本文整理汇总了C++中CvCity::getGameObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CvCity::getGameObject方法的具体用法?C++ CvCity::getGameObject怎么用?C++ CvCity::getGameObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CvCity
的用法示例。
在下文中一共展示了CvCity::getGameObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
void CvGameObjectPlayer::foreach(GameObjectTypes eType, boost::function<void (CvGameObject*)> func)
{
int iLoop;
switch(eType)
{
case GAMEOBJECT_GAME:
func(GC.getGameINLINE().getGameObject());
break;
case GAMEOBJECT_TEAM:
func(GET_TEAM(m_pPlayer->getTeam()).getGameObject());
break;
case GAMEOBJECT_CITY:
for (CvCity* pCity = m_pPlayer->firstCity(&iLoop); pCity != NULL; pCity = m_pPlayer->nextCity(&iLoop))
{
func(pCity->getGameObject());
}
break;
case GAMEOBJECT_UNIT:
for (CvUnit* pUnit = m_pPlayer->firstUnit(&iLoop); pUnit != NULL; pUnit = m_pPlayer->nextUnit(&iLoop))
{
func(pUnit->getGameObject());
}
break;
case GAMEOBJECT_PLOT:
for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{
CvPlot* pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
if (pLoopPlot->getOwnerINLINE() == m_pPlayer->getID())
{
func(pLoopPlot->getGameObject());
}
}
break;
case GAMEOBJECT_PLAYER:
func(this);
break;
}
}
示例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);
}
}