当前位置: 首页>>代码示例>>C++>>正文


C++ ActorPtr::performAction方法代码示例

本文整理汇总了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;
}
开发者ID:lonski,项目名称:amarlon,代码行数:28,代码来源:cmd_cast.cpp

示例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;
}
开发者ID:lonski,项目名称:amarlon,代码行数:29,代码来源:cmd_use_skill.cpp

示例3: setHitPoints

void Character::setHitPoints(int newHp)
{
  _hitPoints = newHp;

  if ( _hitPoints <= 0 )
  {
    ActorPtr owner = getOwner().lock();
    if ( owner )
    {
      owner->performAction( std::make_shared<DieAction>() );
    }
  }
}
开发者ID:pelagos,项目名称:amarlon,代码行数:13,代码来源:character.cpp

示例4:

TEST_F(MoveActionTest, actorWithoutMap)
{
  ActorPtr orc = Actor::create(ActorType::Orc);
  EXPECT_FALSE(orc->performAction( std::make_shared<MoveAction>(1, 1)));
}
开发者ID:pelagos,项目名称:amarlon,代码行数:5,代码来源:move_action_test.cpp


注:本文中的ActorPtr::performAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。