//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Excavates between two rooms. </summary> /// /// <remarks> Variables named from the perspective of dir being vertical. Darrellp, 9/18/2011. </remarks> /// /// <param name="map"> The map to be excavated. </param> /// <param name="roomTop"> The first room. </param> /// <param name="roomBottom"> The second room. </param> /// <param name="dir"> The direction to excavate in. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void ExcavateCorridor(IRoomsMap map, RectangularRoom roomTop, RectangularRoom roomBottom, Dir dir) { // Locals MapCoordinates bottomEntrance, topEntrance; // Get the entrances to each room GetEntrances(roomTop, roomBottom, dir, out topEntrance, out bottomEntrance); // Allocate the generic room int genericWidth = Math.Abs(topEntrance.Column - bottomEntrance.Column) + 1; int genericHeight = Math.Abs(topEntrance.Row - bottomEntrance.Row) + 1; int genericLeft = Math.Min(topEntrance.Column, bottomEntrance.Column); int genericBottom = Math.Min(topEntrance.Row, bottomEntrance.Row); MapCoordinates genericLocation = new MapCoordinates(genericLeft, genericBottom); GenericCorridor corridor = new GenericCorridor(genericWidth, genericHeight, genericLocation); // Excavate a connection between the two rooms CreateBend(map, dir, topEntrance, bottomEntrance, corridor); // Put the exits in the appropriate generic rooms GenericRoom groomTop = _mapRoomToGenericRooms[roomTop]; GenericRoom groomBottom = _mapRoomToGenericRooms[roomBottom]; corridor.AddExit(groomTop, topEntrance); corridor.AddExit(groomBottom, bottomEntrance); groomTop.AddExit(corridor, topEntrance); groomBottom.AddExit(corridor, bottomEntrance); // Should we put a door in the top room? if (_rnd.Next(100) < _pctDoorChance) { // Place the door map[topEntrance].Terrain = TerrainType.Door; } // Should we put a door in the bottom room? if (_rnd.Next(100) < _pctDoorChance) { // Place the door map[bottomEntrance].Terrain = TerrainType.Door; } }