本文整理汇总了C++中ActorPtr::performAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ActorPtr::performAction方法的具体用法?C++ ActorPtr::performAction怎么用?C++ ActorPtr::performAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActorPtr
的用法示例。
在下文中一共展示了ActorPtr::performAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
int CmdCast::execute()
{
int turns = 0;
SpellPtr spell = getSpell();
Engine::instance().render();
Engine::instance().flush();
ActorPtr player = Engine::instance().getPlayer();
if ( spell )
{
TargetSelectorPtr selector( TargetSelector::create( spell->getTargetType() ) );
if ( selector )
{
selector->setRange( spell->getRange() );
selector->setRadius( spell->getRadius() );
MapPtr map = Engine::instance().getWorld().getCurrentMap();
Target target = selector->select([&](ActorPtr a){ return map->isInFov(a->getX(), a->getY()); });
if ( player->performAction( new CastAction(spell, target) ) != ActorActionResult::Ok )
{
gui::msgBox("Failed to cast spell!", gui::MsgType::Warning);
}
}
++turns;
}
return turns;
}
示例2: execute
int CmdUseSkill::execute()
{
int turns(0);
if ( SkillPtr skill = getSkill() )
{
Engine::instance().render();
Engine::instance().flush();
ActorPtr player = Engine::instance().getPlayer();
TargetSelectorPtr selector( TargetSelector::create( skill->getTargetType() ) );
if ( selector )
{
selector->setRadius( skill->getRadius() );
MapPtr map = Engine::instance().getWorld().getCurrentMap();
ActorActionPtr action(
new UseSkillAction(skill, selector->select([&](ActorPtr a){
return map->isInFov(a->getX(), a->getY());
})) );
if ( player->performAction( action ) != ActorActionResult::Ok )
{
gui::msgBox(skill->getName() + " failed!", gui::MsgType::Warning);
}
++turns;
}
}
return turns;
}
示例3: setHitPoints
void Character::setHitPoints(int newHp)
{
_hitPoints = newHp;
if ( _hitPoints <= 0 )
{
ActorPtr owner = getOwner().lock();
if ( owner )
{
owner->performAction( std::make_shared<DieAction>() );
}
}
}
示例4:
TEST_F(MoveActionTest, actorWithoutMap)
{
ActorPtr orc = Actor::create(ActorType::Orc);
EXPECT_FALSE(orc->performAction( std::make_shared<MoveAction>(1, 1)));
}