private RoomBlock GetRandomRoom(int northSpace, int eastSpace, int southSpace, int westSpace, RoomBlock.Direction d) { RoomBlock roomBlock = new RoomBlock(); int rng; bool boss = false; //need a way to say stop generating along this chain when it gets too long //also need a way to check if you are generating next to a room //so the rooms can generate with appropriate doors and also tell //the adjacent room that this one is now next to it if (!placedBossRoom && currentRoom.distFromCore == bossRoomDistFromCore - 1) { rng = Random.Range(0, bossRooms.Count); roomBlock = bossRooms[rng]; boss = true; } //randomly chooses a room from this areas list of rooms else { rng = Random.Range(0, rooms.Count); roomBlock = rooms[rng]; } //Quadratically probes the list of rooms if the one selected does not meet the requirments for the space int n = 0; while ((roomBlock.Dimentions.n > northSpace || roomBlock.Dimentions.e > eastSpace || //checks if the room can fit roomBlock.Dimentions.s > southSpace || roomBlock.Dimentions.w > westSpace) && //within the avalible space and roomBlock.HasDoorHere(d)) //it has a door that can connect { n++; if (boss) { int nRNG = rng + (n * n); //if this is checking for boss rooms while (nRNG > bossRooms.Count) { nRNG -= bossRooms.Count; } //it will loop through the boss rooms quadratically roomBlock = bossRooms[nRNG]; //looking for a suitable room placedBossRoom = true; } else { int newRNG = rng + (n * n); while (newRNG > rooms.Count) { newRNG -= rooms.Count; } roomBlock = rooms[newRNG]; } } return(roomBlock); }