本文整理汇总了C++中UnitArray::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitArray::begin方法的具体用法?C++ UnitArray::begin怎么用?C++ UnitArray::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitArray
的用法示例。
在下文中一共展示了UnitArray::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Unit *MoonScriptCreatureAI::ForceCreatureFind( uint32 pCreatureId, float pX, float pY, float pZ )
{
Unit *UnitPtr = NULLUNIT;
MapMgr *Mgr = _unit->GetMapMgr();
if ( Mgr == NULL )
return UnitPtr;
UnitPtr = TO_UNIT(Mgr->GetObjectClosestToCoords(pCreatureId, pX, pY, pZ, 99999.0f, TYPEID_UNIT ));
if ( UnitPtr == NULL )
{
UnitArray Array;
for ( uint32 i = 0; i != Mgr->m_CreatureHighGuid; ++i )
{
UnitPtr = Mgr->m_CreatureStorage[ i ];
if ( UnitPtr != NULL )
{
if ( UnitPtr->GetEntry() == pCreatureId && UnitPtr != _unit )
Array.push_back( UnitPtr );
}
}
if ( Array.size() == 1 )
return Array[ 0 ];
UnitPtr = NULLUNIT;
float Distance, NearestDistance = 99999;
for ( UnitArray::iterator UnitIter = Array.begin(); UnitIter != Array.end(); ++UnitIter )
{
Distance = _unit->CalcDistance( pX, pY, pZ, ( *UnitIter )->GetPositionX(), ( *UnitIter )->GetPositionY(), ( *UnitIter )->GetPositionZ() );
if ( Distance < NearestDistance )
{
NearestDistance = Distance;
UnitPtr = ( *UnitIter );
}
}
}
return UnitPtr;
}
示例2: ForceCreatureFind
Unit* AscentScriptCreatureAI::ForceCreatureFind( uint32 pCreatureId, float pX, float pY, float pZ )
{
Unit* UnitPtr = NULL;
MapMgr* Mgr = _unit->GetMapMgr();
if ( Mgr == NULL )
return UnitPtr;
UnitPtr = Mgr->GetInterface()->GetCreatureNearestCoords( pX, pY, pZ, pCreatureId );
if ( UnitPtr == NULL )
{
UnitArray Array;
for ( uint32 i = 0; i != Mgr->m_CreatureHighGuid; ++i )
{
UnitPtr = Mgr->m_CreatureStorage[ i ];
if ( UnitPtr != NULL )
{
if ( UnitPtr->GetEntry() == pCreatureId && UnitPtr != _unit )
Array.push_back( UnitPtr );
};
};
if ( Array.size() == 1 )
return Array[ 0 ];
UnitPtr = NULL;
float Distance, NearestDistance = 99999;
for ( UnitArray::iterator UnitIter = Array.begin(); UnitIter != Array.end(); ++UnitIter )
{
Distance = _unit->CalcDistance( pX, pY, pZ, ( *UnitIter )->GetPositionX(), ( *UnitIter )->GetPositionY(), ( *UnitIter )->GetPositionZ() );
if ( Distance < NearestDistance )
{
NearestDistance = Distance;
UnitPtr = ( *UnitIter );
};
};
};
return UnitPtr;
};