本文整理汇总了C++中Monster::atack方法的典型用法代码示例。如果您正苦于以下问题:C++ Monster::atack方法的具体用法?C++ Monster::atack怎么用?C++ Monster::atack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monster
的用法示例。
在下文中一共展示了Monster::atack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tick
//.........这里部分代码省略.........
if (actor->GetType () == EActorType::PROJECTILE)
{
static_cast<Projectile*>(actor)->death = true;
}
else
{
actor->OnCollideWorld();
}
}
}
if (actor->GetType() == EActorType::PLAYER)
{
Player* player = dynamic_cast<Player*>(actor);
if (player->GetHealth() < player->GetMaxHealth())
{
player->SetHealth(player->GetHealth() + 1);
}
}
if (actor->GetType() == EActorType::MONSTER)
{
Monster* monster = dynamic_cast<Monster*>(actor);
Creature* target = monster->target;
if (target && target->GetHealth() > 0)
{
Vector2 m_pos = actor->GetPosition();
Vector2 t_pos = target->GetPosition();
float distance2 = Sqr(m_pos.x - t_pos.x)
+ Sqr(m_pos.y - t_pos.y);
if (distance2 <= Sqr(pickUpRadius_))
{
events_ << monster->atack(target);
events_ << target->atack(monster);
}
}
}
for (Actor* neighbour : actors_)
{
if (actor == nullptr
|| neighbour == nullptr
|| actor == neighbour
|| neighbour->GetType() == EActorType::ITEM
|| (actor->GetType() == EActorType::PROJECTILE
&& neighbour->GetType() == EActorType::PROJECTILE))
{
break;
}
Box box0(neighbour->GetPosition(), 0.9f, 0.9f);
Box box1(actor->GetPosition(), 0.9f, 0.9f);
if (box0.Intersect(box1))
{
actor->OnCollideActor(neighbour);
neighbour->OnCollideActor(actor);
if (actor->GetType() == EActorType::PROJECTILE)
{
static_cast<Projectile*>(actor)->death = true;
if (neighbour->GetType () == EActorType::MONSTER)
{
Monster* monster = dynamic_cast<Monster*>(neighbour);
if (monster->GetHealth () <= 0)
{