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


C++ MetaType::getUpgradeType方法代码示例

本文整理汇总了C++中MetaType::getUpgradeType方法的典型用法代码示例。如果您正苦于以下问题:C++ MetaType::getUpgradeType方法的具体用法?C++ MetaType::getUpgradeType怎么用?C++ MetaType::getUpgradeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MetaType的用法示例。


在下文中一共展示了MetaType::getUpgradeType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: canMakeNow

bool ProductionManager::canMakeNow(BWAPI::Unit producer, MetaType t)
{
    //UAB_ASSERT(producer != nullptr, "Producer was null");

	bool canMake = meetsReservedResources(t);
	if (canMake)
	{
		if (t.isUnit())
		{
			canMake = BWAPI::Broodwar->canMake(t.getUnitType(), producer);
		}
		else if (t.isTech())
		{
			canMake = BWAPI::Broodwar->canResearch(t.getTechType(), producer);
		}
		else if (t.isUpgrade())
		{
			if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Carapace)
			{
				BWAPI::Broodwar->printf("Trying to create carapace with %d %d EVO CHAMBER\n", producer->getTilePosition().x, producer->getTilePosition().y);
			}
			else if ((t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Missile_Attacks))
			{
				BWAPI::Broodwar->printf("Trying to create misisle attacks with %d %d EVO CHAMBER\n", producer->getTilePosition().x, producer->getTilePosition().y);
			}
			canMake = BWAPI::Broodwar->canUpgrade(t.getUpgradeType(), producer);
		}
		else
		{	
			UAB_ASSERT(false, "Unknown type");
		}
	}

	return canMake;
}
开发者ID:0x4849,项目名称:c350,代码行数:35,代码来源:ProductionManagerbuggy.cpp

示例2: canMakeNow

bool ProductionManager::canMakeNow(BWAPI::Unit producer, MetaType t)
{
    //UAB_ASSERT(producer != nullptr, "Producer was null");

	bool canMake = meetsReservedResources(t);
	if (canMake)
	{
		if (t.isUnit())
		{
			canMake = BWAPI::Broodwar->canMake(t.getUnitType(), producer);
		}
		else if (t.isTech())
		{
			canMake = BWAPI::Broodwar->canResearch(t.getTechType(), producer);
		}
		else if (t.isUpgrade())
		{
			canMake = BWAPI::Broodwar->canUpgrade(t.getUpgradeType(), producer);
		}
		else
		{	
			UAB_ASSERT(false, "Unknown type");
		}
	}

	return canMake;
}
开发者ID:pineal,项目名称:SC_AI_Flash,代码行数:27,代码来源:ProductionManager.cpp

示例3: create

// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item) 
{
    if (!producer)
    {
        return;
    }

    MetaType t = item.metaType;

    // if we're dealing with a building
    if (t.isUnit() && t.getUnitType().isBuilding() 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
        && !t.getUnitType().isAddon())
    {
        // send the building task to the building manager
		if (t.getUnitType() == BWAPI::UnitTypes::Terran_Bunker)
		{
			BWAPI::TilePosition tp = BWAPI::TilePosition(BWTA::getNearestChokepoint(BWAPI::Position(BWAPI::Broodwar->self()->getStartLocation()))->getCenter());
			BuildingManager::Instance().addBuildingTask(t.getUnitType(), tp, item.isGasSteal);
		}
		else {
			BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
		}
    }
    else if (t.getUnitType().isAddon())
    {
        //BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
        producer->buildAddon(t.getUnitType());
    }
    // if we're dealing with a non-building unit
    else if (t.isUnit()) 
    {
        // if the race is zerg, morph the unit
        if (t.getUnitType().getRace() == BWAPI::Races::Zerg) 
        {
            producer->morph(t.getUnitType());
        // if not, train the unit
        } 
        else 
        {
            producer->train(t.getUnitType());
        }
    }
    // if we're dealing with a tech research
    else if (t.isTech())
    {
        producer->research(t.getTechType());
    }
    else if (t.isUpgrade())
    {
        //Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
        producer->upgrade(t.getUpgradeType());
    }
    else
    {	
		
    }
}
开发者ID:smithe0,项目名称:ualbertabot,代码行数:61,代码来源:ProductionManager.cpp

示例4: getEvolutionChamberProducer

BWAPI::Unit ProductionManager::getEvolutionChamberProducer(BWAPI::Unit producer, MetaType t)
{
	if (upgradingStuff.find(producer) != upgradingStuff.end())
	{
		BWAPI::Broodwar->printf("Entered uprgading stuff loop\n");
		for (auto x : BWAPI::Broodwar->self()->getUnits())
		{
			if (x->getType() == producer->getType() && x != producer)
			{
				if (upgradeMap.find(x) == upgradeMap.end() || (upgradeMap.find(x) != upgradeMap.end() && upgradeMap[x] == 0))
				{
					upgradeMap[x] = BWAPI::Broodwar->getFrameCount() + t.getUpgradeType().upgradeTime();
					return x;
				}
			}
		}
	}
	return producer;
}
开发者ID:0x4849,项目名称:c350,代码行数:19,代码来源:ProductionManagerbuggy.cpp

示例5: GetActionType

BOSS::ActionType BOSSManager::GetActionType(const MetaType & t)
{
    // set the appropriate type
    if (t.isUnit())
    {
        return BOSS::ActionType(t.getUnitType());
    }
    else if (t.isUpgrade())
    {
        return BOSS::ActionType(t.getUpgradeType());
    }
    else if (t.isTech())
    {
        return BOSS::ActionType(t.getTechType());
    }
    else
    {
        UAB_ASSERT(false, "Should have found a valid type here");
    }

    return BOSS::ActionType();
}
开发者ID:ssssuishui,项目名称:ualbertabot,代码行数:22,代码来源:BOSSManager.cpp

示例6: create

// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item)
{
	if (!producer)
	{
		return;
	}

	MetaType t = item.metaType;

	// if we're dealing with a building
	if (t.isUnit() && t.getUnitType().isBuilding()
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Sunken_Colony
		&& !t.getUnitType().isAddon())
	{
		// send the building task to the building manager
		BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
	}
	else if (t.getUnitType().isAddon())
	{
		//BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
		producer->buildAddon(t.getUnitType());
	}
	// if we're dealing with a non-building unit
	else if (t.isUnit())
	{
		// if the race is zerg, morph the unit
		if (t.getUnitType().getRace() == BWAPI::Races::Zerg)
		{
			producer->morph(t.getUnitType());
			if (t.getUnitType() == BWAPI::UnitTypes::Zerg_Overlord)
			{
				_overlordTimer = BWAPI::Broodwar->getFrameCount() + t.getUnitType().buildTime() + 35;
			}

			// if not, train the unit
		}
		else
		{
			producer->train(t.getUnitType());
		}
	}
	// if we're dealing with a tech research
	else if (t.isTech())
	{
		producer->research(t.getTechType());
	}
	else if (t.isUpgrade())
	{
		//Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
		
		if (t.getUpgradeType() == BWAPI::UpgradeTypes::Muscular_Augments)
		{
			muscBuildTimer = BWAPI::Broodwar->getFrameCount() + t.getUpgradeType().upgradeTime();
			muscBuild = true;
		}
		producer->upgrade(t.getUpgradeType());
	}
	else
	{

	}
}
开发者ID:0x4849,项目名称:c350,代码行数:66,代码来源:ProductionManager.cpp

示例7: create

// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item) 
{
    if (!producer)
    {
        return;
    }

    MetaType t = item.metaType;

    // if we're dealing with a building
    if (t.isUnit() && t.getUnitType().isBuilding() 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Sunken_Colony
        && !t.getUnitType().isAddon())
    {
        // send the building task to the building manager
        BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
    }
    else if (t.getUnitType().isAddon())
    {
        //BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
        producer->buildAddon(t.getUnitType());
    }
    // if we're dealing with a non-building unit
    else if (t.isUnit()) 
    {
        // if the race is zerg, morph the unit
        if (t.getUnitType().getRace() == BWAPI::Races::Zerg) 
        {
			if (t.getUnitType() == BWAPI::UnitTypes::Zerg_Overlord)
			{
				overlordBuildTimer = BWAPI::Broodwar->getFrameCount() + t.getUnitType().buildTime();
				canOverlord = true;
			}
            producer->morph(t.getUnitType());
        // if not, train the unit
        } 
        else 
        {
            producer->train(t.getUnitType());
        }
    }
    // if we're dealing with a tech research
    else if (t.isTech())
    {
        producer->research(t.getTechType());
    }
    else if (t.isUpgrade())
    {
		if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Carapace)
		{
			BWAPI::Broodwar->printf("Got a request for carapace upgrade using producer x %d y %d: \n", producer->getTilePosition().x, producer->getTilePosition().y);
		}
		else if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Missile_Attacks)
		{
			BWAPI::Broodwar->printf("Got a request for missile attacks upgrade using producer x %d y %d : \n", producer->getTilePosition().x, producer->getTilePosition().y);
		}
		producer = getEvolutionChamberProducer(producer, t);
		//BWAPI::Broodwar->printf("Got request for capace or missile attacks with producer type : x : %d  y: %d\n", producer->getTilePosition().x, producer->getTilePosition().y);
		//}
        //Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
        producer->upgrade(t.getUpgradeType());
		upgradingStuff.insert(producer);
    }
    else
    {	
		
    }
}
开发者ID:0x4849,项目名称:c350,代码行数:72,代码来源:ProductionManagerbuggy.cpp

示例8: getProducer

BWAPI::Unit ProductionManager::getProducer(MetaType t, BWAPI::Position closestTo)
{
    // get the type of unit that builds this
    BWAPI::UnitType producerType = t.whatBuilds();

    // make a set of all candidate producers
    BWAPI::Unitset candidateProducers;
    for (auto & unit : BWAPI::Broodwar->self()->getUnits())
    {
        UAB_ASSERT(unit != nullptr, "Unit was null");

        // reasons a unit can not train the desired type
        if (unit->getType() != producerType)                    { continue; }
        if (!unit->isCompleted())                               { continue; }
        if (unit->isTraining())                                 { continue; }
        if (unit->isLifted())                                   { continue; }
        if (!unit->isPowered())                                 { continue; }

        // if the type is an addon, some special cases
        if (t.getUnitType().isAddon())
        {
				// if the unit already has an addon, it can't make one
			if (unit->getAddon() != nullptr)
			{
				continue;
			}

			// if we just told this unit to build an addon, then it will not be building another one
			// this deals with the frame-delay of telling a unit to build an addon and it actually starting to build
			if (unit->getLastCommand().getType() == BWAPI::UnitCommandTypes::Build_Addon 
				&& (BWAPI::Broodwar->getFrameCount() - unit->getLastCommandFrame() < 10)) 
			{ 
				continue; 
			}

			bool isBlocked = false;

			// if the unit doesn't have space to build an addon, it can't make one
			BWAPI::TilePosition addonPosition(unit->getTilePosition().x + unit->getType().tileWidth(), unit->getTilePosition().y + unit->getType().tileHeight() - t.getUnitType().tileHeight());
			BWAPI::Broodwar->drawBoxMap(addonPosition.x*32, addonPosition.y*32, addonPosition.x*32 + 64, addonPosition.y*32 + 64, BWAPI::Colors::Red);
            
			for (int i=0; i<unit->getType().tileWidth() + t.getUnitType().tileWidth(); ++i)
			{
				for (int j=0; j<unit->getType().tileHeight(); ++j)
				{
					BWAPI::TilePosition tilePos(unit->getTilePosition().x + i, unit->getTilePosition().y + j);

					// if the map won't let you build here, we can't build it
					if (!BWAPI::Broodwar->isBuildable(tilePos))
					{
						isBlocked = true;
						BWAPI::Broodwar->drawBoxMap(tilePos.x*32, tilePos.y*32, tilePos.x*32 + 32, tilePos.y*32 + 32, BWAPI::Colors::Red);
					}

					// if there are any units on the addon tile, we can't build it
					BWAPI::Unitset uot = BWAPI::Broodwar->getUnitsOnTile(tilePos.x, tilePos.y);
					if (uot.size() > 0 && !(uot.size() == 1 && *(uot.begin()) == unit))
					{
						isBlocked = true;;
						BWAPI::Broodwar->drawBoxMap(tilePos.x*32, tilePos.y*32, tilePos.x*32 + 32, tilePos.y*32 + 32, BWAPI::Colors::Red);
					}
				}
            }

            if (isBlocked)
            {
                continue;
            }
        }
        
        // if the type requires an addon and the producer doesn't have one
        typedef std::pair<BWAPI::UnitType, int> ReqPair;
        for (const ReqPair & pair : t.getUnitType().requiredUnits())
        {
            BWAPI::UnitType requiredType = pair.first;
            if (requiredType.isAddon())
            {
                if (!unit->getAddon() || (unit->getAddon()->getType() != requiredType))
                {
                    continue;
                }
            }
        }

        // if we haven't cut it, add it to the set of candidates
        candidateProducers.insert(unit);
    }
	if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Carapace)
	{
		/*
		for (auto x : candidateProducers)
		{
			BWAPI::Broodwar->printf("Candidate Position : %d %d\n", x->getTilePosition().x, x->getTilePosition().y);
		}
		*/
	}
    return getClosestUnitToPosition(candidateProducers, closestTo);
}
开发者ID:0x4849,项目名称:c350,代码行数:98,代码来源:ProductionManagerbuggy.cpp


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