本文整理汇总了C++中AI::getState方法的典型用法代码示例。如果您正苦于以下问题:C++ AI::getState方法的具体用法?C++ AI::getState怎么用?C++ AI::getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AI
的用法示例。
在下文中一共展示了AI::getState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void SecurityCam::update(const double &dt, Vector3 &playerPos, std::vector<GameObject*> m_goList)
{
Vector3 SCPos = pos;
Vector3 SCLookat = Lookat;
SCPos.y = SCLookat.y = 0;
switch(c_State)
{
case SPOTTED:
{
float rotationdiff = (CalAnglefromPosition(playerPos, pos, true) - CalAnglefromPosition(Lookat, pos, true)) * 2.f;
Mtx44 rotation;
Lookat = Lookat - pos;
f_rotationLimiter += rotationdiff * static_cast<float>(dt);
rotation.SetToRotation(rotationdiff * static_cast<float>(dt), 0, 1, 0);
Lookat = rotation * Lookat;
Lookat = Lookat + pos;
//Check whether player is still in the fov of security camera
if (((isVisible(SCPos, SCLookat, static_cast<float>(f_cameraFOV), playerPos)) && (SCPos - playerPos).LengthSquared() < f_cameraRange))
{
//Give player 1 sec to prevent detection by the security camera
if (alerttimer < 1)
{
alerttimer += static_cast<float>(dt);
}
else
{
c_State = FOUND;
alerttimer = 0;
}
}
else
{
//if player is no longer in the fov of the security camera
c_State = NOTFOUND;
alerttimer = 0;
}
}
break;
case FOUND:
{
float rotationdiff = (CalAnglefromPosition(playerPos, pos, true) - CalAnglefromPosition(Lookat, pos, true));
if (rotationdiff >= 180)
{
Mtx44 rotation;
Lookat = Lookat - pos;
rotation.SetToRotation(-360, 0, 1, 0);
Lookat = rotation * Lookat;
Lookat = Lookat + pos;
rotationdiff -= 360;
}
else if (rotationdiff <= -180)
{
Mtx44 rotation;
Lookat = Lookat - pos;
rotation.SetToRotation(360, 0, 1, 0);
Lookat = rotation * Lookat;
Lookat = Lookat + pos;
rotationdiff += 360;
}
Mtx44 rotation;
Lookat = Lookat - pos;
f_rotationLimiter += rotationdiff * static_cast<float>(dt);
rotation.SetToRotation(rotationdiff * 2 * static_cast<float>(dt), 0, 1, 0);
Lookat = rotation * Lookat;
Lookat = Lookat + pos;
//Alert all the ai to the camera's position
if (b_alertAI)
{
for (std::vector<GameObject*>::iterator it = m_goList.begin(); it != m_goList.end(); it++)
{
GameObject *go = (GameObject *)*it;
AI *ai = dynamic_cast<AI*>(go);
if (ai != NULL)
{
if (ai->getState() == AI::WALKING)
{
ai->setState(AI::ALERT);
ai->setcurrentLookat(pos);
ai->setDestination(pos);
}
}
}
b_alertAI = false;
}
else
{
if (!isVisible(pos, Lookat, f_cameraFOV, playerPos) || (playerPos - pos).LengthSquared() > f_cameraRange)
{
c_State = NOTFOUND;
}
}
//.........这里部分代码省略.........