Esempio n. 1
0
        /*
         * StartGame creates a new multiplayer game, generating the maze and registering
         * the client to the game
         */
        public void StartGame(string name, int rows, int cols, string user)
        {
            Maze baseMaze = mazeMaker.Generate(rows, cols);

            baseMaze.Name = name;
            SearchableMaze      maze    = new SearchableMaze(baseMaze, baseMaze.Name);
            MultiplayerMazeGame oneGame = new MultiplayerMazeGame(maze);

            oneGame.SendMessageEvent += UpdateClientEvent;

            // We add the player to the game we just created
            oneGame.AddPlayer(user);
            // We place the maze into our database
            multiplayerMazes[name] = oneGame;

            playerToGameMap[user] = oneGame;
        }
Esempio n. 2
0
 /*
  * This command cancels a multiplayer game
  */
 public bool CancelGame(string player)
 {
     if (!playerToGameMap.ContainsKey(player))
     {
         return(false);
     }
     else
     {
         MultiplayerMazeGame game = playerToGameMap[player];
         // We remove the game from the list of games
         multiplayerMazes.Remove(game.name);
         // We remove the players from the list of players
         playerToGameMap.Remove(game.GetOtherPlayer(player));
         playerToGameMap.Remove(player);
         // We cancel the game
         game.CancelGame(player);
         return(true);
     }
 }