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


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

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


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

示例1: foreachNear

void CvGameObjectPlot::foreachNear(GameObjectTypes eType, boost::function<void(CvGameObject *)> func, int iDistance)
{
    int iPlotX = m_pPlot->getX_INLINE();
    int iPlotY = m_pPlot->getY_INLINE();

    for (int iX=iPlotX - iDistance; iX <= iPlotX + iDistance; iX++)
    {
        for (int iY=iPlotY - iDistance; iY <= iPlotY + iDistance; iY++)
        {
            CvPlot* pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
            if (pPlot)
                pPlot->getGameObject()->foreachOn(eType, func);
        }
    }
}
开发者ID:gdambrauskas,项目名称:anewdawn1.74Hspinoff,代码行数:15,代码来源:CvGameObject.cpp

示例2: foreach

void CvGameObjectTeam::foreach(GameObjectTypes eType, boost::function<void (CvGameObject*)> func)
{
    switch(eType)
    {
    case GAMEOBJECT_GAME:
        func(GC.getGameINLINE().getGameObject());
        break;

    case GAMEOBJECT_PLAYER:
        for (int iPlayer = 0; iPlayer < MAX_CIV_PLAYERS; ++iPlayer)
        {
            CvPlayer& kLoopPlayer = GET_PLAYER((PlayerTypes)iPlayer);
            if (kLoopPlayer.isAlive())
            {
                if (kLoopPlayer.getTeam() == m_pTeam->getID())
                {
                    func((CvGameObject*)&CvGameObjectPlayer(&kLoopPlayer));
                }
            }
        }
        break;

    case GAMEOBJECT_CITY:
        foreach(GAMEOBJECT_PLAYER, boost::bind(callForeach, _1, GAMEOBJECT_CITY, func));
        break;

    case GAMEOBJECT_UNIT:
        foreach(GAMEOBJECT_PLAYER, boost::bind(callForeach, _1, GAMEOBJECT_UNIT, func));
        break;

    case GAMEOBJECT_PLOT:
        for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
        {
            CvPlot* pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
            if (pLoopPlot->getTeam() == m_pTeam->getID())
            {
                func(pLoopPlot->getGameObject());
            }
        }
        break;

    case GAMEOBJECT_TEAM:
        func(this);
        break;
    }
}
开发者ID:gdambrauskas,项目名称:anewdawn1.74Hspinoff,代码行数:46,代码来源:CvGameObject.cpp

示例3: 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


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