/// <summary> /// 检测游戏是否异常结束 /// </summary> private bool CheckGameAbnormalEnd() { //判断还剩下多少玩家,如果玩家少于2,则表示至少有玩家主动退出 if (m_ListPlayer.Count < 2) { //直接进入GameEnd状态 SetGameState(FSPGameState.GameEnd, (int)FSPGameEndReason.AllOtherExit); AddCmdToCurrentFrame(FSPVKeyBase.GAME_END, (int)FSPGameEndReason.AllOtherExit); return(true); } // 检测玩家在线状态 for (int i = 0; i < m_ListPlayer.Count; i++) { FSPPlayer player = m_ListPlayer[i]; if (player.IsLose()) { m_ListPlayer.RemoveAt(i); FSPServer.Instance.DelSession(player.Sid); player.Dispose(); --i; } } //判断还剩下多少玩家,如果玩家少于2,则表示有玩家掉线了 if (m_ListPlayer.Count < 2) { //直接进入GameEnd状态 SetGameState(FSPGameState.GameEnd, (int)FSPGameEndReason.AllOtherLost); AddCmdToCurrentFrame(FSPVKeyBase.GAME_END, (int)FSPGameEndReason.AllOtherLost); return(true); } return(false); }
//============================================================ /// <summary> /// 检测游戏是否异常结束 /// </summary> private bool CheckGameAbnormalEnd() { //判断还剩下多少玩家,如果玩家少于2,则表示至少有玩家主动退出 if (m_ListPlayer.Count < 1) { //直接进入GameEnd状态 SetGameState(FSPGameState.GameEnd, (int)FSPGameEndReason.AllOtherExit); AddBasicCmdToCurrentFrame(FSPBasicCmd.GAME_END, (int)FSPGameEndReason.AllOtherExit); return(true); } // 检测玩家在线状态 for (int i = 0; i < m_ListPlayer.Count; i++) { FSPPlayer player = m_ListPlayer[i]; if (player.IsLose()) { m_ListPlayer.RemoveAt(i); player.Release(); --i; } } //判断还剩下多少玩家,如果玩家少于1,则表示至少有玩家主动退出 if (m_ListPlayer.Count < 1) { //直接进入GameEnd状态 SetGameState(FSPGameState.GameEnd, (int)FSPGameEndReason.AllOtherLost); AddBasicCmdToCurrentFrame(FSPBasicCmd.GAME_END, (int)FSPGameEndReason.AllOtherLost); return(true); } return(false); }
/// <summary> /// check if there are player exit abnormally /// </summary> private bool CheckGameAbnormalEnd() { //check current player,if less than 2 if (mPlayerList.Count < 2) { //enter GameEnd state SetGameState(FSPGameState.GameEnd, (int)FSPGameEndState.AllOtherExit); AddCmdToCurrentFrame(FSPVKeyBase.GAME_END, (int)FSPGameEndState.AllOtherExit); return(true); } // check player connection status for (int i = 0; i < mPlayerList.Count; i++) { FSPPlayer player = mPlayerList[i]; if (player.IsLose()) { mPlayerList.RemoveAt(i); FSPServer.Instance.DelSession(player.Sid); player.Dispose(); --i; } } //check again, if player num is less than 2 if (mPlayerList.Count < 2) { //enter GameEnd state directly SetGameState(FSPGameState.GameEnd, (int)FSPGameEndState.AllOtherLost); AddCmdToCurrentFrame(FSPVKeyBase.GAME_END, (int)FSPGameEndState.AllOtherLost); return(true); } return(false); }