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


C++ Monster::GetHealth方法代码示例

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


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

示例1: main

int main(){

	//Declare the characters
	Hero Player;
	Monster Ogre;

	//Set the main characters in game properties
	Player.SetName("Budi");
	Player.SetHealth(1000);
	Player.SetAttack(30);
	Player.SetJob("Magician");
	Player.SetTown("Furedator");

	
	Ogre.SetName("Ograr");
	Ogre.SetHealth(1500);
	Ogre.SetAttack(15);
	Ogre.SetClan("Myrtr");
	
	cout << "Nama playernya adalah " << Player.GetName() << endl;
	cout << "Player memiliki health " << Player.GetHealth() << endl;
	cout << "Attack player adalah " << Player.GetAttack() << endl;
	cout << "Job player adalah " << Player.GetJob() << endl;
	cout << "Kota asal player adalah " << Player.GetTown() << endl;

	
	cout << "Nama monsternya adalah " << Ogre.GetName() << endl;
	cout << "Monsternya memiliki health " << Ogre.GetHealth() << endl;
	cout << "Attack Monsternya adalah " << Ogre.GetAttack() << endl;
	cout << "Clan Monsternya dari " << Ogre.GetClan() << endl;
	



	return 0;
}
开发者ID:igrir,项目名称:ECG,代码行数:36,代码来源:main.cpp

示例2: tick


//.........这里部分代码省略.........
              Creature* m = dynamic_cast<Creature*>(tar);

              QStringList str = monster->Flags.filter("HATE");
              for (QString hate: str)
              {
                if (Hates[hate] == m->GetRace())
                {
                  b = true;
                  break;
                }
              }

              if (b)
              {
                Vector2 t_pos = tar->GetPosition();
                distance2 = Sqr(m_pos.x - t_pos.x) + Sqr(m_pos.y - t_pos.y);
                // Dasha told 5^2 is a protocol defined const
                if (distance2 < 25)
                {
                  monster->target = m;
                  break;
                }
              }
            }
          }
        }
      }
    }

    if (actor->GetType() == EActorType::MONSTER
        || actor->GetType() == EActorType::PLAYER)
    {
      Creature* monster = dynamic_cast<Creature*>(actor);
      if (monster->GetHealth() <= 0)
      {
        KillActor_(actor);
        break;
      }
    }
  }

  for (Actor* actor: actors_)
  {
    if (!actor
        || actor == nullptr)
    {
      break;
    }

    auto v = directionToVector[static_cast<unsigned>(actor->GetDirection())] ;
    actor->SetVelocity(v);
    float dt = playerVelocity_;
    Vector2 old_pos = actor->GetPosition();
    Vector2 new_pos = old_pos + v * (dt + 0.001);
    Vector2 old_pos2 = old_pos + v * 0.51;
    levelMap_.RemoveActor(actor);
    EActorDirection d = actor->GetDirection();
    float x = new_pos.x;
    float y = new_pos.y;
    if (levelMap_.GetCell(old_pos2.x, old_pos2.y) != '#'
        && d != EActorDirection::NONE
        && (((levelMap_.GetCell(x - slideThreshold_+ 0.5f, y) == '.'
              && levelMap_.GetCell(x + slideThreshold_- 0.5f, y) == '.')
             && (d == EActorDirection::NORTH
                 || d == EActorDirection::SOUTH))
            || ((levelMap_.GetCell(x, y - slideThreshold_+ 0.5f) == '.'
开发者ID:dahin,项目名称:fefu-mmorpg,代码行数:67,代码来源:GameServer.cpp


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