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 { CreateWall(currentCell, neighbor, direction); } } else { CreateWall(currentCell, null, direction); } }
void DoNextGenerationStep(List <MazeCell> _activeCells) { // newest cell index int currentIndex = ChooseIndex(_activeCells.Count); MazeCell currentCell = _activeCells [currentIndex]; if (currentCell.isFullyInitialized()) { _activeCells.RemoveAt(currentIndex); return; } IntVector2 currentCoords = currentCell.coordinates; mazeDirection nextDirection = currentCell.RandomUninitializedDirection; IntVector2 nextCellCoords = currentCoords + nextDirection.ToIntVector2(); if (isCoordInRange(nextCellCoords)) { MazeCell neighbourCell = GetCell(nextCellCoords); // Check if cell already or not if (neighbourCell == null) { // i.e. cell doesn't exists neighbourCell = CreateCell(nextCellCoords); CreatePassage(currentCell, neighbourCell, nextDirection); _activeCells.Add(neighbourCell); } else if (currentCell.room == neighbourCell.room && expandRooms) { CreatePassageInSameRoom(currentCell, neighbourCell, nextDirection); } else { CreateWall(currentCell, neighbourCell, nextDirection); } } else { //Create wall CreateWall(currentCell, null, nextDirection); } }