本文整理汇总了C++中CvPlot::getWorkingCity方法的典型用法代码示例。如果您正苦于以下问题:C++ CvPlot::getWorkingCity方法的具体用法?C++ CvPlot::getWorkingCity怎么用?C++ CvPlot::getWorkingCity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvPlot
的用法示例。
在下文中一共展示了CvPlot::getWorkingCity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckTargetReached
CvPlot* CvArmyAI::CheckTargetReached(PlayerTypes eEnemy, bool bNavalOp, int iMaxDistance)
{
//check if we're at the target
CvPlot *pTargetPlot = GetGoalPlot();
CvPlot *pCenterOfMass = GetCenterOfMass(NO_DOMAIN);
if(pCenterOfMass && pTargetPlot && plotDistance(*pCenterOfMass,*pTargetPlot) <= iMaxDistance)
return pTargetPlot;
//check early termination if we ran into the enemy
if(GetArmyAIState() == ARMYAISTATE_MOVING_TO_DESTINATION)
{
CvPlot* pEnemyPlot = DetectNearbyEnemy(eEnemy, bNavalOp);
if(pEnemyPlot != NULL)
{
CvCity* pCity = pEnemyPlot->getWorkingCity();
if(pCity != NULL)
{
if (bNavalOp && pCity->isCoastal() && pCity->waterArea()==pTargetPlot->area())
pEnemyPlot = pCity->plot();
if (!bNavalOp && pCity->area()==pTargetPlot->area())
pEnemyPlot = pCity->plot();
if (pEnemyPlot!=GetGoalPlot())
{
if(GC.getLogging() && GC.getAILogging())
{
CvString strMsg;
strMsg.Format("Switching target from %d,%d to closest city at %d,%d", GetGoalX(), GetGoalY(), pEnemyPlot->getX(), pEnemyPlot->getY() );
GET_PLAYER(m_eOwner).getAIOperation(m_iOperationID)->LogOperationSpecialMessage(strMsg);
}
}
return pEnemyPlot;
}
}
}
return NULL;
}
示例2: foreachRelated
void CvGameObjectCity::foreachRelated(GameObjectTypes eType, RelationTypes eRelation, boost::function<void(CvGameObject *)> func, int iData)
{
if (eRelation == RELATION_TRADE)
{
if (eType == GAMEOBJECT_CITY)
{
int iRoutes = m_pCity->getTradeRoutes();
for (int i=0; i<iRoutes; i++)
{
CvCity* pTradeCity = m_pCity->getTradeCity(i);
if (pTradeCity)
{
func(pTradeCity->getGameObject());
}
}
}
}
else if (eRelation == RELATION_WORKING)
{
if (eType == GAMEOBJECT_PLOT)
{
for (int iI = 0; iI < m_pCity->getNumCityPlots(); iI++)
{
CvPlot* pLoopPlot = plotCity(m_pCity->getX_INLINE(), m_pCity->getY_INLINE(), iI);
if (pLoopPlot)
{
if (pLoopPlot->getWorkingCity() == m_pCity)
{
func(pLoopPlot->getGameObject());
}
}
}
}
}
else
{
CvGameObject::foreachRelated(eType, eRelation, func, iData);
}
}
示例3: PlotFoundValue
//.........这里部分代码省略.........
{
CvImprovementEntry* pkEntry = GC.getImprovementInfo(eIncaImprovement);
if(pkEntry != NULL && pkEntry->IsSpecificCivRequired())
{
CivilizationTypes eCiv = pkEntry->GetRequiredCivilization();
if(eCiv == pPlayer->getCivilizationType())
{
bIsInca = true;
}
}
}
}
int iRange = pPlayer ? pPlayer->getWorkPlotDistance() : 3;
for (int iDX = -iRange; iDX <= iRange; iDX++)
{
for (int iDY = -iRange; iDY <= iRange; iDY++)
{
CvPlot* pLoopPlot = plotXY(pPlot->getX(), pPlot->getY(), iDX, iDY);
if (pLoopPlot != NULL)
{
int iDistance = plotDistance(pPlot->getX(), pPlot->getY(), pLoopPlot->getX(), pLoopPlot->getY());
if (iDistance <= iRange)
{
int iRingModifier = m_iRingModifier[iDistance];
//not only our cities, also other player's cities!
int iExistingCityDistance = GC.getGame().GetClosestCityDistance(pLoopPlot);
//count the tile only if the city will be able to work it
if ( !pLoopPlot->isValidMovePlot(pPlayer->GetID()) || pLoopPlot->getWorkingCity()!=NULL || iExistingCityDistance<=2 )
iRingModifier = 0;
if (iExistingCityDistance==3)
//this plot will likely be contested between the two cities, reduce its value
iRingModifier /= 2;
int iPlotValue = iDefaultPlotValue;
if (iRingModifier>0)
{
int iFoodValue = 0;
int iHappinessValue = 0;
int iProductionValue = 0;
int iGoldValue = 0;
int iScienceValue = 0;
int iFaithValue = 0;
int iResourceValue = 0;
int iStrategicValue = 0;
if (eYield == NO_YIELD || eYield == YIELD_FOOD)
iFoodValue = ComputeFoodValue(pLoopPlot, pPlayer) * /*15*/ GC.getSETTLER_FOOD_MULTIPLIER();
if (eYield == NO_YIELD || eYield == YIELD_PRODUCTION)
iProductionValue = ComputeProductionValue(pLoopPlot, pPlayer) * /*3*/ GC.getSETTLER_PRODUCTION_MULTIPLIER();
if (eYield == NO_YIELD || eYield == YIELD_GOLD)
iGoldValue = ComputeGoldValue(pLoopPlot, pPlayer) * /*2*/ GC.getSETTLER_GOLD_MULTIPLIER();
if (eYield == NO_YIELD || eYield == YIELD_SCIENCE)
iScienceValue = ComputeScienceValue(pLoopPlot, pPlayer) * /*1*/ GC.getSETTLER_SCIENCE_MULTIPLIER();
if (eYield == NO_YIELD || eYield == YIELD_FAITH)
iFaithValue = ComputeFaithValue(pLoopPlot, pPlayer) * /*1*/ GC.getSETTLER_FAITH_MULTIPLIER();