本文整理汇总了C++中CEntity::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntity::GetPosition方法的具体用法?C++ CEntity::GetPosition怎么用?C++ CEntity::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEntity
的用法示例。
在下文中一共展示了CEntity::GetPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ActionShoot
EStatus ActionShoot(const float frametime, CBot* bot, bool shotgun)
{
bot->SetSpeed( 0.0f );
bot->SetState(ai::EBotState::BotStateShooting);
if ( bot->Aim(frametime) )
{
CEntityList* entList = CEntityList::GetInstance();
CEntity* ent = entList->GetEntity( bot->GetTargetID() );
if ( ent != NULL )
{
XMFLOAT3 ray = utl::Normalise( utl::Subtract( bot->GetPosition(), ent->GetPosition() ) );
if (CheckLOS(bot, ray, entList) && bot->GetAmmo(shotgun) != 0)
{
bot->Shoot( frametime, shotgun );
return Pass;
}
else
{
return Fail;
}
}
}
else
{
return Running;
}
return Fail;
}
示例2: ConditionInRange
EStatus ConditionInRange(CBot* bot)
{
CEntity* target = CEntityList::GetInstance()->GetEntity( bot->GetTargetID() );
if (target == NULL)
{
return Error;
}
if (utl::DistanceToSquared(bot->GetPosition(), target->GetPosition()) < gInRange)
{
return Pass;
}
return Fail;
}
示例3: ConditionLongRange
EStatus ConditionLongRange(CBot* bot)
{
CEntity* target = CEntityList::GetInstance()->GetEntity( bot->GetTargetID() );
if (target == NULL)
{
return Error;
}
float distSq = utl::DistanceToSquared(bot->GetPosition(), target->GetPosition());
if (distSq > gCloseRange)
{
return Pass;
}
return Fail;
}
示例4: CheckLOS
bool CheckLOS(CBot* bot, const XMFLOAT3 &ray, CEntityList* entList)
{
XMFLOAT3 rayPoint = bot->GetPosition();
bool end = false;
CEntity* ent;
int count = 0;
int numOfEntities = entList->GetNumberOfEntities();
unsigned int botID = bot->GetUID();
while (!end)
{
rayPoint.x += (ray.x * gRayInc);
rayPoint.z += (ray.z * gRayInc);
if (count == 150)
{
return false;
}
for (int i = 0; i < numOfEntities; i++)
{
ent = entList->GetEntityAtIndex(i);
if (ent != NULL && ent->GetUID() != botID)
{
// Checks collision between ray and object
if (typeid(*(ent->GetBoundingArea())) == typeid(CBoundingSphere))
{
float radius = ((CBoundingSphere*) ent->GetBoundingArea())->GetRadius();
end = PointToSphere( rayPoint, ent->GetPosition(), radius );
}
else if (typeid(*(ent->GetBoundingArea())) == typeid(CBoundingBox))
{
SBoundingBoxData bbox = ((CBoundingBox*) ent->GetBoundingArea())->GetBoxData();
end = PointToBox( rayPoint, ent->GetPosition(), bbox );
}
else
{
end = false;
}
// if the light of sight has found an object and it exists
if (end && typeid(*ent) != typeid (CFlag) && typeid(*ent) != typeid (CBullet))
{
if (typeid(*ent) == typeid(CBot) || typeid(*ent) == typeid(CPlayer))
{
if (((CBot*)ent)->GetTeam() == bot->GetTeam())
{
return false;
}
else
{
bot->SetTargetID(ent->GetUID());
return true;
}
}
else
{
return false;
}
}
}
}
count++;
}
return false;
}