コード例 #1
0
    private void NextStep(List <CellMaze> activeCells)
    {
        int      currentIndex = activeCells.Count - 1;
        CellMaze currentCell  = activeCells[currentIndex];

        if (currentCell.IsFullyInitialized)
        {
            activeCells.RemoveAt(currentIndex);
            return;
        }
        DirectionMaze direction   = currentCell.RandomUninitializedDirection;
        IntVector     coordinates = currentCell.coordinates + direction.ToIntVector();

        if (ContainsCoordinates(coordinates))
        {
            CellMaze neighbor = GetCell(coordinates);
            if (neighbor == null)
            {
                neighbor = CreateCell(coordinates);
                CreatePassage(currentCell, neighbor, direction);
                activeCells.Add(neighbor);
            }
            else
            {
                CreateWall(currentCell, neighbor, direction);
            }
        }
        else
        {
            CreateWall(currentCell, null, direction);
        }
    }
コード例 #2
0
    private void CreatePassage(CellMaze cell, CellMaze otherCell, DirectionMaze direction)
    {
        PassageMaze passage = Instantiate(passagePrefab) as PassageMaze;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(passagePrefab) as PassageMaze;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
    }
コード例 #3
0
    private void CreateWall(CellMaze cell, CellMaze otherCell, DirectionMaze direction)
    {
        WallMaze wall = Instantiate(wallPrefab) as WallMaze;

        wall.Initialize(cell, otherCell, direction);
        if (otherCell != null)
        {
            wall = Instantiate(wallPrefab) as WallMaze;
            wall.Initialize(otherCell, cell, direction.GetOpposite());
        }
    }
コード例 #4
0
 public static Quaternion ToRotation(this DirectionMaze direction)
 {
     return(rotations[(int)direction]);
 }
コード例 #5
0
 public static IntVector ToIntVector(this DirectionMaze direction)
 {
     return(vectors[(int)direction]);
 }
コード例 #6
0
 public static DirectionMaze GetOpposite(this DirectionMaze direction)
 {
     return(opposites[(int)direction]);
 }
コード例 #7
0
 public void SetEdge(DirectionMaze direction, CellEdgeMaze edge)
 {
     edges[(int)direction] = edge;
     initializedEdgeCount += 1;
 }
コード例 #8
0
 public CellEdgeMaze GetEdge(DirectionMaze direction)
 {
     return(edges[(int)direction]);
 }