AddPlayer() public method

public AddPlayer ( Player player ) : void
player Player
return void
Example #1
0
        public static Game CreateNewGame(int x, int y, params Player[] players)
        {
            var game = new Game(x, y);

            foreach (var player in players)
                game.AddPlayer(player);

            return game;
        }
Example #2
0
        public static Game CreateNewGame(int x, int y, params Player[] players)
        {
            var game = new Game(x, y);

            foreach (var player in players)
            {
                game.AddPlayer(player);
            }

            return(game);
        }
Example #3
0
        public GameConnection TryAddPlayer(GameWebSocketService client, string name)
        {
            lock (gameLock)
            {
                if (Started)
                {
                    return(null);
                }

                clients.Add(client);
                var player = new Player(name);
                game.AddPlayer(player);

                if (clients.Count == config.NumberOfPlayers)
                {
                    StartGame();
                }

                return(new GameConnection(client, player, this));
            }
        }