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


C++ CSystem::CalcMatchStrength方法代码示例

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


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

示例1: if

CSoundType *CSoundtrackManager::CalcGameTrackToPlay (const CString &sRequiredAttrib)

//	CalcGameTrackToPlay
//
//	Calculates a game track to play.

	{
	int i;
	CSystem *pSystem = g_pUniverse->GetCurrentSystem();

	//	Create a probability table of tracks to play.

	TSortMap<int, TProbabilityTable<CSoundType *>> Table(DescendingSort);
	for (i = 0; i < g_pUniverse->GetSoundTypeCount(); i++)
		{
		CSoundType *pTrack = g_pUniverse->GetSoundType(i);

		//	If this is not appropriate music then skip it

		if (!pTrack->HasAttribute(sRequiredAttrib))
			continue;

		//	If this is a system track and we've already played a
		//	system track, then skip it.

		else if (m_bSystemTrackPlayed
				&& pTrack->HasAttribute(ATTRIB_SYSTEM_SOUNDTRACK))
			continue;

		//	Calculate the chance for this track based on location
		//	criteria.

		int iChance = (pSystem ? pSystem->CalcMatchStrength(pTrack->GetLocationCriteria()) : 1000);
		if (iChance == 0)
			continue;

		//	Adjust probability based on when we last played this tack.

		switch (GetLastPlayedRank(pTrack->GetUNID()))
			{
			case 0:
				iChance = 0;
				break;

			case 1:
				iChance = iChance / 10;
				break;

			case 2:
				iChance = iChance / 5;
				break;

			case 3:
			case 4:
				iChance = iChance / 3;
				break;

			case 5:
			case 6:
			case 7:
				iChance = iChance / 2;
				break;

			case 8:
			case 9:
			case 10:
				iChance = 2 * iChance / 3;
				break;
			}

		if (iChance == 0)
			continue;

		//	Add to the probability table

		TProbabilityTable<CSoundType *> *pEntry = Table.SetAt(pTrack->GetPriority());
		pEntry->Insert(pTrack, iChance);
		}

	//	If the table is empty, then there is nothing to play.

	if (Table.GetCount() == 0)
		return NULL;

	//	Otherwise, roll out of the first table.

	TProbabilityTable<CSoundType *> &Entry = Table[0];
	return Entry.GetAt(Entry.RollPos());
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:89,代码来源:CSoundtrackManager.cpp


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