本文整理汇总了C++中MetaType::isUpgrade方法的典型用法代码示例。如果您正苦于以下问题:C++ MetaType::isUpgrade方法的具体用法?C++ MetaType::isUpgrade怎么用?C++ MetaType::isUpgrade使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetaType
的用法示例。
在下文中一共展示了MetaType::isUpgrade方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canMakeNow
bool ProductionManager::canMakeNow(BWAPI::Unit producer, MetaType t)
{
//UAB_ASSERT(producer != nullptr, "Producer was null");
bool canMake = meetsReservedResources(t);
if (canMake)
{
if (t.isUnit())
{
canMake = BWAPI::Broodwar->canMake(t.getUnitType(), producer);
}
else if (t.isTech())
{
canMake = BWAPI::Broodwar->canResearch(t.getTechType(), producer);
}
else if (t.isUpgrade())
{
canMake = BWAPI::Broodwar->canUpgrade(t.getUpgradeType(), producer);
}
else
{
UAB_ASSERT(false, "Unknown type");
}
}
return canMake;
}
示例2: create
// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item)
{
if (!producer)
{
return;
}
MetaType t = item.metaType;
// if we're dealing with a building
if (t.isUnit() && t.getUnitType().isBuilding()
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
&& !t.getUnitType().isAddon())
{
// send the building task to the building manager
if (t.getUnitType() == BWAPI::UnitTypes::Terran_Bunker)
{
BWAPI::TilePosition tp = BWAPI::TilePosition(BWTA::getNearestChokepoint(BWAPI::Position(BWAPI::Broodwar->self()->getStartLocation()))->getCenter());
BuildingManager::Instance().addBuildingTask(t.getUnitType(), tp, item.isGasSteal);
}
else {
BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
}
}
else if (t.getUnitType().isAddon())
{
//BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
producer->buildAddon(t.getUnitType());
}
// if we're dealing with a non-building unit
else if (t.isUnit())
{
// if the race is zerg, morph the unit
if (t.getUnitType().getRace() == BWAPI::Races::Zerg)
{
producer->morph(t.getUnitType());
// if not, train the unit
}
else
{
producer->train(t.getUnitType());
}
}
// if we're dealing with a tech research
else if (t.isTech())
{
producer->research(t.getTechType());
}
else if (t.isUpgrade())
{
//Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
producer->upgrade(t.getUpgradeType());
}
else
{
}
}
示例3: canMakeNow
bool ProductionManager::canMakeNow(BWAPI::Unit producer, MetaType t)
{
//UAB_ASSERT(producer != nullptr, "Producer was null");
bool canMake = meetsReservedResources(t);
if (canMake)
{
if (t.isUnit())
{
canMake = BWAPI::Broodwar->canMake(t.getUnitType(), producer);
}
else if (t.isTech())
{
canMake = BWAPI::Broodwar->canResearch(t.getTechType(), producer);
}
else if (t.isUpgrade())
{
if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Carapace)
{
BWAPI::Broodwar->printf("Trying to create carapace with %d %d EVO CHAMBER\n", producer->getTilePosition().x, producer->getTilePosition().y);
}
else if ((t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Missile_Attacks))
{
BWAPI::Broodwar->printf("Trying to create misisle attacks with %d %d EVO CHAMBER\n", producer->getTilePosition().x, producer->getTilePosition().y);
}
canMake = BWAPI::Broodwar->canUpgrade(t.getUpgradeType(), producer);
}
else
{
UAB_ASSERT(false, "Unknown type");
}
}
return canMake;
}
示例4: createMetaType
// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::createMetaType(BWAPI::UnitInterface* producer, MetaType t)
{
if (!producer)
{
return;
}
// if we're dealing with a building
if (t.isUnit() && t.unitType.isBuilding()
&& t.unitType != BWAPI::UnitTypes::Zerg_Lair
&& t.unitType != BWAPI::UnitTypes::Zerg_Hive
&& t.unitType != BWAPI::UnitTypes::Zerg_Greater_Spire
&& !t.unitType.isAddon())
{
// send the building task to the building manager
BuildingManager::Instance().addBuildingTask(t.unitType, BWAPI::Broodwar->self()->getStartLocation());
}
else if (t.unitType.isAddon())
{
BWAPI::Broodwar->printf("Building Addon");
//BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
producer->buildAddon(t.unitType);
}
// if we're dealing with a non-building unit
else if (t.isUnit())
{
// if the race is zerg, morph the unit
if (t.unitType.getRace() == BWAPI::Races::Zerg)
{
producer->morph(t.unitType);
// if not, train the unit
}
else
{
producer->train(t.unitType);
}
}
// if we're dealing with a tech research
else if (t.isTech())
{
producer->research(t.techType);
}
else if (t.isUpgrade())
{
//Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
producer->upgrade(t.upgradeType);
}
else
{
}
}
示例5: GetActionType
BOSS::ActionType BOSSManager::GetActionType(const MetaType & t)
{
// set the appropriate type
if (t.isUnit())
{
return BOSS::ActionType(t.getUnitType());
}
else if (t.isUpgrade())
{
return BOSS::ActionType(t.getUpgradeType());
}
else if (t.isTech())
{
return BOSS::ActionType(t.getTechType());
}
else
{
UAB_ASSERT(false, "Should have found a valid type here");
}
return BOSS::ActionType();
}
示例6: create
// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item)
{
if (!producer)
{
return;
}
MetaType t = item.metaType;
// if we're dealing with a building
if (t.isUnit() && t.getUnitType().isBuilding()
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Sunken_Colony
&& !t.getUnitType().isAddon())
{
// send the building task to the building manager
BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
}
else if (t.getUnitType().isAddon())
{
//BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
producer->buildAddon(t.getUnitType());
}
// if we're dealing with a non-building unit
else if (t.isUnit())
{
// if the race is zerg, morph the unit
if (t.getUnitType().getRace() == BWAPI::Races::Zerg)
{
producer->morph(t.getUnitType());
if (t.getUnitType() == BWAPI::UnitTypes::Zerg_Overlord)
{
_overlordTimer = BWAPI::Broodwar->getFrameCount() + t.getUnitType().buildTime() + 35;
}
// if not, train the unit
}
else
{
producer->train(t.getUnitType());
}
}
// if we're dealing with a tech research
else if (t.isTech())
{
producer->research(t.getTechType());
}
else if (t.isUpgrade())
{
//Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
if (t.getUpgradeType() == BWAPI::UpgradeTypes::Muscular_Augments)
{
muscBuildTimer = BWAPI::Broodwar->getFrameCount() + t.getUpgradeType().upgradeTime();
muscBuild = true;
}
producer->upgrade(t.getUpgradeType());
}
else
{
}
}
示例7: create
// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item)
{
if (!producer)
{
return;
}
MetaType t = item.metaType;
// if we're dealing with a building
if (t.isUnit() && t.getUnitType().isBuilding()
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Sunken_Colony
&& !t.getUnitType().isAddon())
{
// send the building task to the building manager
BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
}
else if (t.getUnitType().isAddon())
{
//BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
producer->buildAddon(t.getUnitType());
}
// if we're dealing with a non-building unit
else if (t.isUnit())
{
// if the race is zerg, morph the unit
if (t.getUnitType().getRace() == BWAPI::Races::Zerg)
{
if (t.getUnitType() == BWAPI::UnitTypes::Zerg_Overlord)
{
overlordBuildTimer = BWAPI::Broodwar->getFrameCount() + t.getUnitType().buildTime();
canOverlord = true;
}
producer->morph(t.getUnitType());
// if not, train the unit
}
else
{
producer->train(t.getUnitType());
}
}
// if we're dealing with a tech research
else if (t.isTech())
{
producer->research(t.getTechType());
}
else if (t.isUpgrade())
{
if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Carapace)
{
BWAPI::Broodwar->printf("Got a request for carapace upgrade using producer x %d y %d: \n", producer->getTilePosition().x, producer->getTilePosition().y);
}
else if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Missile_Attacks)
{
BWAPI::Broodwar->printf("Got a request for missile attacks upgrade using producer x %d y %d : \n", producer->getTilePosition().x, producer->getTilePosition().y);
}
producer = getEvolutionChamberProducer(producer, t);
//BWAPI::Broodwar->printf("Got request for capace or missile attacks with producer type : x : %d y: %d\n", producer->getTilePosition().x, producer->getTilePosition().y);
//}
//Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
producer->upgrade(t.getUpgradeType());
upgradingStuff.insert(producer);
}
else
{
}
}