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


C++ CvUnitEntry::GetPrereqAndTech方法代码示例

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


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

示例1: isTechRequiredForUnit

bool isTechRequiredForUnit(TechTypes eTech, UnitTypes eUnit)
{
	CvUnitEntry* info = GC.getUnitInfo(eUnit);
	if(info == NULL)
	{
		return false;
	}

	if(info->GetPrereqAndTech() == eTech)
	{
		return true;
	}

	for(int iI = 0; iI < GC.getNUM_UNIT_AND_TECH_PREREQS(); iI++)
	{
		if(info->GetPrereqAndTechs(iI) == eTech)
		{
			return true;
		}
	}

	return false;
}
开发者ID:Ninakoru,项目名称:Community-Patch-DLL,代码行数:23,代码来源:CvGameCoreUtils.cpp

示例2: GetLeastAdvancedUnitClassNobodyHas

//	---------------------------------------------------------------------------
UnitClassTypes CvGameQueries::GetLeastAdvancedUnitClassNobodyHas(bool bUseRandom /* = false */)
{
	CvWeightedVector<int, SAFE_ESTIMATE_NUM_UNITS, true> UnitClassesVector;
	int iWeight;

	bool bValid;

	for (int i = 0; i < GC.getNumUnitClassInfos(); i++)
	{
		const UnitClassTypes eUnitClass = static_cast<UnitClassTypes>(i);
		CvUnitClassInfo* pkUnitClassInfo = GC.getUnitClassInfo(eUnitClass);
		if(pkUnitClassInfo)
		{
			const UnitTypes eDefaultUnit = (UnitTypes) pkUnitClassInfo->getDefaultUnitIndex();

			// If the UnitClass doesn't have a Default Unit available to everyone, skip it
			if (eDefaultUnit == NO_UNIT)
			{
				continue;
			}

			CvUnitEntry* pkUnitInfo = GC.getUnitInfo(eDefaultUnit);
			if(pkUnitInfo == NULL)
			{
				continue;
			}

			// Only look at Land Units
			if (pkUnitInfo->GetDomainType() != DOMAIN_LAND)
			{
				continue;
			}
			// Only look at Military Units
			if (pkUnitInfo->GetCombat() <= 0)
			{
				continue;
			}

			const TechTypes ePrereqTech = (TechTypes) pkUnitInfo->GetPrereqAndTech();

			// Unit has to require a Tech, otherwise it's too easy!
			if (ePrereqTech == NO_TECH)
			{
				continue;
			}

			CvTechEntry* pkTechInfo = GC.getTechInfo(ePrereqTech);
			if(pkTechInfo == NULL)
			{
				continue;
			}

			bValid = true;
			bool bAllPlayersHaveTech = true;

			for (int iMajorLoop = 0; iMajorLoop < MAX_MAJOR_CIVS; iMajorLoop++)
			{
				if (GET_PLAYER((PlayerTypes) iMajorLoop).isAlive())
				{
					// If a player already has one of this Unit, throw it out - we want something more advanced
					if (GET_PLAYER((PlayerTypes) iMajorLoop).getUnitClassCount(eUnitClass) > 0)
					{
						bValid = false;
						break;
					}

					// Even if no one has this Unit lying around, if all players already have the Tech which unlocks it, throw it out - too easy
					if (bAllPlayersHaveTech && !GET_TEAM((TeamTypes) GET_PLAYER((PlayerTypes) iMajorLoop).getTeam()).GetTeamTechs()->HasTech(ePrereqTech))
					{
						bAllPlayersHaveTech = false;
					}
				}
			}
			if (!bValid || bAllPlayersHaveTech)
			{
				continue;
			}

			iWeight = pkUnitInfo->GetPower();

			// Add a Tech factor, since we want something in the near future, not too far off
			iWeight += (pkTechInfo->GetResearchCost() / 8);

			// Add a random bit so that the same Unit isn't ALWAYS picked
			if (bUseRandom)
			{
				iWeight += GC.getGame().getJonRandNum(iWeight / 10, "Minor Civ Quest: Gift Unit - Adding random weight to Unit Chosen");
			}

			UnitClassesVector.push_back(i, iWeight);
		}
	}

	UnitClassesVector.SortItems();

	//int iValue;

	bValid = true;

//.........这里部分代码省略.........
开发者ID:Be1eriand,项目名称:Civ5-DLL,代码行数:101,代码来源:CvGameQueries.cpp


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