本文整理汇总了C++中CEntity::getIsDead方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntity::getIsDead方法的具体用法?C++ CEntity::getIsDead怎么用?C++ CEntity::getIsDead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEntity
的用法示例。
在下文中一共展示了CEntity::getIsDead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
void CIARunAway::process(const std::shared_ptr<Logic::IMessage> &message)
{
if (message->getType() == "CHANGE_TARGET")
{
CEntity* ent = dynamic_cast<CHANGE_TARGET*>(message.get())->getLogicEntity();
if(ent != NULL)
{
if(!ent->getIsDead())
{
_target = ent;
if (_target->getCenterPosition().x > _entity->getCenterPosition().x)
{
_direction = -1;
}
else
{
_direction = 1;
}
std::shared_ptr<Logic::TURN> m(new Logic::TURN());
m->setInt(_direction);
_entity->emitMessage(m);
}
}
}
} // process
示例2: process
void CIADodge::process(const std::shared_ptr<Logic::IMessage> &message)
{
if(message->getType() == "DAMAGED")
{
// Si no está esquivando....
if (!_initIA && _canIA)
{
// Comprobamos primero si el enemigo está cerca del personaje
Vector3 dist = _target->getCenterPosition() - _entity->getCenterPosition();
float distLength = dist.length();
if (distLength < _rangeDetect)
{
// Comprobamos si el aleatorio es un % viable
int random = rand()% 101;
if (random <= _successPercent)
{
_initIA = true;
std::shared_ptr<CAN_MOVE> m(new CAN_MOVE);
m->setBool(false);
_entity->emitMessage(m);
}
}
}
// Si sigue sin activarse la IA (es decir, no se cumplen las condiciones), restamos vida al enemigo.
if (!_initIA || !_canIA)
{
CLifeEnemy* compLife = (CLifeEnemy*)_entity->getComponent("CLifeEnemy");
if (!compLife->getInvincible())
{
compLife->damageEntity(dynamic_cast<DAMAGED*>(message.get())->getFloat(),
dynamic_cast<DAMAGED*>(message.get())->getString());
}
}
}
else if(message->getType().compare("FALLING") == 0)
{
_isFalling = dynamic_cast<FALLING*>(message.get())->getBool();
}
else if (message->getType() == "CHANGE_TARGET")
{
CEntity* ent = dynamic_cast<CHANGE_TARGET*>(message.get())->getLogicEntity();
if(ent != NULL)
{
if(!ent->getIsDead())
{
_target = ent;
}
}
}
else if (message->getType() == "CAN_IA")
{
_canIA = dynamic_cast<CAN_IA*>(message.get())->getBool();
}
} // process