Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Maze maze = new Maze(5, 5);

            maze.Show();
        }
Ejemplo n.º 2
0
        private void ButtonGenerate_Click(object sender, EventArgs e)
        {
            //Grid details setup
            //---------------------------------------------//
            //Get weight
            if (Int32.TryParse(boxWidth.Text, out int newWidth))
            {
                Settings.MazeWidth = newWidth;
            }
            else
            {
                Console.WriteLine("Using default width value.");
            }

            //Get height
            if (Int32.TryParse(boxHeight.Text, out int newHeight))
            {
                Settings.MazeHeight = newHeight;
            }
            else
            {
                Console.WriteLine("Using default height value.");
            }

            //Get cell size
            if (Int32.TryParse(boxCell.Text, out int newCell))
            {
                Settings.CellSize = newCell;
            }
            else
            {
                Console.WriteLine("Using default cell value.");
            }

            //Get grid colour
            if (boxGridColour.Text != "")
            {
                Settings.GridColour = Color.FromName(boxGridColour.Text);
            }

            //Start point setup
            //---------------------------------------------//
            //Height of start point
            int tempStartH = -1;

            if (Int32.TryParse(boxStartH.Text, out int newStartH))
            {
                if (newStartH > 0 && newStartH < Settings.MazeHeight)
                {
                    tempStartH = newStartH;
                }
            }

            //Width of start point
            if (Int32.TryParse(boxStartW.Text, out int newStartW))
            {
                if (newStartW > 0 && newStartW < Settings.MazeWidth && tempStartH != -1)
                {
                    Settings.StartPoint = new Point(tempStartH, newStartW);
                }
            }

            if (boxStartColour.Text != "")
            {
                Settings.StartPointColour = Color.FromName(boxStartColour.Text);
            }
            //End point setup
            //---------------------------------------------//
            //Height of end point
            int tempEndH = -1;

            if (Int32.TryParse(boxEndH.Text, out int newEndH))
            {
                if (newEndH > 0 && newEndH < Settings.MazeHeight)
                {
                    tempEndH = newEndH;
                }
            }

            //Width of end point
            if (Int32.TryParse(boxEndW.Text, out int newEndW))
            {
                if (newEndW > 0 && newEndW < Settings.MazeWidth && tempEndH != -1)
                {
                    Settings.EndPoint = new Point(tempEndH, newEndW);
                }
            }

            if (boxEndColour.Text != "")
            {
                Settings.EndPointColour = Color.FromName(boxEndColour.Text);
            }
            //Generate Maze
            //---------------------------------------------//
            Maze formMaze = new Maze();

            formMaze.Show();
        }