本文整理汇总了C++中Guard::GetKnockedOut方法的典型用法代码示例。如果您正苦于以下问题:C++ Guard::GetKnockedOut方法的具体用法?C++ Guard::GetKnockedOut怎么用?C++ Guard::GetKnockedOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guard
的用法示例。
在下文中一共展示了Guard::GetKnockedOut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void AttackState::Update(double dt)
{
FSMState::Update(dt);
Guard* g = dynamic_cast<Guard*>(m_FSMOwner);
// Check if the NPC is legit
if (!g)
{
return;
}
if (g->GetAttacked() && g->GetKnockedOut())
{
if (g->GetLastTarget())
{
g->GetLastTarget()->SetTargetted(false); // Tell spy that guard no longer has sight on it
}
else if (g->GetTarget())
{
g->GetTarget()->SetTargetted(false); // Tell spy that guard no longer has sight on it
}
g->SetMoveSpeed(Guard::S_GUARD_PATROL_SPEED);
changeState(new AttackedState());
return;
}
if (!g->GetTarget()) // Target missing
{
m_missingTimer += dt;
if (g->GetLastTarget())
{
//g->GetLastTarget()->SetTargetted(false); // Tell spy that guard no longer has sight on it
}
if (!m_reached)
{
if (m_recordPoint)
{
g->AddToFallback(g->GetTransform().Translation);
m_recordPoint = false;
}
moveToLastSeen(dt);
}
else
{
g->SetMoveSpeed(Guard::S_GUARD_PATROL_SPEED);
g->GetView()->SetScale(Vector2(g->GetDefaultViewRadius() * 2.f, g->GetDefaultViewRadius() * 2.f));
g->UpdateViewPosition();
changeState(new PatrolState());
return;
}
}
else // Target still in sight
{
m_missingTimer = 0.f;
m_recordPoint = true;
g->GetTarget()->SetTargetted(true); // Tell spy that guard spotted it
m_attackTimer += dt;
if (m_attackTimer >= S_TIME_TILL_ATTACK)
{
int killChance = Math::RandIntMinMax(1, 100);
if (killChance < 70) // % chance to kill spy
{
g->GetTarget()->Kill();
g->GetTarget()->SetTargetted(false);
g->SetMoveSpeed(Guard::S_GUARD_PATROL_SPEED);
g->GetView()->SetScale(Vector2(g->GetDefaultViewRadius() * 2.f, g->GetDefaultViewRadius() * 2.f));
g->UpdateViewPosition();
changeState(new PatrolState());
return;
}
m_attackTimer = 0.f;
}
}
if (m_missingTimer >= S_MISSING_TIMER) // Can't find target for a period of time
{
if (g->GetLastTarget())
{
g->GetLastTarget()->SetTargetted(false); // Tell spy that guard no longer has sight on it
}
changeState(new PatrolState());
g->GetView()->SetScale(Vector2(g->GetDefaultViewRadius() * 2.f, g->GetDefaultViewRadius() * 2.f));
g->UpdateViewPosition();
return;
}
}