private void LoadLevel(MiMapLevelConfig config) { var levelMap = new LevelMap(this, config); _levelMaps.Add(config.LevelId, levelMap); Log.InfoFormat("Loaded Level {0}", config.LevelId); }
public LevelMap(MiMapManager miMapManager, MiMapLevelConfig config) { MiMapManager = miMapManager; Config = config; Meta = new LevelMeta() { Id = config.LevelId, Name = string.IsNullOrEmpty(config.Label) ? config.LevelId : config.Label, MinZoom = config.MinZoom, MaxZoom = config.MaxZoom, TileSize = new Size(config.TileSize, config.TileSize), Size = new Size(), Bounds = new BlockBounds(new BlockPosition(0, 0), new BlockPosition(0, 0)), LastUpdate = DateTime.MinValue }; BlockBounds = new BlockBounds(new BlockPosition(0, 0), new BlockPosition(0, 0)); TilesDirectory = Path.Combine(MiMapManager.Config.TilesDirectory, config.LevelId); _metaPath = Path.Combine(TilesDirectory, "meta.json"); #if DEBUG if (Directory.Exists(TilesDirectory)) { try { Directory.Delete(TilesDirectory, true); } catch { } } #endif Directory.CreateDirectory(TilesDirectory); _layers = new MapLayer[config.Layers.Length + 1]; var baseLayer = new MapLayer(this, new MiMapLevelLayerConfig() { LayerId = "base", BlendMode = BlendMode.Normal, Default = config.Enabled, Enabled = config.Enabled, Label = config.Label, Renderer = config.Renderer }); baseLayer.OnTileUpdated += (s, e) => OnTileUpdated?.Invoke(s, e); var i = 0; _layers[i] = baseLayer; i++; foreach (var layer in config.Layers) { //Log.InfoFormat("Loading Overlay layer {0} {1}/{2}", layer, i, _layers.Length); var overlayerLayer = new MapLayer(this, layer); overlayerLayer.OnTileUpdated += (s, e) => OnTileUpdated?.Invoke(s, e); _layers[i] = overlayerLayer; i++; } _timer = new Timer(SaveLayers); }