当前位置: 首页>>代码示例>>C++>>正文


C++ UnitArray::push_back方法代码示例

本文整理汇总了C++中UnitArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitArray::push_back方法的具体用法?C++ UnitArray::push_back怎么用?C++ UnitArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitArray的用法示例。


在下文中一共展示了UnitArray::push_back方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetBestUnitTarget

Unit* AscentScriptCreatureAI::GetBestUnitTarget( TargetFilter pTargetFilter, float pMinRange, float pMaxRange )
{
	//Build potential target list
	UnitArray TargetArray;
	if ( pTargetFilter & TargetFilter_Friendly )
	{
		for ( unordered_set< Object* >::iterator ObjectIter = _unit->GetInRangeSetBegin(); ObjectIter != _unit->GetInRangeSetEnd(); ++ObjectIter )
		{
			if ( IsValidUnitTarget( *ObjectIter, pTargetFilter, pMinRange, pMaxRange ) )
				TargetArray.push_back( TO_UNIT( *ObjectIter ) );
		};

		if ( IsValidUnitTarget( _unit, pTargetFilter ) )
			TargetArray.push_back( _unit );	//Also add self as possible friendly target
	}
	else
	{
		for ( unordered_set< Object* >::iterator ObjectIter = _unit->GetInRangeOppFactsSetBegin(); ObjectIter != _unit->GetInRangeOppFactsSetEnd(); ++ObjectIter )
		{
			if ( IsValidUnitTarget( *ObjectIter, pTargetFilter, pMinRange, pMaxRange ) )
				TargetArray.push_back( TO_UNIT( *ObjectIter ) );
		};
	};

	return ChooseBestTargetInArray( TargetArray, pTargetFilter );
};
开发者ID:Ballwinkle,项目名称:Ascent_NG,代码行数:26,代码来源:Base.cpp

示例2: ChooseBestTargetInArray

Unit *MoonScriptCreatureAI::GetBestUnitTarget( TargetFilters pTargetFilter, float pMinRange, float pMaxRange)
{
	//Build potential target list
	UnitArray TargetArray;
	if ( pTargetFilter & TargetFilter_Friendly )
	{
		for ( unordered_set< Object *>::iterator ObjectIter = _unit->GetInRangeSetBegin(); ObjectIter != _unit->GetInRangeSetEnd(); ++ObjectIter )
		{
			// Trololololo.......
			if( IsValidUnitTarget(*ObjectIter, pTargetFilter, pMinRange, pMaxRange) )
			{
				if(pTargetFilter & TargetFilter_ManaClass)
				{
					if(TO_UNIT(*ObjectIter)->GetPowerType() == POWER_TYPE_MANA)
						TargetArray.push_back( TO_UNIT( *ObjectIter ) );
				}
				else
					TargetArray.push_back( TO_UNIT( *ObjectIter ) );
			}
		};

		if ( IsValidUnitTarget( _unit, pTargetFilter ) )
			TargetArray.push_back( _unit );	//Also add self as possible friendly target
	}
	else
	{
		for ( unordered_set< Object *>::iterator ObjectIter = _unit->GetInRangeOppFactsSetBegin(); ObjectIter != _unit->GetInRangeOppFactsSetEnd(); ++ObjectIter )
		{
			// Problem, Dylan?
			if( IsValidUnitTarget(*ObjectIter, pTargetFilter, pMinRange, pMaxRange) )
			{
				if(pTargetFilter & TargetFilter_ManaClass)
				{
					if(TO_UNIT(*ObjectIter)->GetPowerType() == POWER_TYPE_MANA)
						TargetArray.push_back( TO_UNIT( *ObjectIter ) );
				}
				else
					TargetArray.push_back( TO_UNIT( *ObjectIter ) );
			}
		};
	};

	return ChooseBestTargetInArray( TargetArray, pTargetFilter );
};
开发者ID:Refuge89,项目名称:Hearthstone,代码行数:44,代码来源:Base.cpp

示例3: GetBestPlayerTarget

Unit* ArcScriptCreatureAI::GetBestPlayerTarget(TargetFilter pFilter)
{
	//Build potential target list
	UnitArray TargetArray;
	for( set<Player*>::iterator PlayerIter = _unit->GetInRangePlayerSetBegin(); PlayerIter != _unit->GetInRangePlayerSetEnd(); ++PlayerIter ) 
	{ 
		if( IsValidUnitTarget(*PlayerIter, pFilter) ) TargetArray.push_back(static_cast<Unit*>(*PlayerIter));
	}

	return ChooseBestTargetInArray(TargetArray, pFilter);
}
开发者ID:AegisEmu,项目名称:AegisEmu,代码行数:11,代码来源:Base.cpp

示例4: GetBestUnitTarget

Unit* ArcScriptCreatureAI::GetBestUnitTarget(TargetFilter pFilter)
{
	//Build potential target list
	UnitArray TargetArray;
	if( pFilter & TargetFilter_Friendly )
	{
		for( std::set<Object*>::iterator ObjectIter = _unit->GetInRangeSetBegin(); ObjectIter != _unit->GetInRangeSetEnd(); ++ObjectIter )
		{
			if( IsValidUnitTarget(*ObjectIter, pFilter) ) TargetArray.push_back(static_cast<Unit*>(*ObjectIter));
		}
		if( IsValidUnitTarget(_unit, pFilter) ) TargetArray.push_back(_unit);	//Also add self as possible friendly target
	}
	else
	{
		for( std::set<Object*>::iterator ObjectIter = _unit->GetInRangeOppFactsSetBegin(); ObjectIter != _unit->GetInRangeOppFactsSetEnd(); ++ObjectIter )
		{
			if( IsValidUnitTarget(*ObjectIter, pFilter) ) TargetArray.push_back(static_cast<Unit*>(*ObjectIter));
		}
	}

	return ChooseBestTargetInArray(TargetArray, pFilter);
}
开发者ID:AegisEmu,项目名称:AegisEmu,代码行数:22,代码来源:Base.cpp

示例5: GetInRangePlayers

	UnitArray GetInRangePlayers()
	{
		UnitArray TargetArray;
		for (unordered_set<Player*>::iterator itr = _unit->GetInRangePlayerSetBegin(); itr != _unit->GetInRangePlayerSetEnd(); itr++) 
		{ 
			if (IsValidUnitTarget(*itr, TargetFilter_None))
			{
				TargetArray.push_back(TO_UNIT(*itr));
			}
		}

		return TargetArray;
	}
开发者ID:Bootz,项目名称:arcticdev,代码行数:13,代码来源:Raid_GruulsLair.cpp

示例6: GetInRangePlayers

        UnitArray GetInRangePlayers()
        {
            UnitArray TargetArray;
            for (set< Object* >::iterator itr = _unit->GetInRangePlayerSetBegin(); itr != _unit->GetInRangePlayerSetEnd(); ++itr)
            {
                if (IsValidUnitTarget(*itr, TargetFilter_None))
                {
                    TargetArray.push_back(TO< Unit* >(*itr));
                }
            }

            return TargetArray;
        }
开发者ID:TheGhostGroup,项目名称:AscEmu,代码行数:13,代码来源:Raid_GruulsLair.cpp

示例7:

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;
}
开发者ID:Refuge89,项目名称:Hearthstone,代码行数:39,代码来源:Base.cpp

示例8: 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;
};
开发者ID:Ballwinkle,项目名称:Ascent_NG,代码行数:39,代码来源:Base.cpp


注:本文中的UnitArray::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。