本文整理汇总了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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}