本文整理汇总了C++中PlayerList::Begin方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerList::Begin方法的具体用法?C++ PlayerList::Begin怎么用?C++ PlayerList::Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerList
的用法示例。
在下文中一共展示了PlayerList::Begin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateAI_ChasePlayer
void UpdateAI_ChasePlayer( AIComponentChasePlayer *pAiComponent, AvatarControllerComponent *pController )
{
PlayerComponent *pTarget = NULL;
float pTargetDistanceSquared = NumericLimits<float>::Maximum;
Simd::Vector3 targetPosition = Simd::Vector3::Zero;
Simd::Vector3 myPosition = Simd::Vector3::Zero;
TransformComponent *pTransform = pAiComponent->GetComponentCollection()->GetFirst<TransformComponent>();
if ( pTransform )
{
myPosition = pTransform->GetPosition();
for (PlayerList::Iterator iter = g_PlayerList.Begin(); iter != g_PlayerList.End(); ++iter)
{
float d = (iter->Second() - myPosition).GetMagnitudeSquared();
if ( d < pTargetDistanceSquared )
{
pTargetDistanceSquared = d;
pTarget = iter->First();
targetPosition = iter->Second();
}
}
}
if ( pTarget )
{
Simd::Vector3 moveDir = (targetPosition - myPosition).GetNormalized();
pController->m_MoveDir.SetX( moveDir.GetElement(0));
pController->m_MoveDir.SetY( moveDir.GetElement(1));
pController->m_AimDir = Simd::Vector3::Zero;
pController->m_bShoot = false;
}
else
{
pController->m_MoveDir = Simd::Vector2::Zero;
pController->m_AimDir = Simd::Vector3::Zero;
pController->m_bShoot = false;
}
}