Пример #1
0
        /// <summary>
        /// This method will create a new maze for the multiplayer mode
        /// </summary>
        /// <param name="name">Name of the Maze</param>
        /// <returns>A new general Maze</returns>
        public GeneralMaze <int> CreateMultiMaze(string name)
        {
            _2DMaze <int>     newMaze = new _2DMaze <int>(HIEGHT, WIDTH);
            GeneralMaze <int> newGM   = new GeneralMaze <int>(newMaze);
            Random            rand    = new Random();
            int    type     = rand.Next(0, 2);
            string mazeName = name + "_1";

            newGM.Generate(mazeName, type);
            return(newGM);
        }
Пример #2
0
        /// <summary>
        /// THis method will create a new Game if the game doesn't
        /// already exist </summary>
        /// <param name="gameName">The Name of the game</param>
        /// <param name="player">The first PLayer</param>
        public void CreateNewGame(string gameName, Player player)
        {
            GeneralMaze <int> newMaze = CreateMultiMaze(gameName);

            this.mazeList.Add(newMaze.Name, newMaze);
            Game newGame = new Game(newMaze, gameName);

            newGame.AssignPlayerToGame(player);
            games.Add(newGame);
            player.SetPlayerMaze(newMaze);
            player.MazeName = player.GetPlayerMaze().Name;
            player.You      = player.GetPlayerMaze();
        }
Пример #3
0
        /// <summary>
        /// Generate a new maze </summary>
        /// <param Name="name">Name of the the new maze</param>
        /// <param Name="type">The type of the new maze</param>
        public void GenerateMaze(string name, int type)
        {
            int               height = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["HEIGHT"]);
            int               width  = Int32.Parse(System.Configuration.ConfigurationManager.AppSettings["WIDTH"]);
            _2DMaze <int>     maze   = new _2DMaze <int>(height, width);
            GeneralMaze <int> cMaze  = new GeneralMaze <int>(maze);

            cMaze.Generate(name, type);
            this.gMa = cMaze;

            JavaScriptSerializer ser = new JavaScriptSerializer();
            string jsonMaze          = ser.Serialize(cMaze);

            jsonMaze = JToken.Parse(jsonMaze).ToString();
            File.WriteAllText(name + ".json", jsonMaze);

            this.JSONMaze = jsonMaze;
            PublishEvent();
        }