コード例 #1
0
ファイル: CRole.cpp プロジェクト: Gamex/GameX
void CRole::damage(float damagePoint, CRole* attacker)
{
    float curHP = getCurHP();
    curHP = curHP - damagePoint;
    if (FLT_LE(curHP, 0.f))
    {
        setCurHP(0.f);
        FIGHT_RELATION->removeAllRelation(dynamic_cast<IFightingRelation*>(this));
        changeState(ROLE_STATE_DYING);
    }
    else
    {
        setCurHP(curHP);
        
        if (attacker)
        {
            if (getMovetarget().equals(Point(-1.f, -1.f)))
            {
                setMoveTarget(attacker->getLogicGrid()->getGridPos());
            }
        }
    }
    
    m_pHPBar->setPercentage(getCurHP() / getMaxHP());
    
    BF_MANAGER->wakeUpAllDefender();
}
コード例 #2
0
void CFBMatch::updateDefendPlayerAroundBall()
{
    m_defendPlayerIds.clear();
    
    auto ballPos = FBMATCH->getBallPosition();
    
    auto defTeam = getDefendingTeam();
    auto& teamMembers = defTeam->getTeamMembers();
    
    for (auto tm : teamMembers)
    {
        if (!tm->m_isGoalKeeper)
        {
            if (FLT_LE(ballPos.getDistanceSq(tm->getPosition()), m_playerDistanceSq))
            {
                m_defendPlayerIds.insert(tm->m_positionInFormation);
            }
        }
    }
}
コード例 #3
0
ファイル: CRole.cpp プロジェクト: Gamex/GameX
bool CRole::checkInGridRadiusSq(IGridRole* role, float radiusInGrid)
{
	return FLT_LE(getDistanceSqInGrid(role), radiusInGrid);
}