void GenerateRooms(Room room, Vector3Int pos, int depth) { depth++; //keeps track of distance from origin amount++; //total number of rooms RoomInformation info = room.roomInformation; //information about which sides are open Room newRoom; //the object to be instantiated, changes for each side //loop each side for (int i = 0; i < 4; i++) { //side from index RoomSide side = RoomInformation.GetSide(i); if (info.sideOpen(side)) { //accessing inverse list to find room that will fit int index = InverseIndex(i); newRoom = sideRooms[index][Random.Range(0, counts[index])]; HandleSide(pos, side, newRoom, depth); } } }
void finalPass() { foreach (Room room in generatedRooms) { Transform thisRoom = room.transform; Vector3Int roomPosition = Vector3Int.RoundToInt(thisRoom.position); for (int i = 0; i < 4; i++) { Vector3Int testPosition = roomPosition + offsets[i]; RoomSide side = RoomInformation.GetSide(i); //******PLACING GRASS****** GameObject testObject = GetRoom(testPosition); if (!testObject) { CreateGrass(testPosition); } //******PLACING DOORS****** testObject = GetRoom(testPosition); //Debug.Log(room.gameObject + " " + testObject.gameObject + " this open: " + room.roomInformation.sideOpen(side) + " other open: " + !testObject.GetComponent<Room>().roomInformation.invSideOpen(side)); if (room.roomInformation.sideOpen(side)) { if (!testObject.GetComponent <Room>().roomInformation.invSideOpen(side)) { CreateDoor(thisRoom, side); } } //******PLACING GRASS CORNERS****** Vector3Int cornerPosition = roomPosition + corners[i]; if (!GetRoom(cornerPosition)) { CreateGrass(cornerPosition); } } } }
void FindRooms() { thisRoom = GetComponent <Room>(); //making sure origin is on list to be post processed generatedRooms.Add(thisRoom); foreach (Room room in rooms) { RoomInformation currentInfo = room.roomInformation; for (int i = 0; i < 4; i++) { sideRooms.Add(new List <Room>()); if (currentInfo.sideOpen(RoomInformation.GetSide(i))) { sideRooms[i].Add(room); counts[i]++; } } } }