예제 #1
0
    public void Begin()
    {
        // Reset all the values
        delay             = 0;
        mazeGridGenerator = null;
        playerSpawner     = null;
        currentCell       = null;
        cells             = new Dictionary <GameObject, Cell>();
        walls             = new List <GameObject>();

        mazeGridGenerator = GetComponent <MazeGridGenerator>();
        playerSpawner     = GetComponent <PlayerSpawner>();

        delay = MazeInput.Instance.Delay;
        cells = mazeGridGenerator.MazeCells;

        foreach (KeyValuePair <GameObject, Cell> pair in cells)
        {
            // We also need to inject the dictionary with all the cells into every cell to find neighbours
            cells[pair.Key].MazeCells = cells;
        }

        // Start generating the maze
        if (currentSolve != null)
        {
            StopCoroutine(currentSolve);
        }

        currentSolve = SolveMaze(delay);
        StartCoroutine(currentSolve);
    }
예제 #2
0
    public void Begin()
    {
        // Reset all the values
        delay             = 0;
        mazeGridGenerator = null;
        playerSpawner     = null;
        currentCell       = null;
        newStartCell      = null;
        directedCells     = new Dictionary <GameObject, Direction>();
        remaining         = new List <GameObject>();
        foundMaze         = false;

        mazeGridGenerator = GetComponent <MazeGridGenerator>();
        playerSpawner     = GetComponent <PlayerSpawner>();

        delay = MazeInput.Instance.Delay;

        foreach (KeyValuePair <GameObject, Cell> pair in mazeGridGenerator.MazeCells)
        {
            // We need to add all the cells into the remaining list to loop through
            remaining.Add(mazeGridGenerator.MazeCells[pair.Key].gameObject);
        }

        // Start generating the maze
        if (currentSolve != null)
        {
            StopCoroutine(currentSolve);
        }

        currentSolve = SolveMaze(delay);
        StartCoroutine(currentSolve);
    }
예제 #3
0
 private void Awake()
 {
     mazeGridGenerator = GetComponent <MazeGridGenerator>();
     mazeGenerator     = GetComponent <MazeGenerator>();
 }