Пример #1
0
        /// <summary>
        /// Creates the maze.
        /// </summary>
        private void CreateMaze()
        {
            // Generate the maze
            var mazeGenerator = new MazeGenerator2 {
                Width = 21, Height = 31
            };

            this.maze = mazeGenerator.Generate();

            // Solve the maze
            var solver   = new MazeSolver1();
            var start    = new Cell(1, 1);
            var end      = new Cell(this.maze.GetLength(0) - 2, this.maze.GetLength(1) - 2);
            var solution = solver.Solve(this.maze, start, end);

            int m = this.maze.GetUpperBound(0) + 1;
            int n = this.maze.GetUpperBound(1) + 1;

            this.offsetX = -m * 0.5;
            this.offsetY = -n * 0.5;

            this.WallsGeometry    = this.CreateMazeGeometry(this.maze);
            this.GroundGeometry   = this.CreateGroundGeometry(this.maze, 1, -0.005);
            this.SolutionGeometry = this.CreateSolutionGeometry(solution);
        }
Пример #2
0
        /// <summary>
        /// Creates the maze.
        /// </summary>
        private void CreateMaze()
        {
            // Generate the maze
            var mazeGenerator = new MazeGenerator2 { Width = 21, Height = 31 };
            this.maze = mazeGenerator.Generate();

            // Solve the maze
            var solver = new MazeSolver1();
            var start = new Cell(1, 1);
            var end = new Cell(this.maze.GetLength(0) - 2, this.maze.GetLength(1) - 2);
            var solution = solver.Solve(this.maze, start, end);

            int m = this.maze.GetUpperBound(0) + 1;
            int n = this.maze.GetUpperBound(1) + 1;
            this.offsetX = -m * 0.5;
            this.offsetY = -n * 0.5;

            this.WallsGeometry = this.CreateMazeGeometry(this.maze);
            this.GroundGeometry = this.CreateGroundGeometry(this.maze, 1, -0.005);
            this.SolutionGeometry = this.CreateSolutionGeometry(solution);
        }