private List <Corridor> LinkPaths(List <VaultPath> paths, VaultRoom startingRoom) { var corridors = new List <Corridor>(); bool first = true; foreach (var path in paths) { for (int i = 0; i < path.rooms.Count - 1; i++) { if (first && i == path.rooms.Count - 2) { first = false; path.rooms[path.rooms.Count - 1] = new BossRoom(); } var room = path.rooms[i]; var nextRoom = path.rooms[i + 1]; int corridorRoll = RNG.Int(0, 2); var corridor = new Corridor() { connectedRooms = { room, nextRoom } }; corridors.Add(corridor); if (corridorRoll == 0) { corridor.size = 4; } else { corridor.size = RNG.Int(6, 22); } } } int corridorRoll2 = RNG.Int(0, 2); var corridor2 = new Corridor() { connectedRooms = { startingRoom, paths[0].rooms[0] } }; if (corridorRoll2 == 0) { corridor2.size = 4; } else { corridor2.size = RNG.Int(6, 22); } corridors.Add(corridor2); foreach (var path in paths) { if (path == paths[0]) { continue; } AttachRandomly(path, paths, startingRoom, corridors); } return(corridors); }
public List <Room> CreateRooms() { paths = GeneratePaths(); var startingRoom = new VaultRoom(); var roomList = new List <Room> { startingRoom }; while (!PathsAcceptable(paths)) { paths = GeneratePaths(); } var corridors = LinkPaths(paths, startingRoom); var roomList2 = GetRoomsFromPaths(paths, corridors); foreach (var room in roomList2) { roomList.Add(room); } return(roomList); }
private void GenerateRooms() { rooms.Clear(); int roomCount = RNG.Int(1, 15); for (int i = 0; i < roomCount; i++) { var vr = new VaultRoom { floor = 0 }; int encounterRoll = RNG.Int(0, 4); if (encounterRoll > 0) { vr.hasEncounter = true; } if (i == roomCount - 1) { vr.hasTreasure = true; } rooms.Add(vr); } }
public Room ConvertTo() { var output = new VaultRoom { uuid = uuid, size = size, grandiosity = grandiosity, x = x, y = y, floor = floor, xSize = xSize, ySize = ySize }; foreach (var entrance in entrances) { output.entrances.Add(entrance.ConvertTo()); } foreach (var dressingLocation in dressingLocations) { output.dressingLocations.Add(dressingLocation.ConvertTo()); } return(output); }
private void AttachRandomly(VaultPath path, List <VaultPath> paths, VaultRoom startingRoom, List <Corridor> corridors) { int x = RNG.Int(-1, paths.Count); if (paths.Count == 1) { return; } while (x == paths.IndexOf(path)) { x = RNG.Int(-1, paths.Count); } if (x == -1) { AttachToRoom(path, startingRoom, corridors); } else { var attachPath = paths[x]; int y = RNG.Int(0, attachPath.rooms.Count); var attachRoom = attachPath.rooms[y]; AttachToRoom(path, attachRoom, corridors); } }