예제 #1
0
        private void DoNextGenerationStep(List <MazeCell> activeCells)
        {
            int      currentIndex = activeCells.Count - 1;
            MazeCell currentCell  = activeCells[currentIndex];

            if (currentCell.IsFullyInitialized)
            {
                activeCells.RemoveAt(currentIndex);
                return;
            }
            MazeDirection direction   = currentCell.RandomUninitializedDirection;
            IntVector2    coordinates = currentCell.coordinates + direction.ToIntVector2();

            if (ContainsCoordinates(coordinates))
            {
                MazeCell neighbor = GetCell(coordinates);
                if (neighbor == null)
                {
                    neighbor = CreateCell(coordinates);
                    CreatePassage(currentCell, neighbor, direction);
                    activeCells.Add(neighbor);
                }
                else if (currentCell.room.settingsIndex == neighbor.room.settingsIndex)
                {
                    CreatePassageInSameRoom(currentCell, neighbor, direction);
                }
                else
                {
                    CreateWall(currentCell, neighbor, direction);
                }
            }
            else
            {
                CreateWall(currentCell, null, direction);
            }
        }
예제 #2
0
 public override void Initialize(MazeCell cell, MazeCell otherCell, MazeDirection direction)
 {
     base.Initialize(cell, otherCell, direction);
     wall.GetComponent <Renderer>().material = cell.room.settings.wallMaterial;
 }
예제 #3
0
 public void Add(MazeCell cell)
 {
     cell.room = this;
     cells.Add(cell);
 }
예제 #4
0
 private static MazeCell GetNeighborCellInDirection(MazeCell cell, MazeDirection direction)
 {
     return(GetCell(cell.GetX() + MazeDirections.ToIntVector2(direction).x,
                    cell.GetY() + MazeDirections.ToIntVector2(direction).y));
 }