Exemple #1
0
        ///<summary>GameLobbtInstance Constructor</summary>
        ///<param name="lobbyID">The lobbys unique ID</param>
        ///<param name="lobbyLeader">The client that created the lobby</param>
        public GameLobbyInstance(int lobbyID, GameClientInstance lobbyLeader)
        {
            PlayerCount = 1;
            UID         = lobbyID;
            Name        = lobbyLeader.UserName + "'s lobby";
            IsFull      = false;

            playersInLobby = new List <GameClientInstance>();
            playersInLobby.Add(lobbyLeader);
        }
Exemple #2
0
        ///<summary>Add a player to the lobby, if the server is not full. If adding a player would make the server full, then set
        ///"IsFull" to true. Increment playerCount by 1.</summary>
        ///<param name="player">Client to add to the lobby</param>
        public void AddPlayer(GameClientInstance player)
        {
            if (!IsFull)
            {
                playersInLobby.Add(player);
                PlayerCount++;

                if (PlayerCount == (GameServer.MaxPlayers / 4))
                {
                    IsFull = true;
                }
            }
        }
Exemple #3
0
        ///<summary>Remove a player from the lobby. If the lobby becomes empty, remove this lobby from the lobby list and dispose this.</summary>
        ///<param name="player">Client to remove from the lobby</param>
        ///<remarks> This function sends a "LobbyList" packet.</remarks>
        public void RemovePlayer(GameClientInstance player)
        {
            if (playersInLobby.Contains(player))
            {
                playersInLobby.Remove(player);
                PlayerCount--;

                IsFull = false;
            }

            if (PlayerCount == 0)
            {
                GameServer.openLobbies.Remove(UID);

                Console.WriteLine(Name + Constants.LOBBY_CLOSED);

                PacketSend.LobbyList();
            }
        }