private void CreateRoom(BaseRoom baseRoom) { m_rooms.Add(baseRoom); BaseCell baseCell = null; float randomR = Random.Range(0, 255f) / 255; float randomG = Random.Range(0, 255f) / 255; float randomB = Random.Range(0, 255f) / 255; for (int h = baseRoom.PivotH; h < baseRoom.PivotH + baseRoom.RoomHeight; h++) { for (int w = baseRoom.PivotW; w < baseRoom.PivotW + baseRoom.RoomWidth; w++) { baseCell = new BaseCell(w, h, m_mazeGenerator); baseCell.SetColor(new Color(randomR, randomG, randomB)); #region corner if (w == baseRoom.PivotW && h == baseRoom.PivotH) { baseCell.DisableWalls(Maze.Utils.Direction.Up); baseCell.DisableWalls(Maze.Utils.Direction.Right); continue; } if (w == baseRoom.PivotW && h == baseRoom.PivotH + baseRoom.RoomHeight - 1) { baseCell.DisableWalls(Maze.Utils.Direction.Down); baseCell.DisableWalls(Maze.Utils.Direction.Right); continue; } if (w == baseRoom.PivotW + baseRoom.RoomWidth - 1 && h == baseRoom.PivotH) { baseCell.DisableWalls(Maze.Utils.Direction.Up); baseCell.DisableWalls(Maze.Utils.Direction.Left); continue; } if (w == baseRoom.PivotW + baseRoom.RoomWidth - 1 && h == baseRoom.PivotH + baseRoom.RoomHeight - 1) { baseCell.DisableWalls(Maze.Utils.Direction.Down); baseCell.DisableWalls(Maze.Utils.Direction.Left); continue; } #endregion #region edge if (h == baseRoom.PivotH) { baseCell.DisableWalls(Maze.Utils.Direction.Up); baseCell.DisableWalls(Maze.Utils.Direction.Left); baseCell.DisableWalls(Maze.Utils.Direction.Right); continue; } if (h == baseRoom.PivotH + baseRoom.RoomHeight - 1) { baseCell.DisableWalls(Maze.Utils.Direction.Down); baseCell.DisableWalls(Maze.Utils.Direction.Left); baseCell.DisableWalls(Maze.Utils.Direction.Right); continue; } if (w == baseRoom.PivotW) { baseCell.DisableWalls(Maze.Utils.Direction.Right); baseCell.DisableWalls(Maze.Utils.Direction.Up); baseCell.DisableWalls(Maze.Utils.Direction.Down); continue; } if (w == baseRoom.PivotW + baseRoom.RoomWidth - 1) { baseCell.DisableWalls(Maze.Utils.Direction.Left); baseCell.DisableWalls(Maze.Utils.Direction.Up); baseCell.DisableWalls(Maze.Utils.Direction.Down); continue; } #endregion baseCell.DisableWalls(Maze.Utils.Direction.Up); baseCell.DisableWalls(Maze.Utils.Direction.Down); baseCell.DisableWalls(Maze.Utils.Direction.Left); baseCell.DisableWalls(Maze.Utils.Direction.Right); } } }