public MapFacade(GameMap map, Tileset tileset) { this.map = map; this.tiles = tileset; structuresModifier = new TilemapModifier(map.structures); groundModifier = new TilemapModifier(map.ground); decorationsModifier = new TilemapModifier(map.decorations); roomRectangleConstructor = new RandomRectangleConstructor(new Vector2Int(MIN_WIDTH, MIN_HEIGHT), new Vector2Int(MAX_WIDTH, MAX_HEIGHT)); globalMapRectangleConstructor = new RandomRectangleConstructor(new Vector2Int(map.sizeX / 3, map.sizeY / 3), new Vector2Int((int)(map.sizeX / 1.2), (int)(map.sizeY / 1.2))); mapOperations = new MapModifier(map); }
// private methods private void CreateVillage(Rect area) { List <Rect> rooms = roomRectangleConstructor.CreateRandomRectanglesInArea(area, DUNGEON_GENERATE_CYCLE); TilemapModifier structuresModifier = new TilemapModifier(map.structures); TilemapModifier groundModifier = new TilemapModifier(map.ground); System.Func <Tileset, TileBase> getStructure = tileset => tileset.GetStructureTile(); System.Func <Tileset, TileBase> getIndoor = tileset => tileset.GetIndoorTile(); foreach (Rect room in rooms) { structuresModifier.MakeRoom(room, getStructure, tiles); groundModifier.FillRect(room, getIndoor, tiles); } }