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


C++ UnitBase::deploy方法代码示例

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


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

示例1: destroy

void UnitBase::destroy() {

	setTarget(NULL);
	currentGameMap->removeObjectFromMap(getObjectID());	//no map point will reference now
	currentGame->getObjectManager().removeObject(objectID);

	currentGame->getHouse(originalHouseID)->decrementUnits(itemID);

	unitList.remove(this);

    if(isVisible()) {
        if(currentGame->randomGen.rand(1,100) <= getInfSpawnProp()) {
            UnitBase* pNewUnit = currentGame->getHouse(originalHouseID)->createUnit(Unit_Soldier);
            pNewUnit->setHealth(pNewUnit->getMaxHealth()/2);
            pNewUnit->deploy(location);

            if(owner->getHouseID() != originalHouseID) {
                // deviation is inherited
                pNewUnit->owner = owner;
                pNewUnit->graphic = pGFXManager->getObjPic(pNewUnit->graphicID,owner->getHouseID());
                pNewUnit->deviationTimer = deviationTimer;
            }
        }
    }

	delete this;
}
开发者ID:katlogic,项目名称:dunelegacy,代码行数:27,代码来源:UnitBase.cpp

示例2: triggerSpecialBloom

void Tile::triggerSpecialBloom(House* pTrigger) {
    if(isSpecialBloom()) {
        setType(Terrain_Sand);

        switch(currentGame->randomGen.rand(0,3)) {
        case 0: {
            // the player gets an randomly choosen amount of credits between 150 and 400
            pTrigger->addCredits(currentGame->randomGen.rand(150, 400),false);
        }
        break;

        case 1: {
            // The house gets a Trike for free. It spawns beside the special bloom.
            UnitBase* pNewUnit = pTrigger->createUnit(Unit_Trike);
            if(pNewUnit != NULL) {
                Coord spot = currentGameMap->findDeploySpot(pNewUnit, location);
                pNewUnit->deploy(spot);
            }
        }
        break;

        case 2: {
            // One of the AI players on the map (one that has at least one unit) gets a Trike for free. It spawns beside the special bloom.
            int numCandidates = 0;
            for(int i=0; i<NUM_HOUSES; i++) {
                House* pHouse = currentGame->getHouse(i);
                if(pHouse != NULL && pHouse->getTeam() != pTrigger->getTeam() && pHouse->getNumUnits() > 0) {
                    numCandidates++;
                }
            }

            if(numCandidates == 0) {
                break;
            }

            House* pEnemyHouse = NULL;
            for(int i=0; i<NUM_HOUSES; i++) {
                House* pHouse = currentGame->getHouse(i);
                if(pHouse != NULL && pHouse->getTeam() != pTrigger->getTeam() && pHouse->getNumUnits() > 0) {
                    numCandidates--;
                    if(numCandidates == 0) {
                        pEnemyHouse = pHouse;
                        break;
                    }
                }
            }

            UnitBase* pNewUnit = pEnemyHouse->createUnit(Unit_Trike);
            if(pNewUnit != NULL) {
                Coord spot = currentGameMap->findDeploySpot(pNewUnit, location);
                pNewUnit->deploy(spot);
            }

        }
        break;

        case 3:
        default: {
            // One of the AI players on the map (one that has at least one unit) gets an Infantry unit (3 Soldiers) for free. The spawn beside the special bloom.
            int numCandidates = 0;
            for(int i=0; i<NUM_HOUSES; i++) {
                House* pHouse = currentGame->getHouse(i);
                if(pHouse != NULL && pHouse->getTeam() != pTrigger->getTeam() && pHouse->getNumUnits() > 0) {
                    numCandidates++;
                }
            }

            if(numCandidates == 0) {
                break;
            }

            House* pEnemyHouse = NULL;
            for(int i=0; i<NUM_HOUSES; i++) {
                House* pHouse = currentGame->getHouse(i);
                if(pHouse != NULL && pHouse->getTeam() != pTrigger->getTeam() && pHouse->getNumUnits() > 0) {
                    numCandidates--;
                    if(numCandidates == 0) {
                        pEnemyHouse = pHouse;
                        break;
                    }
                }
            }

            for(int i=0; i<3; i++) {
                UnitBase* pNewUnit = pEnemyHouse->createUnit(Unit_Soldier);
                if(pNewUnit != NULL) {
                    Coord spot = currentGameMap->findDeploySpot(pNewUnit, location);
                    pNewUnit->deploy(spot);
                }
            }
        }
        break;
        }
    }
}
开发者ID:binarycrusader,项目名称:dunelegacy,代码行数:95,代码来源:Tile.cpp


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