本文整理汇总了C++中bwapi::UnitType::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitType::getName方法的具体用法?C++ UnitType::getName怎么用?C++ UnitType::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwapi::UnitType
的用法示例。
在下文中一共展示了UnitType::getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
}
示例2: GetActionID
ActionID ActionTypeData::GetActionID(const BWAPI::UnitType & type)
{
const RaceID raceID = GetRaceID(type.getRace());
BOSS_ASSERT(raceID < Races::NUM_RACES, "Race ID invalid: %d %s", (int)raceID, type.getName().c_str());
for (ActionID a(0); a < ActionTypeData::GetNumActionTypes(raceID); ++a)
{
const ActionTypeData & data = GetActionTypeData(raceID, a);
if (data.isUnit() && data.getUnitType() == type)
{
return data.getActionID();
}
}
BOSS_ASSERT(false, "Could not find UnitType: %d %s", type.getID(), type.getName().c_str());
return 0;
}
示例3: 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());
}
}
}
示例4:
const std::string GUI::getTextureFileName(const BWAPI::UnitType type) const
{
std::stringstream image;
#ifdef WIN32
image << imageDir << "units\\" << type.getName() << ".png";
#else
image << imageDir << "units/" << type.getName() << ".png";
#endif
std::string filename = image.str();
for (size_t i(0); i<filename.size(); ++i)
{
if (filename[i] == ' ')
{
filename[i] = '_';
}
}
return filename;
}
示例5: 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));
}
示例6: 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);
}
示例7: finishUnit
bool HLUnitData::finishUnit(BWAPI::UnitType type)
{
bool found = false;
for (auto &item : _unitMap){
if (item.second.type.getID() == type.getID() && !item.second.completed){
item.second.completed = true;
numCompletedUnits[type.getID()]++;
found = true;
break;
}
}
UAB_ASSERT(found,"Couldn't find unit to finish: %s\n",type.getName().c_str());
return found;
}
示例8: 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();
}
示例9: getAction
Action getAction(const BWAPI::UnitType & a) const
{
int index = -1;
for (size_t i(0); i < actions.size(); ++i)
{
if (actions[i].isUnit() && actions[i].getUnitType() == a)
{
index = i;
break;
}
}
if (index < 0)
{
printf("Error Incoming: %s\n", a.getName().c_str());
}
assert(index > -1);
return (Action)index;
}
示例10: checkSupportedUnitType
void checkSupportedUnitType(const BWAPI::UnitType & type)
{
if (type == BWAPI::UnitTypes::None || type == BWAPI::UnitTypes::Unknown)
{
System::FatalError("Unknown unit type in experiment file, not supported");
}
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() && type!=BWAPI::UnitTypes::Terran_Medic && type!=BWAPI::UnitTypes::Protoss_High_Templar)
if (type.isSpellcaster() && type!=BWAPI::UnitTypes::Terran_Medic)
{
System::FatalError("Spell casting units not currently supported: " + type.getName());
}
// Don't support units loading other units yet
if (type == BWAPI::UnitTypes::Terran_Vulture_Spider_Mine ||
type == BWAPI::UnitTypes::Protoss_Carrier ||
type == BWAPI::UnitTypes::Protoss_Interceptor ||
type == BWAPI::UnitTypes::Protoss_Reaver ||
type == BWAPI::UnitTypes::Protoss_Scarab ||
type == BWAPI::UnitTypes::Zerg_Broodling)
{
System::FatalError("Units which have unit projectiles not supported: " + type.getName());
}
}
示例11: onSendText
void UAlbertaBotModule::onSendText(std::string text)
{
if (Options::Modules::USING_REPLAY_VISUALIZER && (text.compare("sim") == 0))
{
BWAPI::UnitInterface* selected = NULL;
for (BWAPI::UnitInterface* unit : BWAPI::Broodwar->getAllUnits())
{
if (unit->isSelected())
{
selected = unit;
break;
}
}
if (selected)
{
#ifdef USING_VISUALIZATION_LIBRARIES
//ReplayVisualizer rv;
//rv.launchSimulation(selected->getPosition(), 1000);
#endif
}
}
if (Options::Modules::USING_BUILD_ORDER_DEMO)
{
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());
}
}
}
示例12: drawProductionInformation
void ProductionManager::drawProductionInformation(int x, int y)
{
// fill prod with each unit which is under construction
std::vector<BWAPI::UnitInterface*> prod;
for (BWAPI::UnitInterface* unit : BWAPI::Broodwar->self()->getUnits())
{
UAB_ASSERT(unit != NULL, "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());
if (Options::Debug::DRAW_UALBERTABOT_DEBUG) BWAPI::Broodwar->drawTextScreen(x, y, "\x04 Build Order Info:");
if (Options::Debug::DRAW_UALBERTABOT_DEBUG) BWAPI::Broodwar->drawTextScreen(x, y+20, "\x04UNIT NAME");
size_t reps = prod.size() < 10 ? prod.size() : 10;
y += 40;
int yy = y;
// for each unit in the queue
for (size_t i(0); i<reps; i++)
{
std::string prefix = "\x07";
yy += 10;
BWAPI::UnitType t = prod[i]->getType();
if (Options::Debug::DRAW_UALBERTABOT_DEBUG) BWAPI::Broodwar->drawTextScreen(x, yy, "%s%s", prefix.c_str(), t.getName().c_str());
if (Options::Debug::DRAW_UALBERTABOT_DEBUG) BWAPI::Broodwar->drawTextScreen(x+150, yy, "%s%6d", prefix.c_str(), prod[i]->getRemainingBuildTime());
}
queue.drawQueueInformation(x, yy+10);
}