Inheritance: Location
        public static void CreateDungeons()
        {
            List<MapBlock> blocks = new List<MapBlock>();

            //Collect all the points
            for (int x = 0; x < WORLDSIZE; x++)
            {
                for (int y = 0; y < WORLDSIZE; y++)
                {
                    MapBlock block = GameState.GlobalMap.GetBlockAtCoordinate(new MapCoordinate(x, y, 0, MapType.GLOBAL));

                    var tile = block.Tile as GlobalTile;

                    if (!tile.HasRiver && !tile.IsBlockedForColonisation && !tile.HasResource && tile.Elevation > 0 && tile.Elevation < 250)
                    {
                        blocks.Add(block);
                    }
                }
            }

            //Toss them anywhere
            for (int i = 0; i < DUNGEON_TOTAL; i++)
            {
                int randomNumber = GameState.Random.Next(blocks.Count);

                MapBlock block = blocks[randomNumber];

                //And remove it
                blocks.RemoveAt(randomNumber);

                Dungeon dungeon = new Dungeon();
                dungeon.DifficultyLevel = 1;
                dungeon.Coordinate = new MapCoordinate(block.Tile.Coordinate);

                DungeonItem di = new DungeonItem();
                di.Coordinate = new MapCoordinate(block.Tile.Coordinate);
                di.Dungeon = dungeon;

                block.ForcePutItemOnBlock(di);

                (block.Tile as GlobalTile).IsBlockedForColonisation = true;
            }
        }
        public static MapBlock[,] GenerateDungeonLevel(int level, int percentCovered, out MapCoordinate startPoint, out Actor[] enemies, out Dungeon dungeon)
        {
            startPoint = new MapCoordinate();
            List<Actor> ens = new List<Actor>();
            List<Rectangle> rectangles = null;
            Stack<Rectangle> unusedRectangles = null;
            ItemFactory.ItemFactory fact = new ItemFactory.ItemFactory();
            List<SummoningCircle> summoningCircles = new List<SummoningCircle>();

            int tileID = -1;

            MapBlock[,] map = GenerateBaseMap(level, percentCovered, out rectangles, out tileID);

            //Copy the rectangles
            unusedRectangles = new Stack<Rectangle>();

            foreach (var rectangle in rectangles)
            {
                unusedRectangles.Push(rectangle);
            }

            //Put the tiles

            SummoningCircle dummyCircle = null;

            //Each rectangle is going to contain a room

            //First pick two to be the start and end rooms
            PutRoom(map, tileID, level, DungeonRoomType.ENTRANCE, unusedRectangles.Pop(), out dummyCircle);

            startPoint = new MapCoordinate(rectangles[rectangles.Count - 1].Center.X, rectangles[rectangles.Count - 1].Center.Y, 0, MapType.LOCAL);

            PutRoom(map, tileID, level, DungeonRoomType.EXIT, unusedRectangles.Pop(), out dummyCircle);

            //Then pick d6 + level as summoning rooms. Ensuring they are less than half the rooms
            int summoningRooms = GameState.Random.Next(1, 6) + level;

            summoningRooms = summoningRooms > rectangles.Count / 2 ? rectangles.Count / 2 : summoningRooms;

            for (int i = 0; i < summoningRooms; i++)
            {
                SummoningCircle circle = null;

                PutRoom(map, tileID, level, DungeonRoomType.SUMMONING, unusedRectangles.Pop(), out circle); //Create them

                //Grab references to the summoning circle as we'll need them later

                summoningCircles.Add(circle);
            }

            int treasureRooms = GameState.Random.Next((int)Math.Ceiling((double)(level / 2 > 5 ? 5 : level / 2)));

            if (treasureRooms > unusedRectangles.Count)
            {
                treasureRooms = unusedRectangles.Count - 1;
            }
            else if (treasureRooms < 1)
            {
                treasureRooms = 1; //At least one
            }

            //Create some treasure rooms
            for (int i = 0; i < treasureRooms; i++)
            {
                PutRoom(map, tileID, level, DungeonRoomType.TREASURE, unusedRectangles.Pop(), out dummyCircle);
            }

            //Then we can pick some of the rooms as being the other room types
            List<DungeonRoomType> roomTypes = ((DungeonRoomType[])Enum.GetValues(typeof(DungeonRoomType))).ToList();

            roomTypes.Remove(DungeonRoomType.ENTRANCE);
            roomTypes.Remove(DungeonRoomType.EXIT);

            for(int i=0; i < 7; i++)
            {
                roomTypes.Add(DungeonRoomType.EMPTY);
            }

            //Make the remaining rectangles into rooms

            while (unusedRectangles.Count > 0)
            {
                //Pick a room type at random
                PutRoom(map, tileID, level, roomTypes.GetRandom(), unusedRectangles.Pop(), out dummyCircle);
            }

            //Package it all into a Dungeon object
            dungeon = new Dungeon();
            dungeon.DifficultyLevel = level;
            dungeon.Rooms = rectangles;
            dungeon.SummoningCircles = summoningCircles;
            enemies = ens.ToArray();

            return map;
        }