public OgmoLevel LoadLevel(string level) { if (!Path.HasExtension(level)) { level = Path.ChangeExtension(level, "json"); } if (LoadedLevels.ContainsKey(level)) { Debug.Warn("You're loading a level that was already loaded. Be careful as its likely to have been disposed if the parent NezContentManager has been disposed inbetween calls."); return(LoadedLevels[level]); } if (LevelNameToFullPath.ContainsKey(level) == false) { throw new System.Exception("You cannot load a level that is not registed to this ogmo project. Try checking the file paths in your project and json files in content."); } var targetFilePath = LevelNameToFullPath[level]; OgmoLevel GameLevel = ParentContentManager.LoadJson(targetFilePath, this, OgmoLevelConverter.Instance); GameLevel.Project = this; GameLevel.FullPath = Path.GetDirectoryName(targetFilePath); GameLevel.Name = level; LoadedLevels.Add(level, GameLevel); return(GameLevel); }
/// <param name="autoEmitEntities"> /// If true, each entity layer will have its entities mapped /// to Ash Entities and instantiated if they implement <c>IOgmoEmittable</c> /// </param> /// <param name="lockCamera"> /// If true, the camera will be bound within the /// level's size, preventing it from viewing outside of it. /// </param> public OgmoScene(OgmoLevel level, bool autoEmitEntities = true, Assembly entityAssembly = null) { CurrentLevel = level; EmittedEntities = ListPool <ECEntity> .Obtain(); var map = CreateEntity("Map"); LevelRenderer = map.AddComponent(new OgmoRenderer(CurrentLevel)); LockCameraToLevelBounds = false; LockCameraToZoomPixels = false; OverrideAssembly = entityAssembly; if (autoEmitEntities) { EmitEntities(); } }