public static PrimsMazeGenerator instance;    //The Singleton instance.

    private void Awake()
    {
        //Make sure there is only one maze generator.
        if (instance == null)
        {
            instance = this;
        }
    }
Example #2
0
        private static Tuple <int, int> NextMaze(int width, int height)
        {
            var maze = new PrimsMazeGenerator(width, height).GenerateMaze();

            maze.ExploreTimeout = -1;

            var leftExplorer  = new LeftHandExplorer();
            var rightExplorer = new RightHandExplorer();

            maze.Explorers.Add(leftExplorer);
            maze.Explorers.Add(rightExplorer);

            maze.FullExplore();
            return(new Tuple <int, int>(leftExplorer.MovementCount, rightExplorer.MovementCount));
        }
Example #3
0
    //creates 3d structure of a maze
    private void InitMaze()
    {
        transform.position = new Vector3(0, 0, 0); //set maze position to the origine

        mazeCells = new MazeCell[mazeHeight][, ];

        // i follows x axis
        // j follows z axis
        for (int t = 0; t < mazeHeight; t++)
        {
            mazeCells[t] = new MazeCell[mazeSize, mazeSize]; //initialize a floor

            //instantiate each cell on a floor.
            for (int i = 0; i < mazeSize; i++)
            {
                for (int j = 0; j < mazeSize; j++)
                {
                    mazeCells[t][i, j]             = new MazeCell();
                    mazeCells[t][i, j].coordinates = new Vector3Int(i, t, j);
                }
            }

            PrimsMazeGenerator.run(mazeCells[t], mazeSize); //create the maze.

            for (int i = 0; i < mazeSize; i++)
            {
                for (int j = 0; j < mazeSize; j++)
                {
                    mazeCells[t][i, j].visited = false;
                }
            } //reset all visited to false, for BFS
        }



        InitializeCollider();
    }