当前位置: 首页>>代码示例>>C++>>正文


C++ bwapi::UnitType类代码示例

本文整理汇总了C++中bwapi::UnitType的典型用法代码示例。如果您正苦于以下问题:C++ UnitType类的具体用法?C++ UnitType怎么用?C++ UnitType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UnitType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的bwapi::UnitType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。