Exemplo n.º 1
0
    IEnumerator GenerateSteps()
    {
        if (randomPosition)
        {
            startPosition = new Vector2Int(Random.Range(0, size.x), Random.Range(0, size.y));
        }

        var growingTree = new GrowingTree(size, startPosition, nextCandidate);

        growingTree.OnVisit += (pos) =>
        {
            blocks[pos.x, pos.y].sharedMaterial = (startPosition == pos ? startMaterial : candidateMaterial);
        };
        growingTree.OnDeadEnd      += (pos) => blocks[pos.x, pos.y].sharedMaterial = corridorMaterial;
        growingTree.OnCarvePassage += RemoveWall;

        growingTree.Start();
        while (!growingTree.Finished)
        {
            growingTree.Step();
            yield return(stepWait);
        }

        maze                  = growingTree.Maze;
        generator             = null;
        btnWalk.interactable  = true;
        btnStart.interactable = true;
    }
Exemplo n.º 2
0
 public void Setup(Vector3 delta, Vector2Int gridPos, MazeSpec maze, Direction lookingAt, Text compass)
 {
     transform.position = delta + new Vector3(gridPos.x, 0, gridPos.y);
     this.gridPos       = gridPos;
     this.maze          = maze;
     this.lookingAt     = lookingAt;
     this.compass       = compass;
     UpdateCompass();
 }
Exemplo n.º 3
0
 public void Start()
 {
     visited = new bool[size.x, size.y];
     deltas  = new Vector2Int[]
     {
         new Vector2Int(-1, 0),
         new Vector2Int(1, 0),
         new Vector2Int(0, 1),
         new Vector2Int(0, -1),
     };
     neighbours = new List <Vector2Int>();
     candidates = new List <Vector2Int>
     {
         startPosition
     };
     Maze = new MazeSpec(size);
 }