本文整理汇总了C++中CvPlot::getNumUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ CvPlot::getNumUnits方法的具体用法?C++ CvPlot::getNumUnits怎么用?C++ CvPlot::getNumUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvPlot
的用法示例。
在下文中一共展示了CvPlot::getNumUnits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResponseSwapUnits
//------------------------------------------------------------------------------
void CvDllNetMessageHandler::ResponseSwapUnits(PlayerTypes ePlayer, int iUnitID, MissionTypes eMission, int iData1, int iData2, int iFlags, bool bShift)
{
CvUnit::dispatchingNetMessage(true);
CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);
CvUnit* pkUnit = kPlayer.getUnit(iUnitID);
if(pkUnit != NULL)
{
// Get target plot
CvMap& kMap = GC.getMap();
CvPlot* pkTargetPlot = kMap.plot(iData1, iData2);
if(pkTargetPlot != NULL)
{
CvPlot* pkOriginationPlot = pkUnit->plot();
// Find unit to move out
for(int iI = 0; iI < pkTargetPlot->getNumUnits(); iI++)
{
CvUnit* pkUnit2 = pkTargetPlot->getUnitByIndex(iI);
if(pkUnit2 && pkUnit2->AreUnitsOfSameType(*pkUnit))
{
// Start the swap
pkUnit->PushMission(CvTypes::getMISSION_MOVE_TO(), iData1, iData2, CvUnit::MOVEFLAG_IGNORE_STACKING, bShift, true);
// Move the other unit back out, again splitting if necessary
pkUnit2->PushMission(CvTypes::getMISSION_MOVE_TO(), pkOriginationPlot->getX(), pkOriginationPlot->getY());
}
}
}
}
CvUnit::dispatchingNetMessage(false);
}
示例2: StartTurn
//------------------------------------------------------------------------------
void CvPlayerAchievements::StartTurn()
{
#if !defined(NO_ACHIEVEMENTS)
if(m_kPlayer.GetID() != GC.getGame().getActivePlayer())
return;
if(m_eSwedenType == UNDEFINED_TYPE)
{
m_eSwedenType = (CivilizationTypes)GC.getInfoTypeForString("CIVILIZATION_SWEDEN", true);
}
if(m_eGreatGeneralType == UNDEFINED_TYPE)
{
m_eGreatGeneralType = (UnitTypes)GC.getInfoTypeForString("UNIT_GREAT_GENERAL", true);
}
if(m_eHakkapelittaType == UNDEFINED_TYPE)
{
m_eHakkapelittaType = (UnitTypes)GC.getInfoTypeForString("UNIT_SWEDISH_HAKKAPELIITTA", true);
}
if(m_eSwedenType != NO_CIVILIZATION && m_eGreatGeneralType != NO_UNIT && m_eHakkapelittaType != NO_UNIT)
{
if(m_kPlayer.getCivilizationType() == m_eSwedenType)
{
int iLoop = 0;
for(const CvUnit* pUnit = m_kPlayer.firstUnit(&iLoop); pUnit != NULL; pUnit = m_kPlayer.nextUnit(&iLoop))
{
if(pUnit->getUnitType() == m_eGreatGeneralType)
{
CvPlot* pPlot = pUnit->plot();
if(pPlot != NULL)
{
int iNumUnits = pPlot->getNumUnits();
for(int i = 0; i < iNumUnits; ++i)
{
CvUnit* pStackedUnit = pPlot->getUnitByIndex(i);
if(pStackedUnit->getUnitType() == m_eHakkapelittaType)
{
gDLL->UnlockAchievement(ACHIEVEMENT_XP1_31);
return;
}
}
}
}
}
}
}
#endif
}
示例3: KilledUnitWithUnit
//------------------------------------------------------------------------------
void CvPlayerAchievements::KilledUnitWithUnit(CvUnit* pKillingUnit, CvUnit* pKilledUnit)
{
if(m_kPlayer.GetID() != GC.getGame().getActivePlayer())
return;
if(m_eByzantinesType == UNDEFINED_TYPE)
{
m_eByzantinesType = (CivilizationTypes)GC.getInfoTypeForString("CIVILIZATION_BYZANTIUM", true);
}
if(m_eGreekType == UNDEFINED_TYPE)
{
m_eGreekType = (CivilizationTypes)GC.getInfoTypeForString("CIVILIZATION_GREECE", true);
}
if(m_eDromonType == UNDEFINED_TYPE)
{
m_eDromonType = (UnitTypes)GC.getInfoTypeForString("UNIT_BYZANTINE_DROMON", true);
}
if(m_eDromonType != NO_UNIT && m_eByzantinesType != NO_CIVILIZATION && m_eGreekType != NO_CIVILIZATION)
{
//* ACHIEVEMENT_XP1_33 - As Byzantines, sink 10 Greek ships with a Dromon
if( pKillingUnit->getCivilizationType() == m_eByzantinesType &&
pKillingUnit->getUnitType() == m_eDromonType &&
pKilledUnit->getCivilizationType() == m_eGreekType &&
pKilledUnit->getDomainType() == DOMAIN_SEA)
{
m_iAchievement_XP1_33_Progress++;
if(m_iAchievement_XP1_33_Progress >= 10)
{
gDLL->UnlockAchievement(ACHIEVEMENT_XP1_33);
}
}
}
bool bUsingXP1Scenario3 = gDLL->IsModActivated(CIV5_XP1_SCENARIO3_MODID);
if(bUsingXP1Scenario3)
{
if(m_eSkyFortress == UNDEFINED_TYPE)
{
m_eSkyFortress = (UnitTypes)GC.getInfoTypeForString("UNIT_SKY_FORTRESS" , true);
}
if(pKillingUnit->getDomainType() == DOMAIN_AIR)
{
const int iX = pKillingUnit->getX();
const int iY = pKillingUnit->getY();
CvPlot* pkPlot = GC.getMap().plot(iX, iY);
if(pkPlot != NULL)
{
const int iNumUnits = pkPlot->getNumUnits();
for(int i = 0; i < iNumUnits; ++i)
{
CvUnit* pUnit = pkPlot->getUnitByIndex(i);
if(pUnit && pUnit->getUnitType() == m_eSkyFortress)
{
gDLL->UnlockAchievement(ACHIEVEMENT_XP1_46);
}
}
}
}
}
}