Stop() 공개 메소드

public Stop ( ) : void
리턴 void
예제 #1
0
 public void RemovePlayer(Player player)
 {
     if (player.Equals(HostPlayer) && State == GameState.Lobby)
     {
         _server.Stop();
     }
     else if (player.Type == (int)PlayerType.Observer)
     {
         Observers.Remove(player);
         if (State == GameState.Lobby)
         {
             GameServerPacket nwatch = new GameServerPacket(StocMessage.HsWatchChange);
             nwatch.Write((short)Observers.Count);
             SendToAll(nwatch);
         }
         player.Disconnect();
     }
     else if (State == GameState.Lobby)
     {
         Players[player.Type] = null;
         IsReady[player.Type] = false;
         GameServerPacket change = new GameServerPacket(StocMessage.HsPlayerChange);
         change.Write((byte)((player.Type << 4) + (int)PlayerChange.Leave));
         SendToAll(change);
         player.Disconnect();
     }
     else
     {
         Surrender(player, 4, true);
     }
 }
예제 #2
0
        public void RemovePlayer(Player player)
        {
            if (player.Equals(HostPlayer) && State == GameState.Lobby)
            {
                bool found = false;
                foreach (Player p in Players)
                {
                    if (p != null && !p.Equals(player))
                    {
                        HostPlayer = p;
                        found      = true;
                        break;
                    }
                }
                if (found)
                {
                    IsReady[HostPlayer.Type] = false;
                    HostPlayer.SendTypeChange();
                }
                else
                {
                    _server.Stop();
                    return;
                }
            }
            if (player.IsRecorder)
            {
                player.Disconnect();
            }
            if (player.Type == (int)PlayerType.Observer)
            {
                Observers.Remove(player);
                if (State == GameState.Lobby)
                {
                    BinaryWriter nwatch = GamePacketFactory.Create(StocMessage.HsWatchChange);
                    nwatch.Write((short)Observers.Count);
                    SendToAll(nwatch);
                }
                player.Disconnect();
            }
            else if (State == GameState.Lobby)
            {
                Players[player.Type] = null;
                IsReady[player.Type] = false;
                BinaryWriter change = GamePacketFactory.Create(StocMessage.HsPlayerChange);
                change.Write((byte)((player.Type << 4) + (int)PlayerChange.Leave));
                SendToAll(change);
                player.Disconnect();
            }
            else
            {
                Surrender(player, 4, true);
            }

            if (OnPlayerLeave != null)
            {
                OnPlayerLeave(this, new PlayerEventArgs(player));
            }
        }