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


C++ CGameRules::GetTeamPlayerCount方法代码示例

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


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

示例1: Update

void CHUDTagNames::Update()
{
	CActor *pClientActor = static_cast<CActor *>(g_pGame->GetIGameFramework()->GetClientActor());
	CGameRules *pGameRules = g_pGame->GetGameRules();

	if(!pClientActor || !pGameRules || !gEnv->bMultiplayer)
		return;

	int iClientTeam = pGameRules->GetTeam(pClientActor->GetEntityId());

	// Skip enemies, they need to be added only when shot
	// (except in spectator mode when we display everyone)
	for(int iTeam = 0; iTeam < pGameRules->GetTeamCount() + 1; ++iTeam)
	{
		if((iTeam == iClientTeam) || (pClientActor->GetSpectatorMode() != CActor::eASM_None))
		{
			int iTeamPlayerCount = pGameRules->GetTeamPlayerCount(iTeam);
			for(int iPlayer=0; iPlayer<iTeamPlayerCount; iPlayer++)
			{
				IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pGameRules->GetTeamPlayer(iTeam,iPlayer));
				if(!pActor)
					continue;

				// Never display the local player
				if(pActor == pClientActor)
					continue;

				// never display other spectators
				if(static_cast<CActor*>(pActor)->GetSpectatorMode() != CActor::eASM_None)
					continue;

				// never display the name of the player we're spectating (it's shown separately with their current health)
				if(pClientActor->GetSpectatorMode() == CActor::eASM_Follow && pClientActor->GetSpectatorTarget() == pActor->GetEntityId())
					continue;

				DrawTagName(pActor);
			}
		}
	}

	IVehicleSystem *pVehicleSystem = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem();
	if(!pVehicleSystem)
		return;

	IVehicleIteratorPtr pVehicleIter = pVehicleSystem->CreateVehicleIterator();
	while(IVehicle *pVehicle=pVehicleIter->Next())
	{
		SVehicleStatus rVehicleStatus = pVehicle->GetStatus();
		if(0 == rVehicleStatus.passengerCount)
			continue;

		// Skip enemy vehicles, they need to be added only when shot (except in spectator mode...)
		bool bEnemyVehicle = true;
		for(int iSeatId=1; iSeatId<=pVehicle->GetLastSeatId(); iSeatId++)
		{
			IVehicleSeat *pVehicleSeat = pVehicle->GetSeatById(iSeatId);
			if(!pVehicleSeat)
				continue;

			EntityId uiEntityId = pVehicleSeat->GetPassenger();

			if(0 == iClientTeam)
			{
				if(uiEntityId && IsFriendlyToClient(uiEntityId))
				{
					bEnemyVehicle = false;
				}
			}
			else if(uiEntityId && pGameRules->GetTeam(uiEntityId) == iClientTeam)
			{
				bEnemyVehicle = false;
			}
		}
		if(bEnemyVehicle && (pClientActor->GetSpectatorMode() == CActor::eASM_None))	// again, draw enemies in spectator mode
			continue;

		DrawTagName(pVehicle);
	}

	// don't need to do any of this if we're in spectator mode - all player names will have been drawn above.
	if(pClientActor->GetSpectatorMode() == CActor::eASM_None)
	{
		for(TEnemyTagNamesList::iterator iter=m_enemyTagNamesList.begin(); iter!=m_enemyTagNamesList.end(); ++iter)
		{
			SEnemyTagName *pEnemyTagName = &(*iter);
			if(gEnv->pTimer->GetAsyncTime().GetSeconds() >= pEnemyTagName->fSpawnTime+((float) g_pGameCVars->hud_mpNamesDuration))
			{
				// Note: iter=my_list.erase(iter) may not be standard/safe
				TEnemyTagNamesList::iterator iterNext = iter;
				++iterNext;
				m_enemyTagNamesList.erase(iter);
				iter = iterNext;
			}
			else
			{
				IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pEnemyTagName->uiEntityId);
				if(pActor)
					DrawTagName(pActor);

				IVehicle *pVehicle = gEnv->pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(pEnemyTagName->uiEntityId);
//.........这里部分代码省略.........
开发者ID:RenEvo,项目名称:dead6,代码行数:101,代码来源:HUDTagNames.cpp


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