Ejemplo n.º 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);
        }
Ejemplo n.º 2
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();
        }