Esempio n. 1
0
 public bool AddPlayer(Player player)
 {
     if (GameMode == GameMode.GUIDED)
     {
         if (GameState == GameState.COUNTDOWN)
         {
             if (PlayersInGame.Count < PlayersLimit)   // pripoji hrača do bežiacej hry
             {
                 PlayersInGame.Add(player);
                 PlayersInLobby.Add(player);
                 player.InGame = true;
                 Map.SpawnPlayer(player);
                 ++PlayersAllive;
                 return(true);
             }
             return(false);
         }
         else     // Lobby
         {
             if (PlayersInLobby.Count < PlayersLimit)
             {
                 PlayersInLobby.Add(player);
                 return(true);
             }
             return(false);
         }
     }
     else     // Player Mode - hraju iba hrači ktory boli pri štarte, ostatny čakaju na skončenie hry
     {
         if (PlayersInLobby.Count < PlayersLimit)
         {
             PlayersInLobby.Add(player);
             if (PlayersInLobby.Count == 1)
             {
                 Creator = player;
             }
             else if (GameState == GameState.LOBBY)
             {
                 FramesToStart /= 2;
             }
             return(true);
         }
         return(false);
     }
 }
Esempio n. 2
0
 public void RemovePlayer(Player player)
 {
     if (player.Spectator)
     {
         return;
     }
     if (GameState != GameState.LOBBY)
     {
         lock (PlayersInGame) PlayersInGame.Remove(player);
         --PlayersAllive;
     }
     PlayersInLobby.Remove(player);
     if (PlayersInLobby.Count >= 1)
     {
         Creator = PlayersInLobby[rnd.Next(0, PlayersInLobby.Count - 1)];
         if (StartTimerRunning)
         {
             FramesToStart *= 2;
         }
     }
     player.InGame = false;
 }