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