コード例 #1
0
ファイル: Maze.cs プロジェクト: Dev-Awesome/aguaribay
    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;
    }
コード例 #2
0
ファイル: Movement.cs プロジェクト: Dev-Awesome/aguaribay
 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();
 }
コード例 #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);
 }