本文整理汇总了C++中bwapi::UnitType::size方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitType::size方法的具体用法?C++ UnitType::size怎么用?C++ UnitType::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwapi::UnitType
的用法示例。
在下文中一共展示了UnitType::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCounters
Composition getCounters(BWAPI::UnitType enemyUnitType)
{
auto allUnitTypes = BWAPI::UnitTypes::allUnitTypes();
std::unordered_map<BWAPI::UnitType, int> unitTypeCounterAmount; //LF new name pls
auto groundDamageType = enemyUnitType.groundWeapon().damageType();
auto airDamageType = enemyUnitType.airWeapon().damageType();
auto sizeType = enemyUnitType.size();
bool flyer = enemyUnitType.isFlyer();
for each (auto unitType in allUnitTypes)
{
if (unitType.getRace() != util::game::getSelf()->getRace() || unitType.isHero() || unitType.isBuilding() || unitType.isWorker())
continue;
//if enemy unit flies and friendly unit can damage it...
if (flyer)
{
if (unitType.airWeapon().damageAmount() > 0)
{
unitTypeCounterAmount[unitType]++;
//if friendly unit flies and enemy unit can't damage it...
if (!(enemyUnitType.airWeapon().damageAmount() > 0))
unitTypeCounterAmount[unitType]++;
//if enemy unit damage type is concussive and friendly unit size is small...
if (airDamageType == BWAPI::DamageTypes::Concussive && unitType.size() == BWAPI::UnitSizeTypes::Small)
unitTypeCounterAmount[unitType]++;
//if enemy unit damage type is explosive and friendly unit size is large...
else if (airDamageType == BWAPI::DamageTypes::Explosive && unitType.size() == BWAPI::UnitSizeTypes::Large)
unitTypeCounterAmount[unitType]++;
//if enemy unit size is small and friendly damage type is explosive...
if (sizeType == BWAPI::UnitSizeTypes::Small && unitType.airWeapon().damageType() == BWAPI::DamageTypes::Explosive)
unitTypeCounterAmount[unitType]++;
//if enemy unit size is medium or large and friendly damage type is concussive...
else if ((sizeType == BWAPI::UnitSizeTypes::Medium || sizeType == BWAPI::UnitSizeTypes::Large) && unitType.airWeapon().damageType() == BWAPI::DamageTypes::Concussive)
unitTypeCounterAmount[unitType]++;
}
else
continue;
}
//if enemy unit is ground unit and friendly unit can damage it...
if (!flyer && unitType.groundWeapon().damageAmount() > 0)
{
unitTypeCounterAmount[unitType]++;
//if friendly unit flies and enemy unit can't damage it...
if (unitType.isFlyer() && !(enemyUnitType.airWeapon().damageAmount() > 0))
unitTypeCounterAmount[unitType]++;
//if enemy unit damage type is concussive and friendly unit size is small...
if (groundDamageType == BWAPI::DamageTypes::Concussive && unitType.size() == BWAPI::UnitSizeTypes::Small)
unitTypeCounterAmount[unitType]++;
//if enemy unit damage type is explosive and friendly unit size is large...
else if (groundDamageType == BWAPI::DamageTypes::Explosive && unitType.size() == BWAPI::UnitSizeTypes::Large)
unitTypeCounterAmount[unitType]++;
//if enemy unit size is small and friendly damage type is explosive...
if (sizeType == BWAPI::UnitSizeTypes::Small && unitType.groundWeapon().damageType() == BWAPI::DamageTypes::Explosive)
unitTypeCounterAmount[unitType]++;
//if enemy unit size is medium or large and friendly damage type is concussive...
else if ((sizeType == BWAPI::UnitSizeTypes::Medium || sizeType == BWAPI::UnitSizeTypes::Large) && unitType.groundWeapon().damageType() == BWAPI::DamageTypes::Concussive)
unitTypeCounterAmount[unitType]++;
}
else
continue;
}
Composition counterComposition;
for (auto &unitType = unitTypeCounterAmount.begin(); unitType != unitTypeCounterAmount.end(); unitType++)
{
if (unitType->first == BWAPI::UnitTypes::Spell_Scanner_Sweep)
counterComposition.addType(BWAPI::UnitTypes::Terran_Comsat_Station, unitType->second);
else if (unitType->first == BWAPI::UnitTypes::Terran_Siege_Tank_Siege_Mode)
counterComposition.addType(BWAPI::UnitTypes::Terran_Siege_Tank_Tank_Mode, unitType->second);
else if(unitType->first == BWAPI::UnitTypes::Terran_Vulture_Spider_Mine)
counterComposition.addType(BWAPI::UnitTypes::Terran_Vulture, unitType->second);
else
counterComposition.addType(unitType->first, unitType->second);
}
return counterComposition;
}