Esempio n. 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);
        }
    }
Esempio n. 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());
    }
Esempio n. 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());
        }
    }
Esempio n. 4
0
 public static Quaternion ToRotation(this DirectionMaze direction)
 {
     return(rotations[(int)direction]);
 }
Esempio n. 5
0
 public static IntVector ToIntVector(this DirectionMaze direction)
 {
     return(vectors[(int)direction]);
 }
Esempio n. 6
0
 public static DirectionMaze GetOpposite(this DirectionMaze direction)
 {
     return(opposites[(int)direction]);
 }
Esempio n. 7
0
 public void SetEdge(DirectionMaze direction, CellEdgeMaze edge)
 {
     edges[(int)direction] = edge;
     initializedEdgeCount += 1;
 }
Esempio n. 8
0
 public CellEdgeMaze GetEdge(DirectionMaze direction)
 {
     return(edges[(int)direction]);
 }