private void LoadLevel(string level) { IMapService mapService = ServiceProvider.GetService <IMapService>(); mapService.LoadMap(level); ServiceProvider.GetService <IPathfinderService>().ClearAreas(); mapService.ForEachLayerTile(l => { if (!l.Animated) { ((IGameEntityFactory)EntityFactory).CreateTile(new Vector2(l.X, l.Y), l.Layer, l.Gid); } else { ((IGameEntityFactory)EntityFactory).CreateAnimatedTile(new Vector2(l.X, l.Y), l.Layer, l.Gids, l.AnimationSpeed); } }); mapService.ForEachObjectGroups(o => { switch (o.Group.ToLower()) { case "gameobjects": LoadGameObject(o); break; case "navmesh": LoadNavPolygon(o); break; default: break; } }); }