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


C++ CvPlot::getWorkingCity方法代码示例

本文整理汇总了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;
}
开发者ID:steemroller,项目名称:Community-Patch-DLL,代码行数:40,代码来源:CvArmyAI.cpp

示例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);
    }
}
开发者ID:gdambrauskas,项目名称:anewdawn1.74Hspinoff,代码行数:39,代码来源:CvGameObject.cpp

示例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();
开发者ID:Ninakoru,项目名称:Community-Patch-DLL,代码行数:67,代码来源:CvSiteEvaluationClasses.cpp


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