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


C++ CvUnit::AI_setUnitAIType方法代码示例

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


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

示例1: RemoveUnit

/// Remove a unit from the army
bool CvArmyAI::RemoveUnit(int iUnitToRemoveID)
{
	for(int iI = 0; iI < (int)m_FormationEntries.size(); iI++)
	{
		CvArmyFormationSlot slot = m_FormationEntries[iI];
		if(slot.GetUnitID() == iUnitToRemoveID)
		{
			CvUnit* pThisUnit = GET_PLAYER(GetOwner()).getUnit(iUnitToRemoveID);
			if(pThisUnit)
			{
				// Clears unit's army ID and erase from formation entries
				pThisUnit->setArmyID(-1);
				pThisUnit->AI_setUnitAIType(pThisUnit->getUnitInfo().GetDefaultUnitAIType());

				// Tell the associate operation that a unit was lost
				CvAIOperation* pThisOperation = GET_PLAYER(GetOwner()).getAIOperation(m_iOperationID);
				if(pThisOperation)
					pThisOperation->UnitWasRemoved(GetID(), iI);

				return true;
			}
		}
	}

	return false;
}
开发者ID:LoneGazebo,项目名称:Community-Patch-DLL,代码行数:27,代码来源:CvArmyAI.cpp

示例2: ReleaseUnits

/// Deallocate memory
void CvArmyAI::ReleaseUnits(bool bAddUnitsToTacticalAI)
{
	for (size_t i = 0; i<m_FormationEntries.size(); i++)
	{
		if (!m_FormationEntries[i].IsUsed())
			continue;

		CvUnit* pThisUnit = GET_PLAYER(GetOwner()).getUnit(m_FormationEntries[i].GetUnitID());
		if (pThisUnit)
		{
			pThisUnit->setArmyID(-1);
			pThisUnit->AI_setUnitAIType(pThisUnit->getUnitInfo().GetDefaultUnitAIType());
			if (bAddUnitsToTacticalAI) //for stupid reasons we first recruit units and then disband armies ...
				GET_PLAYER(GetOwner()).GetTacticalAI()->AddCurrentTurnUnit(pThisUnit);
		}
	}

	m_FormationEntries.clear();
}
开发者ID:LoneGazebo,项目名称:Community-Patch-DLL,代码行数:20,代码来源:CvArmyAI.cpp


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