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


C++ UnitType::size方法代码示例

本文整理汇总了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;
	}
开发者ID:4rChon,项目名称:ACT-AI,代码行数:91,代码来源:CompositionHelper.cpp


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