本文整理汇总了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;
}
示例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;
}
}
}