本文整理汇总了C++中bwapi::UnitType::buildTime方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitType::buildTime方法的具体用法?C++ UnitType::buildTime怎么用?C++ UnitType::buildTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwapi::UnitType
的用法示例。
在下文中一共展示了UnitType::buildTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAllUnitCount
size_t UnitUtil::GetAllUnitCount(BWAPI::UnitType type)
{
size_t count = 0;
for (const auto & unit : BWAPI::Broodwar->self()->getUnits())
{
// trivial case: unit which exists matches the type
if (unit->getType() == type)
{
count++;
}
// case where a zerg egg contains the unit type
if (unit->getType() == BWAPI::UnitTypes::Zerg_Egg && unit->getBuildType() == type)
{
count += type.isTwoUnitsInOneEgg() ? 2 : 1;
}
// case where a building has started constructing a unit but it doesn't yet have a unit associated with it
if (unit->getRemainingTrainTime() > 0)
{
BWAPI::UnitType trainType = unit->getLastCommand().getUnitType();
if (trainType == type && unit->getRemainingTrainTime() == trainType.buildTime())
{
count++;
}
}
}
return count;
}
示例2: setShortName
// UnitType constructor
ActionTypeData::ActionTypeData(BWAPI::UnitType t, const ActionID id)
: type (UnitType)
, unit (t)
, raceID (GetRaceID(t.getRace()))
, actionID (id)
, mineralPriceVal (t.mineralPrice() * Constants::RESOURCE_SCALE)
, gasPriceVal (t.gasPrice() * Constants::RESOURCE_SCALE)
, supplyRequiredVal (t.supplyRequired())
, supplyProvidedVal (t.supplyProvided())
, buildTimeVal (t.buildTime())
, numberProduced (1)
, name (t.getName())
, metaName (t.getName())
, building (t.isBuilding())
, worker (t.isWorker())
, refinery (t.isRefinery())
, resourceDepot (t.isResourceDepot())
, supplyProvider (t.supplyProvided() > 0 && !t.isResourceDepot())
, canProduceBool (t.isBuilding() && t.canProduce())
, canAttackBool (t.canAttack())
, whatBuildsUnitType (t.whatBuilds().first)
, addon (t.isAddon())
, morphed (false)
, reqAddon (false)
, reqAddonID (0)
{
if (t == BWAPI::UnitTypes::Zerg_Zergling || t == BWAPI::UnitTypes::Zerg_Scourge)
{
numberProduced = 2;
}
if (t == BWAPI::UnitTypes::Zerg_Lair ||
t == BWAPI::UnitTypes::Zerg_Hive ||
t == BWAPI::UnitTypes::Zerg_Greater_Spire ||
t == BWAPI::UnitTypes::Zerg_Lurker ||
t == BWAPI::UnitTypes::Zerg_Guardian ||
t == BWAPI::UnitTypes::Zerg_Sunken_Colony ||
t == BWAPI::UnitTypes::Zerg_Spore_Colony)
{
morphed = true;
}
setShortName();
}
示例3: canPlanBuildOrderNow
// this will return true if any unit is on the first frame if it's training time remaining
// this can cause issues for the build order search system so don't plan a search on these frames
bool ProductionManager::canPlanBuildOrderNow() const
{
for (const auto & unit : BWAPI::Broodwar->self()->getUnits())
{
if (unit->getRemainingTrainTime() == 0)
{
continue;
}
BWAPI::UnitType trainType = unit->getLastCommand().getUnitType();
if (unit->getRemainingTrainTime() == trainType.buildTime())
{
return false;
}
}
return true;
}
示例4: mUnit
UnitClass::UnitClass(Position pos, BWAPI::UnitType type, int startTime)
: mUnit(NULL)
, mStoredPosition(pos)
, mStoredTargetPosition(pos)
, mStoredType(type)
, mStoredAccessType(AccessType::Prediction)
, mStoredPlayer(BWAPI::Broodwar->self())
, mStoredBoolOne(false)
, mStoredCompleted(false)
, mStoredMorphing(false)
, mStoredCompletedTime(startTime + type.buildTime())
, mStoredTime(BWAPI::Broodwar->getFrameCount())
, mStoredInt(0)
, mStoredExistsTime(startTime)
, mStoredHealth(0)
, mStoredShield(0)
, mLastOrderExecuteTime(0)
{
}
示例5: onUnitDiscover
void InformationManager::onUnitDiscover( BWAPI::Unit* unit )
{
// Sanity check
if ( unit == NULL )
{
return;
}
m_savedData[unit].m_exists = true;
// If this is an enemy unit, try to infer build time and start location, and base location
if ( BWAPI::Broodwar->self()->isEnemy( unit->getPlayer() ) )
{
int time = BWAPI::Broodwar->getFrameCount();
BWAPI::UnitType type = unit->getType();
updateBuildTime( type, time - type.buildTime() );
if ( m_scoutedAnEnemyBase == false && unit->getType().isBuilding() )
{
// We haven't scouted the enemy base yet, but this is a building
BWTA::Region* r = BWTA::getRegion( unit->getTilePosition() );
if ( r->getBaseLocations().size() == 1 )
{
// So the enemy probably spawned here.
BWTA::BaseLocation* b = *( r->getBaseLocations().begin() );
m_enemyBases.insert( b );
m_scoutedAnEnemyBase = true;
}
}
if ( unit->getType().isResourceDepot() )
{
// This is a center, so we know its a base location
BWTA::BaseLocation* b = BWTA::getNearestBaseLocation( unit->getTilePosition() );
m_enemyBases.insert( b );
m_enemyBaseCenters[b] = unit;
m_scoutedAnEnemyBase = true;
}
}
}