private static void GenerateEntrances(List <Data.Room> rooms) { for (int i = 0; i < rooms.Count; i++) { Data.Room room = rooms[i]; room.Entrances = GenerateRoomEntrances(rooms[i].Bounds); rooms[i] = room; } }
private static void SeedRooms(List <Data.Room> rooms, List <RectInt> placeholders) { for (int i = 0; i < Info.Map.NumberOfSeedRooms; i++) { RectInt bounds = GetNewRoomLocation(rooms, placeholders); if (bounds.width == 0 && bounds.height == 0) { continue; } Data.Room room = new Data.Room { Bounds = bounds, GroundType = Type.Ground.Wood, StructureType = Type.Structure.Stone_Wall, }; rooms.Add(room); } }
private static Data.Room ExpandRoom(Data.Room room, List <Data.Room> rooms, List <RectInt> placeholders) { bool expanded = false; Data.Room expandedRoom = room; List <Type.Direction> directions = new List <Type.Direction> { Type.Direction.SS, Type.Direction.NN, Type.Direction.WW, Type.Direction.EE }; while (!expanded && directions.Count > 0) { int index = Random.Range(0, directions.Count - 1); Type.Direction direction = directions[index]; directions.RemoveAt(index); switch (direction) { case Type.Direction.SS: expandedRoom.Bounds.xMin -= 1; break; case Type.Direction.WW: expandedRoom.Bounds.xMax += 1; break; case Type.Direction.NN: expandedRoom.Bounds.yMin -= 1; break; case Type.Direction.EE: expandedRoom.Bounds.yMax += 1; break; } bool roomCollision = false; if (Util.Map.OnMap(expandedRoom.Bounds) == false) { roomCollision = true; } else { foreach (Data.Room testRoom in rooms) { if (testRoom.Equals(room)) { continue; } if (testRoom.Bounds.Overlaps(expandedRoom.Bounds)) { roomCollision = true; } } foreach (RectInt bounds in placeholders) { if (bounds.Overlaps(expandedRoom.Bounds)) { roomCollision = true; } } } if (!roomCollision) { expanded = true; } } return(expanded ? expandedRoom : room); }