/// <summary>
 /// Gets the range for the number of rooms.</summary>
 /// <returns>Returns the possible range of the number of rooms.</returns>
 public static Range GetRangeOfNumberOfRooms()
 {
     XmlNode dungeonValues = doc.SelectSingleNode("//mapGenValues/dungeonValues");
     int minimumRooms = XmlConvert.ToInt32(dungeonValues["minNumberOfRooms"].InnerText);
     int maximumRooms = XmlConvert.ToInt32(dungeonValues["maxNumberOfRooms"].InnerText);
     Range roomRange = new Range(minimumRooms, maximumRooms);
     return roomRange;
 }
 /// <summary>
 /// Gets the range for room sizes.</summary>
 /// <returns>A tuple containing the domain and range of a rooms possible 
 ///          dimensions.</returns>
 public static Tuple<Range, Range> GetRoomSizeRange()
 {
     XmlNode dungeonValues = doc.SelectSingleNode("//mapGenValues/dungeonValues");
     int minimumRoomWidth = XmlConvert.ToInt32(dungeonValues["minRoomWidth"].InnerText);
     int maximumRoomWidth = XmlConvert.ToInt32(dungeonValues["maxRoomWidth"].InnerText);
     int minimumRoomHeight = XmlConvert.ToInt32(dungeonValues["minRoomHeight"].InnerText);
     int maximumRoomHeight = XmlConvert.ToInt32(dungeonValues["maxRoomHeight"].InnerText);
     Range width = new Range(minimumRoomWidth, maximumRoomWidth);
     Range height = new Range(minimumRoomHeight, maximumRoomHeight);
     Tuple<Range, Range> roomDimensions = new Tuple<Range, Range>(width, height);
     return roomDimensions;
 }
        /// <summary>
        /// Gets a dictionary of room styles and their spawn chance.</summary>
        /// <returns>Style Dictionary {Range; string}</returns>
        public static Dictionary<Range, string> GetStylesDict()
        {
            XmlNode styles = doc.SelectSingleNode("//mapGenValues/RoomStyles");
            Dictionary<Range, string> styleSpawnDict = new Dictionary<Range, string>();

            foreach (XmlNode node in styles.ChildNodes)
            {
                // Get values and add the style to the styleSpawnDict.
                int styleMinChance = XmlConvert.ToInt32(node["minChance"].InnerText);
                int styleMaxChance = XmlConvert.ToInt32(node["maxChance"].InnerText);
                Range styleSpawnChance = new Range(styleMinChance, styleMaxChance);
                string styleName = node.Attributes["name"].Value;
                styleSpawnDict.Add(styleSpawnChance, styleName);
            }
            return styleSpawnDict;
        }
        /// <summary>
        /// Creates and furnishes a randomly generated room.</summary>
        /// <returns>Returns a finished room.</returns>
        private static Room RoomBuilder(List<Room> generatedRooms, bool allowIntersections = false)
        {
            // Choose a random roomWidth and height based on values from the parser.
            Range potentialRoomWidth = MapParser.GetPotentialRoomDimension(Act, "width");
            Range potentialRoomHeight = MapParser.GetPotentialRoomDimension(Act, "height");

            int roomWidth = RNG.Next((int)potentialRoomWidth.min, (int)potentialRoomWidth.max + 1);
            int roomHeight = RNG.Next((int)potentialRoomHeight.min, (int)potentialRoomHeight.max + 1);

            // Choose a random position inside the maps boundaries and create the room there.
            var mapDimensions = new Range(DungeonLayout.Count - 1, DungeonLayout[0].Count - 1);
            int roomPosX = RNG.Next(0, (int)mapDimensions.min - roomWidth + 1);
            int roomPosY = RNG.Next(0, (int)mapDimensions.max - roomHeight + 1);
            var newRoom = new Room(roomPosX, roomPosY, roomWidth, roomHeight);

            // Run through the other generatedRooms and see if they Intersect with this one
            if (!allowIntersections) {
                foreach (Room otherRoom in generatedRooms)
                    // If this room intersects, discard it.
                    if (newRoom.Intersect(otherRoom))
                        return null;
            }
            RoomStyler(newRoom);
            RoomTiler(newRoom);
            RoomFurnisher(newRoom);
            return newRoom;
        }
 /// <summary>
 /// Returns a dict of the given RoomStyles possible tile types.</summary>
 /// <param name="roomStyle">The style of the room whose tiles we are getting.</param>
 /// <returns>The dictionary of information about the contained tiles.</returns>
 public static Dictionary<Range, int> GetTilerDict(string roomStyle)
 {
     XmlNode tilesNode = doc.SelectSingleNode(
         String.Format("//mapGenValues/RoomStyles/style[@name='{0}']/tileTypes",
         roomStyle));
     Dictionary<Range, int> tilerDict = new Dictionary<Range, int>();
     foreach (XmlNode node in tilesNode.ChildNodes)
     {
         int tileMinChance = XmlConvert.ToInt32(node.Attributes["mapInt"].Value);
         int tileMaxChance = XmlConvert.ToInt32(node["maxChance"].InnerText);
         int mapInt = XmlConvert.ToInt32(node["minChance"].InnerText);
         Range tileSpawnChance = new Range(tileMinChance, tileMaxChance);
         tilerDict.Add(tileSpawnChance, mapInt);
     }
     return tilerDict;
 }