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


C++ CASW_Game_Resource::AreAllOtherPlayersReady方法代码示例

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


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

示例1: PlayerSpectating

void CASW_Campaign_Save::PlayerSpectating(CASW_Player* pPlayer)
{
	if (!ASWGameRules() || !pPlayer)
		return;
	if (ASWGameRules()->GetGameState() != ASW_GS_CAMPAIGNMAP)
		return;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if (m_bNextMissionVoteEnded)	// don't allow votes if the mission has already been chosen
		return;

	pPlayer->m_bRequestedSpectator = true;
	// if player is ready, that means he's already voted or a spectator
	int iPlayer = pPlayer->entindex() -1 ;
	if (iPlayer<0 ||iPlayer>ASW_MAX_READY_PLAYERS-1)
		return;
	if (pGameResource->IsPlayerReady(pPlayer->entindex()))
	{
		// subtract his old vote
		int iVotedFor = pGameResource->m_iCampaignVote[iPlayer];
		if (iVotedFor >=0 && iVotedFor < ASW_MAX_MISSIONS_PER_CAMPAIGN)
		{
			int iVotes = m_NumVotes[iVotedFor] - 1;
			m_NumVotes.Set(iVotedFor, iVotes);
		}
	}
	// clear his chosen mission and flag him as ready
	pGameResource->m_iCampaignVote[iPlayer] = -1;
	pGameResource->m_bPlayerReady.Set(iPlayer, true);

	if (pGameResource->AreAllOtherPlayersReady(pPlayer->entindex()))
	{
		if ( gpGlobals->maxClients > 1 )
		{
			if (!m_fVoteEndTime != 0)
			{	
				m_fVoteEndTime = gpGlobals->curtime + 4.0f;
			}
			SetThink( &CASW_Campaign_Save::VoteEndThink );
			SetNextThink( m_fVoteEndTime );
		}
		else
		{
			VoteEnded();
		}
	}
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:49,代码来源:asw_campaign_save.cpp

示例2: PlayerDisconnected

void CASW_Campaign_Save::PlayerDisconnected(CASW_Player *pPlayer)
{
	if (!ASWGameRules() || !pPlayer)
		return;
	if (ASWGameRules()->GetGameState() != ASW_GS_CAMPAIGNMAP)
		return;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if (m_bNextMissionVoteEnded)	// don't allow votes if the mission has already been chosen
		return;

	// if player is ready, that means he's already voted or a spectator
	int iPlayer = pPlayer->entindex() -1 ;
	if (iPlayer<0 ||iPlayer>ASW_MAX_READY_PLAYERS-1)
		return;
	if (pGameResource->IsPlayerReady(pPlayer->entindex()))
	{
		// subtract his old vote
		int iVotedFor = pGameResource->m_iCampaignVote[iPlayer];
		if (iVotedFor >=0 && iVotedFor < ASW_MAX_MISSIONS_PER_CAMPAIGN)
		{
			int iVotes = m_NumVotes[iVotedFor] - 1;
			m_NumVotes.Set(iVotedFor, iVotes);
		}
	}

	// check for ending the vote
	if (pGameResource->AreAllOtherPlayersReady(pPlayer->entindex()))
	{
		if ( gpGlobals->maxClients > 1 )
		{
			//softcopy:test debug mission can't continue if one of the player disconnected
			/*if (!m_fVoteEndTime != 0)
			{	
				m_fVoteEndTime = gpGlobals->curtime + 4.0f;
			}
			SetThink( &CASW_Campaign_Save::VoteEndThink );
			SetNextThink( m_fVoteEndTime );*/
			VoteEnded();
		}
		else 
		{
			VoteEnded();
		}
	}
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:48,代码来源:asw_campaign_save.cpp

示例3: PlayerVote

void CASW_Campaign_Save::PlayerVote(CASW_Player* pPlayer, int iMission)
{
	if (!ASWGameRules() || !pPlayer || pPlayer->m_bRequestedSpectator)
		return;
	if (ASWGameRules()->GetGameState() != ASW_GS_CAMPAIGNMAP)
		return;
	CASW_Game_Resource *pGameResource = ASWGameResource();
	if (!pGameResource)
		return;

	if (m_bNextMissionVoteEnded)	// don't allow votes if the mission has already been chosen
		return;

	// if player is ready, that means he's already voted or a spectator
	int iPlayer = pPlayer->entindex() -1 ;
	if (iPlayer<0 ||iPlayer>ASW_MAX_READY_PLAYERS-1)
		return;
	if (pGameResource->IsPlayerReady(pPlayer->entindex()))
	{
		// subtract his old vote
		int iVotedFor = pGameResource->m_iCampaignVote[iPlayer];
		if (iVotedFor >=0 && iVotedFor < ASW_MAX_MISSIONS_PER_CAMPAIGN)
		{
			int iVotes = m_NumVotes[iVotedFor] - 1;
			m_NumVotes.Set(iVotedFor, iVotes);
		}
	}
	if (iMission < 0 || iMission >= ASW_MAX_MISSIONS_PER_CAMPAIGN)
		return;

	// don't allow vote for this mission if this mission was already completed, or if it's the dropzone
	if (m_MissionComplete[iMission] != 0 || iMission <= 0)
		return;

	// make sure the mission they want to vote for is reachable
	if (!IsMissionLinkedToACompleteMission(iMission, ASWGameRules()->GetCampaignInfo()))
		return;	

	// add his vote to the chosen map
	pGameResource->m_iCampaignVote[iPlayer] = iMission;
	int iVotes = m_NumVotes[iMission] + 1;
	m_NumVotes.Set(iMission, iVotes);
	// flag him as ready
	pGameResource->m_bPlayerReady.Set(iPlayer, true);

	if (pGameResource->AreAllOtherPlayersReady(pPlayer->entindex()))
	{
		if ( gpGlobals->maxClients > 1 )
		{
			if (!m_fVoteEndTime != 0)
			{	
				m_fVoteEndTime = gpGlobals->curtime + 4.0f;
			}
			SetThink( &CASW_Campaign_Save::VoteEndThink );
			SetNextThink( m_fVoteEndTime );
		}
		else
		{
			VoteEnded();
		}
	}
}
开发者ID:jtanx,项目名称:ch1ckenscoop,代码行数:62,代码来源:asw_campaign_save.cpp


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