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


C++ Character::IsDead方法代码示例

本文整理汇总了C++中Character::IsDead方法的典型用法代码示例。如果您正苦于以下问题:C++ Character::IsDead方法的具体用法?C++ Character::IsDead怎么用?C++ Character::IsDead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Character的用法示例。


在下文中一共展示了Character::IsDead方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CanUseCharacter

bool AIIdea::CanUseCharacter(const Character & character)
{
  if (character.IsDead())
    return false;

  bool can_change_character = GameMode::GetInstance()->AllowCharacterSelection()
    && (Game::GetInstance()->ReadState() == Game::PLAYING)
    && !Game::GetInstance()->IsCharacterAlreadyChosen();
  return (character.IsActiveCharacter() || can_change_character);
}
开发者ID:Arnaud474,项目名称:Warmux,代码行数:10,代码来源:ai_idea.cpp

示例2: Update

//----------------------------------------------------------------------------
void GroupBuf::Update (double appSeconds, double elapsedSeconds)
{
	Buf::Update(appSeconds, elapsedSeconds);

	Scene *scene = PX2_PROJ.GetScene();
	Character *targetChar = DynamicCast<Character>(scene->GetActorByID(mToGroupCharacterID));
	if (targetChar)
	{
		mCharacter->SetGroup(targetChar->GetGroup());

		if (targetChar->IsDead() || targetChar->IsFreezed())
			SetOver(true);
	}
	else
	{
		SetOver(true);
	}
}
开发者ID:SylviaTanenbaum,项目名称:3d-simulation-and-game,代码行数:19,代码来源:PX2GroupBuf.cpp

示例3: Refresh

void Suicide::Refresh()
{
  // The suicide sound may play at different speed for different players,
  // that's why the explosion should not depend on the fact if the sound has finished playing or not.
  uint time_since_last_fire = Time::GetInstance()->Read() - m_last_fire_time;
  Character *player = &ActiveCharacter();
  if (m_last_fire_time > 0 && time_since_last_fire > SUICIDE_SOUND_DURATION_IN_MS && !player->IsDead()) {
    player->DisableDeathExplosion();
    player->body->MakeParticles(ActiveCharacter().GetPosition());
    player->SetEnergy(0, player); // Die!
    ApplyExplosion(player->GetCenter(), cfg());
  }
}
开发者ID:yeKcim,项目名称:warmux,代码行数:13,代码来源:suicide.cpp

示例4: Activate

//----------------------------------------------------------------------------
bool Skill::Activate()
{
	Scene *scene = PX2_PROJ.GetScene();
	if (!scene) return false;

	if (!mCharacter)
		return false;

	if (!mFirstSkillStep)
		return false;

	if (mActivateAllowTimes >= 0)
	{
		if (mActivatedTimes >= mActivateAllowTimes)
			return false;
	}

	if (IsOnCD())
		return false;

	SkillController *skillComp = DynamicCast<SkillController>(
		mCharacter->GetControllerByName("SkillController"));
	if (skillComp)
	{
		assertion(false, "has no this component.");
		return false;
	}

	mIsActivatting = true;
	SetOnCD(true);
	SetOnCDTime(0.0f);

	float randomVal = Mathf::UnitRandom();
	if (randomVal > mActivateProbability)
		return true;

	mActivatedTimes++;

	const APoint &curPos = mCharacter->LocalTransform.GetTranslate();
	const AVector &faceDir = mCharacter->GetHeading();
	int aimTarget = skillComp->GetAimTarget();
	Character *aimChar = skillComp->GetAimTargetCharacter();
	int group = mCharacter->GetGroup();

	float radiusLength = GetMRadiusLength();
	float width = GetMWidth();
	float degree = GetMFanDegree();

	ShapeType shapeType = GetShapeType();
	int numRangeLock = GetNumRangeLock();
	AffectGroupType agt = GetAffectGroupType();

	if (NFT_NEAR == mNearFarType)
	{
		SkillInstance *inst = new0 SkillInstance(this);
		mSkillInstances.push_back(inst);

		int numAdded = 0;

		inst->SetAimTarget(aimTarget);

		if (IsRangeType()) // ·¶Ξ§
		{
			if (-1 == numRangeLock)
			{
				std::vector<Actor*> actors;
				scene->GetRangeActors(actors, curPos, radiusLength, true, GetSkillQueryBitSet());
				for (int i = 0; i < (int)actors.size(); i++)
				{
					Character *character = DynamicCast<Character>(actors[i]);

					if (character && !character->IsDead())
					{
						const APoint &targetPos = character->LocalTransform.GetTranslate();
						float targetRadius = character->GetRadius();

						if (IsInRange(curPos, radiusLength, width, faceDir, degree, targetPos,
							targetRadius, shapeType, false))
						{
							inst->AddTarget(character->GetID());
							numAdded++;
						}
					}
				}
			}
			else if (numRangeLock > 0)
			{
				if (AGT_SELF == agt)
				{
					inst->AddTarget(mCharacter->GetID());
					numAdded++;
				}

				std::vector<Actor*> actors;
				scene->GetRangeActors(actors, curPos, radiusLength, true, GetSkillQueryBitSet());
				for (int i = 0; i < (int)actors.size(); i++)
				{
					Character *character = DynamicCast<Character>(actors[i]);
					if (character && !character->IsDead() &&
//.........这里部分代码省略.........
开发者ID:JamShan,项目名称:Phoenix3D_2.1,代码行数:101,代码来源:PX2Skill_Activate.cpp

示例5: Do

void Chapter::Do(Character& character) const
{
  if (m_verbose) { std::clog << __func__ << std::endl; }
  Helper h;

  assert(m_observer);
  character.SetObserver(m_observer);

  if (m_verbose) { std::clog << "The first text comes now" << std::endl; }

  ShowText("\n");

  #ifndef NDEBUG
  ShowText("CHAPTER " + h.ToStr(GetChapterNumber()) + "\n");
  #endif

  //Display the text line by line
  ShowText(m_text + "\n");

  if (m_verbose) { std::clog << "The first text has been" << std::endl; }


  if (GetType() == ChapterType::game_lost)
  {
    m_game_lost_chapter.Do(character);
    assert(character.IsDead());
    return;
  }
  else if (GetType() == ChapterType::game_won)
  {
    ShowText("\n");
    m_game_won_chapter.Do(character);
    ShowText("\n");
    return;
  }
  else if (GetType() == ChapterType::play_dice)
  {
    m_dice_game_chapter.Do(character);
    m_consequence.Apply(character);
  }
  else if (GetType() == ChapterType::play_ball)
  {
    m_ball_game_chapter.Do(character);
    m_consequence.Apply(character);
  }
  else if (GetType() == ChapterType::play_pill)
  {
    m_pill_game_chapter.Do(character);
    if (character.IsDead()) return;
    m_consequence.Apply(character);
  }
  //Options
  else if (!GetOptions().GetOptions().empty())
  {
    if (GetOptions().GetValidOptions(character).empty())
    {
      std::cerr
        << "ERROR: no valid options in chapter " << character.GetCurrentChapter()
        << std::endl
        << "Options:\n"
      ;
      assert(GetOptions().GetOptions().size() == 2);
    }
    while (1)
    {
      if (m_verbose) { std::clog << "Let the use choose a valid option" << std::endl; }

      auto options = GetOptions().GetValidOptions(character);

      //If there are options, add (1) showing inventory (2) eating provision (3) drinking potion
      if (options.size() > 1)
      {
        //Add to show the inventory
        options.push_back(CreateShowInventoryOption());
        if (character.GetProvisions() > 0) { options.push_back(CreateEatProvisionOption()); }
        if (character.HasPotion()) { options.push_back(CreateDrinkPotionOption()); }
      }

      if (m_verbose) { std::clog << "Do the request" << std::endl; }

      assert(m_observer);
      const auto chosen = m_observer->RequestOption(options);

      if (m_verbose) { std::clog << "Done the request" << std::endl; }

      ShowText("\n");
      if (chosen.GetConsequence().GetType() == ConsequenceType::show_inventory)
      {
        //Showing the inventory is trivial
        this->ShowText(character.ShowInventory());
        continue;
      }
      if (chosen.GetConsequence().GetType() == ConsequenceType::eat_provision)
      {
        character.ChangeProvisions(-1);
        character.ChangeCondition(4);
        continue;
      }
      if (chosen.GetConsequence().GetType() == ConsequenceType::drink_potion)
      {
//.........这里部分代码省略.........
开发者ID:richelbilderbeek,项目名称:CityOfThieves,代码行数:101,代码来源:chapter.cpp


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