本文整理汇总了C++中bwapi::UnitType类的典型用法代码示例。如果您正苦于以下问题:C++ UnitType类的具体用法?C++ UnitType怎么用?C++ UnitType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnitType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Cdingram,项目名称:GGEZ-Bot,代码行数:31,代码来源:UnitUtil.cpp
示例2: build
void UnitClass::build(TilePosition target, BWAPI::UnitType type)
{
if(exists())
{
const Position targetPosition(target.x()*32+type.tileWidth()*16, target.y()*32+type.tileHeight()*16);
if(getDistance(type, targetPosition) > 48 || !MapHelper::isAllVisible(target, type))
{
move(targetPosition, 0);
return;
}
if(mUnit->getOrder() == BWAPI::Orders::PlaceBuilding)
{
if(mUnit->getBuildType() == type && mUnit->getOrderTargetPosition() == targetPosition)
return;
}
if(mUnit->getLastCommand().getType() == BWAPI::UnitCommandTypes::Build && mUnit->getLastCommand().getUnitType() == type && mUnit->getLastCommand().getTargetTilePosition() == target)
{
if(mLastOrderExecuteTime >= BWAPI::Broodwar->getFrameCount())
return;
}
if(mUnit->build(target, type))
mLastOrderExecuteTime = BWAPI::Broodwar->getFrameCount() + BWAPI::Broodwar->getRemainingLatencyFrames();
else
move(targetPosition, 0);
}
}
开发者ID:SPQRBrutus,项目名称:skynetbot,代码行数:29,代码来源:Unit.cpp
示例3: checkSupportedUnitType
void checkSupportedUnitType(const BWAPI::UnitType & type)
{
if (type == BWAPI::UnitTypes::None || type == BWAPI::UnitTypes::Unknown)
{
System::FatalError("Unknown unit type in experiment file");
}
if (type == BWAPI::UnitTypes::Protoss_Corsair ||
type == BWAPI::UnitTypes::Zerg_Devourer ||
type == BWAPI::UnitTypes::Zerg_Scourge ||
type == BWAPI::UnitTypes::Terran_Valkyrie)
{
System::FatalError("Units with just air weapons currently not supported correctly: " + type.getName());
}
if (type.isBuilding() && (type != BWAPI::UnitTypes::Protoss_Photon_Cannon || type != BWAPI::UnitTypes::Zerg_Sunken_Colony || type != BWAPI::UnitTypes::Terran_Missile_Turret))
{
System::FatalError("Non-attacking buildings not currently supported: " + type.getName());
}
if (type.isSpellcaster())
{
System::FatalError("Spell casting units not currently supported: " + type.getName());
}
}
开发者ID:carriercomm,项目名称:sparcraft-clustering,代码行数:25,代码来源:Common.cpp
示例4: getAttackPriority
// get the attack priority of a type in relation to a zergling
int RangedManager::getAttackPriority(BWAPI::UnitInterface* rangedUnit, BWAPI::UnitInterface* target)
{
BWAPI::UnitType rangedUnitType = rangedUnit->getType();
BWAPI::UnitType targetType = target->getType();
bool canAttackUs = rangedUnitType.isFlyer() ? targetType.airWeapon() != BWAPI::WeaponTypes::None : targetType.groundWeapon() != BWAPI::WeaponTypes::None;
// highest priority is something that can attack us or aid in combat
if (targetType == BWAPI::UnitTypes::Terran_Medic || canAttackUs ||
targetType == BWAPI::UnitTypes::Terran_Bunker)
{
return 3;
}
// next priority is worker
else if (targetType.isWorker())
{
return 2;
}
// then everything else
else
{
return 1;
}
}
开发者ID:nateheat,项目名称:ualbertabot,代码行数:27,代码来源:RangedManager.cpp
示例5: hasResources
bool BuildOrderManager::hasResources(BWAPI::UnitType t)
{
if (BWAPI::Broodwar->self()->cumulativeMinerals()-this->usedMinerals<t.mineralPrice())
return false;
if (BWAPI::Broodwar->self()->cumulativeGas()-this->usedGas<t.gasPrice())
return false;
return true;
}
开发者ID:calebthompson,项目名称:School,代码行数:8,代码来源:BuildOrderManager.cpp
示例6:
void sim::UnitProps::SetType(BWAPI::UnitType type)
{
this->type = type;
maxEnergy[0] = maxEnergy[1] = type.maxEnergy();
sightRange[0] = sightRange[1] = type.sightRange() << pixelShift;
extraArmor[0] = extraArmor[1] = 0;
speed[0] = speed[1] = static_cast<int>((1 << pixelShift) * type.topSpeed());
}
开发者ID:welwa,项目名称:ualbertabot,代码行数:8,代码来源:SpecProps.cpp
示例7: hasResources
bool BuildOrderManager::hasResources(BWAPI::UnitType t, int time)
{
pair<int, Resources> res;
res.first=time;
res.second.minerals=t.mineralPrice();
res.second.gas=t.gasPrice();
bool ret=hasResources(res);
return ret;
}
开发者ID:aragar,项目名称:MordinTheBot,代码行数:9,代码来源:BuildOrderManager.cpp
示例8: onSendText
void UAlbertaBotModule::onSendText(std::string text)
{
if (Config::Modules::UsingBuildOrderDemo)
{
std::stringstream type;
std::stringstream numUnitType;
size_t numUnits = 0;
size_t i=0;
for (i=0; i<text.length(); ++i)
{
if (text[i] == ' ')
{
i++;
break;
}
type << text[i];
}
for (; i<text.length(); ++i)
{
numUnitType << text[i];
}
numUnits = atoi(numUnitType.str().c_str());
BWAPI::UnitType t;
for (const BWAPI::UnitType & tt : BWAPI::UnitTypes::allUnitTypes())
{
if (tt.getName().compare(type.str()) == 0)
{
t = tt;
break;
}
}
BWAPI::Broodwar->printf("Searching for %d of %s", numUnits, t.getName().c_str());
if (t != BWAPI::UnitType())
{
MetaPairVector goal;
goal.push_back(MetaPair(BWAPI::UnitTypes::Protoss_Probe, 8));
goal.push_back(MetaPair(BWAPI::UnitTypes::Protoss_Gateway, 2));
goal.push_back(MetaPair(t, numUnits));
ProductionManager::Instance().setSearchGoal(goal);
}
else
{
BWAPI::Broodwar->printf("Unknown unit type %s", type.str().c_str());
}
}
}
开发者ID:nateheat,项目名称:ualbertabot,代码行数:56,代码来源:UAlbertaBotModule.cpp
示例9: canBuildHere
bool BuildingPlacer::canBuildHere(BWAPI::TilePosition position, BWAPI::UnitType type) const
{
if (!BWAPI::Broodwar->canBuildHere(NULL, position, type))
return false;
for(int x = position.x(); x < position.x() + type.tileWidth(); x++)
for(int y = position.y(); y < position.y() + type.tileHeight(); y++)
if (reserveMap[x][y])
return false;
return true;
}
开发者ID:calebthompson,项目名称:School,代码行数:10,代码来源:BuildingPlacer.cpp
示例10: addBuildingTask
// add a new building to be constructed
void BuildingManager::addBuildingTask(BWAPI::UnitType type, BWAPI::TilePosition desiredLocation, bool isGasSteal)
{
_reservedMinerals += type.mineralPrice();
_reservedGas += type.gasPrice();
Building b(type, desiredLocation);
b.isGasSteal = isGasSteal;
b.status = BuildingStatus::Unassigned;
_buildings.push_back(b);
}
开发者ID:0x4849,项目名称:c350,代码行数:12,代码来源:BuildingManagergggg.cpp
示例11: drawCommandStatus
void UnitCommandManager::drawCommandStatus(BWAPI::UnitInterface* unit)
{
BWAPI::UnitType type = unit->getType();
int width = type.dimensionRight();
int height = type.dimensionDown()/6;
int x1 = unit->getPosition().x - width;
int x2 = unit->getPosition().y + width;
int y1 = unit->getPosition().y - height;
int y2 = unit->getPosition().y + height;
}
开发者ID:DantesGearbox,项目名称:ualbertabot,代码行数:11,代码来源:UnitCommandManager.cpp
示例12: buildAdditional
void BuildOrderManager::buildAdditional(int count, BWAPI::UnitType t, int priority, BWAPI::TilePosition seedPosition)
{
if (t == BWAPI::UnitTypes::None || t == BWAPI::UnitTypes::Unknown) return;
if (seedPosition == BWAPI::TilePositions::None || seedPosition == BWAPI::TilePositions::Unknown)
seedPosition=BWAPI::Broodwar->self()->getStartLocation();
if (items[priority].units[t.whatBuilds().first].find(t)==items[priority].units[t.whatBuilds().first].end())
items[priority].units[t.whatBuilds().first].insert(make_pair(t,UnitItem(t)));
items[priority].units[t.whatBuilds().first][t].addAdditional(count,seedPosition);
nextUpdateFrame=0;
}
开发者ID:aragar,项目名称:MordinTheBot,代码行数:11,代码来源:BuildOrderManager.cpp
示例13: canBuildHere
bool BuildingPlacer::canBuildHere(BWAPI::TilePosition position, BWAPI::UnitType type) const
{
//returns true if we can build this type of unit here. Takes into account reserved tiles.
if (!BWAPI::Broodwar->canBuildHere(NULL, position, type))
return false;
for(int x = position.x(); x < position.x() + type.tileWidth(); x++)
for(int y = position.y(); y < position.y() + type.tileHeight(); y++)
if (reserveMap[x][y])
return false;
return true;
}
开发者ID:andertavares,项目名称:MegaBot,代码行数:11,代码来源:BuildingPlacer.cpp
示例14: TireBaseBuilding
//----------------------------------------------------------------------------------------------
EntityClassType StarCraftTechTree::TireBaseBuilding(BaseType p_tireId) const
{
BWAPI::UnitType baseType;
if (p_tireId == BASETYPE_END)
return ECLASS_END;
baseType = m_player->getRace().getCenter();
return g_Database.EntityMapping.GetByFirst(baseType.getID());
}
开发者ID:amrElroumy,项目名称:IStrategizer,代码行数:12,代码来源:StarCraftTechTree.cpp
示例15: canBuildHereWithSpace
bool BuildingPlacer::canBuildHereWithSpace(BWAPI::TilePosition position, BWAPI::UnitType type) const
{
if (!this->canBuildHere(position, type))
return false;
int width=type.tileWidth();
int height=type.tileHeight();
if (type==BWAPI::UnitTypes::Terran_Command_Center ||
type==BWAPI::UnitTypes::Terran_Factory ||
type==BWAPI::UnitTypes::Terran_Starport ||
type==BWAPI::UnitTypes::Terran_Science_Facility)
{
width+=2;
}
int startx = position.x() - buildDistance;
if (startx<0) startx=0;
int starty = position.y() - buildDistance;
if (starty<0) starty=0;
int endx = position.x() + width + buildDistance;
if (endx>BWAPI::Broodwar->mapWidth()) endx=BWAPI::Broodwar->mapWidth();
int endy = position.y() + height + buildDistance;
if (endy>BWAPI::Broodwar->mapHeight()) endy=BWAPI::Broodwar->mapHeight();
for(int x = startx; x < endx; x++)
for(int y = starty; y < endy; y++)
if (!type.isRefinery())
if (!buildable(x, y))
return false;
if (position.x()>3)
{
int startx2=startx-2;
if (startx2<0) startx2=0;
for(int x = startx2; x < startx; x++)
for(int y = starty; y < endy; y++)
{
std::set<BWAPI::Unit*> units = BWAPI::Broodwar->unitsOnTile(x, y);
for(std::set<BWAPI::Unit*>::iterator i = units.begin(); i != units.end(); i++)
{
if (!(*i)->isLifted())
{
BWAPI::UnitType type=(*i)->getType();
if (type==BWAPI::UnitTypes::Terran_Command_Center ||
type==BWAPI::UnitTypes::Terran_Factory ||
type==BWAPI::UnitTypes::Terran_Starport ||
type==BWAPI::UnitTypes::Terran_Science_Facility)
{
return false;
}
}
}
}
}
return true;
}
开发者ID:calebthompson,项目名称:School,代码行数:54,代码来源:BuildingPlacer.cpp
示例16: producer
CancelTrainTest::CancelTrainTest(BWAPI::UnitType unitType1, BWAPI::UnitType unitType2, BWAPI::UnitType unitType3)
: unitType1(unitType1),
unitType2(unitType2),
unitType3(unitType3),
producer(NULL),
startFrame(-1),
nextFrame(-1)
{
fail = false;
running = false;
producerType = unitType1.whatBuilds().first;
BWAssertF(producerType==unitType2.whatBuilds().first,{fail=true;return;});
开发者ID:oenayet,项目名称:bwapi,代码行数:12,代码来源:CancelTrainTest.cpp
示例17: addBuildingTask
// add a new building to be constructed
void BuildingManager::addBuildingTask(BWAPI::UnitType type, BWAPI::TilePosition desiredLocation) {
if (debugMode) { BWAPI::Broodwar->printf("Issuing addBuildingTask: %s", type.getName().c_str()); }
totalBuildTasks++;
// reserve the resources for this building
reservedMinerals += type.mineralPrice();
reservedGas += type.gasPrice();
// set it up to receive a worker
buildingData.addBuilding(ConstructionData::Unassigned, Building(type, desiredLocation));
}
开发者ID:NotABotBot,项目名称:ualbertabot,代码行数:14,代码来源:BuildingManager.cpp
示例18: unitProducesGround
bool UnitHelper::unitProducesGround(BWAPI::UnitType type)
{
static std::set<BWAPI::UnitType> unitData;
if(unitData.empty())
{
for each(BWAPI::UnitType type in BWAPI::UnitTypes::allUnitTypes())
{
if(!type.isFlyer() && type.whatBuilds().first.isBuilding())
unitData.insert(type.whatBuilds().first);
}
}
return unitData.count(type) != 0;
}
开发者ID:SPQRBrutus,项目名称:skynetbot,代码行数:14,代码来源:UnitHelper.cpp
示例19: getAttackPriority
/// Returns target attack priority.
/// Returned value must be greater than 0
int VultureManagerExt::getAttackPriority(BWAPI::Unit * selectedUnit, BWAPI::Unit * target)
{
BWAPI::UnitType selectedUnitType = selectedUnit->getType();
BWAPI::UnitType targetType = target->getType();
bool canAttackUs = targetType.groundWeapon() != BWAPI::WeaponTypes::None;
int selectedUnitWeaponRange = selectedUnitType.groundWeapon().maxRange(); // 160, Concussive
int targetWeaponRange = targetType.groundWeapon().maxRange();
// Larvas are low priority targets
if (targetType == BWAPI::UnitTypes::Zerg_Larva
|| targetType == BWAPI::UnitTypes::Protoss_Interceptor)
{
return 1;
}
else if (targetType == BWAPI::UnitTypes::Protoss_Pylon)
{
return 3;
}
else if ((targetType.isBuilding()) && !(targetType.canAttack()))
{
return 2;
}
else if (targetType == BWAPI::UnitTypes::Protoss_Photon_Cannon)
{
return 4;
}
// Templars are extremely dangerous to bio units and should be eliminated asap.
else if (targetType == BWAPI::UnitTypes::Protoss_High_Templar
|| targetType == BWAPI::UnitTypes::Terran_Medic)
{
return selectedUnitWeaponRange + 10;
}
// Faster than Marine (without Stimpack)
else if ((targetType.topSpeed() >= selectedUnitType.topSpeed())
|| ((targetType == BWAPI::UnitTypes::Protoss_Zealot)
&& (BWAPI::Broodwar->enemy()->getUpgradeLevel(BWAPI::UpgradeTypes::Leg_Enhancements) > 0)))
{
return selectedUnitWeaponRange; // return 160
}
// Slower than Vulture
else
{
int priority = selectedUnitWeaponRange - targetWeaponRange;
if (priority <= 0)
{
priority = 1;
}
return priority;
}
}
开发者ID:filipbober,项目名称:scaiCode,代码行数:56,代码来源:VultureManagerExt.cpp
示例20: drawProductionInformation
void ProductionManager::drawProductionInformation(int x, int y)
{
if (!Config::Debug::DrawProductionInfo)
{
return;
}
// fill prod with each unit which is under construction
std::vector<BWAPI::Unit> prod;
for (auto & unit : BWAPI::Broodwar->self()->getUnits())
{
UAB_ASSERT(unit != nullptr, "Unit was null");
if (unit->isBeingConstructed())
{
prod.push_back(unit);
}
}
// sort it based on the time it was started
std::sort(prod.begin(), prod.end(), CompareWhenStarted());
BWAPI::Broodwar->drawTextScreen(x-30, y+20, "\x04 TIME");
BWAPI::Broodwar->drawTextScreen(x, y+20, "\x04 UNIT NAME");
size_t reps = prod.size() < 10 ? prod.size() : 10;
y += 30;
int yy = y;
// for each unit in the _queue
for (auto & unit : prod)
{
std::string prefix = "\x07";
yy += 10;
BWAPI::UnitType t = unit->getType();
if (t == BWAPI::UnitTypes::Zerg_Egg)
{
t = unit->getBuildType();
}
BWAPI::Broodwar->drawTextScreen(x, yy, " %s%s", prefix.c_str(), t.getName().c_str());
BWAPI::Broodwar->drawTextScreen(x - 35, yy, "%s%6d", prefix.c_str(), unit->getRemainingBuildTime());
}
_queue.drawQueueInformation(x, yy+10);
}
开发者ID:pineal,项目名称:SC_AI_Flash,代码行数:49,代码来源:ProductionManager.cpp
注:本文中的bwapi::UnitType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论