private void OnMouseLeftDown(object e) { MouseButtonEventArgs args = (MouseButtonEventArgs)e; if (args.ClickCount == 2) { //Double click if (Asset is CEntityAsset <CEntity> entityAsset) { var tool = CWorkspace.Instance.GetTool <CEntityBuilderViewModel>(); tool.OpenAsset(entityAsset); } else if (Asset is CKlaxScriptInterfaceAsset interfaceAsset) { var interfaceEditor = CWorkspace.Instance.GetTool <CInterfaceEditorViewmodel>(); interfaceEditor.OpenAsset(interfaceAsset); } else if (Asset is CLevelAsset levelAsset) { CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { Stopwatch timer = new Stopwatch(); timer.Start(); CLevel newLevel = levelAsset.GetLevel(); timer.Stop(); LogUtility.Log("Level deserialize took {0} ms", timer.Elapsed.TotalMilliseconds); CEngine.Instance.CurrentWorld.ChangeLevel(levelAsset, newLevel); }); } } }
/// <summary> /// Draw all entities in the world /// </summary> public void Draw(SpriteBatch batcher, GameTime gameTime) { CLevel.Draw(batcher); foreach (var entity in Entities) { entity.Draw(batcher, gameTime); } }
/// <summary> /// Creates a new level asset from the given level and register it in the asset registry /// </summary> /// <param name="level">Level to save in this asset</param> /// <param name="name">Name of the asset</param> /// <param name="assetPath">Path to save the asset</param> /// <param name="bAlwaysCreateNewAsset">If true always create a new asset even if in the target path an asset with the same name exists</param> public CLevelAsset(CLevel level, string name, string assetPath, bool bAlwaysCreateNewAsset = true) { Name = name; m_levelJson = CEntitySerializer.Instance.Serialize(level); if (CAssetRegistry.Instance.RequestRegisterAsset(this, assetPath, out CLevelAsset existingAsset, bAlwaysCreateNewAsset)) { existingAsset.WaitUntilLoaded(); base.CopyFrom(existingAsset); m_levelJson = existingAsset.m_levelJson; }
public void HandleDrop(object dropData) { CLevelAsset levelAsset = (CLevelAsset)dropData; Stopwatch timer = new Stopwatch(); timer.Start(); CLevel newLevel = levelAsset.GetLevel(); timer.Stop(); LogUtility.Log("Level deserialize took {0} ms", timer.Elapsed.TotalMilliseconds); CEngine.Instance.CurrentWorld.ChangeLevel(levelAsset, newLevel); }
/// <summary> /// Init CSoundEngine, CLevel, the screen size and CCamera /// </summary> public void Init() { m_SoundEngine = new CSoundEngine(); m_SoundEngine.Init(); m_SoundEngine.LoadBank(soundbankName); m_Level = new CLevel(); m_Level.Init(); m_nScreenWidth = 1024; m_nScreenHeight = 768; m_Camera = new CCamera(); m_Camera.Init(); }
public void Unload() { if (SSources != null) { SSources.Clear(); } if (CLights != null) { CLights.Clear(); } if (CLevel != null) { CLevel.Dispose(); } }
/// <summary> /// Create a new level asset from the given level, the asset will not be registered in the asset registry /// </summary> /// <param name="level"></param> /// <param name="name"></param> public CLevelAsset(CLevel level, string name) { Name = name; m_levelJson = CEntitySerializer.Instance.Serialize(level); IsLoaded = true; }
public void Update(Vector2 position, int pos, int FWidthHalf) { CLevel.LayersLookAt(position); CLevel.LayersUpdate(pos, FWidthHalf); }
public void UpdateScale(float scale, Vector2 origin, Viewport viewport) { CLevel.LayersUpdateScale(scale); CLevel.LayersUpdateCameras(origin, viewport); }
/// <summary> /// /// </summary> public void LoadLevel(LevelNames lvl) { CLevel.Initialize(Services.PLManager.NLevels[(int)lvl], Services.LManager); }
/// <summary> /// /// </summary> public void EndDrawLastLayer(SpriteBatch batcher) { CLevel.EndDrawSpecificLayer(batcher); }
/// <summary> /// /// </summary> public void DrawSpecific(SpriteBatch batcher, Vector2 limits, LevelState states, LevelState stoplvlState) { CLevel.DrawSpecificLayers(batcher, limits, states, stoplvlState); }
public override int Run(string[] remainingArguments) { if (CLevel.ToLower() == "default") { if (Operation.ToLower() == "get") { if (String.IsNullOrEmpty(Service)) { Console.WriteLine("Showing results for -> default:all\n\n{0}", DefaultConfig.GetSettings("all")); } else { if (String.IsNullOrEmpty(Field)) { Console.WriteLine("Showing results for -> defaults:{0}\n\n{1}", Service, DefaultConfig.GetSettings(Service)); } else { Console.WriteLine("Showing results for -> default:{0}= {1}", Field, DefaultConfig.GetSettings(Service, Field)); } } } else if (Operation.ToLower() == "set") { Helper.DisplayError("Unable to set values in the default config"); } } //TODO: Need to process Set operation. else if (CLevel.ToLower() == "user") { if (Operation.ToLower() == "get") { if (String.IsNullOrEmpty(Service)) { Console.WriteLine("Showing results for -> user:all\n\n{0}", CustomConfig.GetSettings("all")); } else { if (String.IsNullOrEmpty(Field)) { Console.WriteLine("Showing results for -> user:{0}\n\n{1}", Service, CustomConfig.GetSettings(Service)); } else { Console.WriteLine("Showing results for -> user:{0}= {1}", Field, CustomConfig.GetSettings(Service, Field)); } } } else if (Operation.ToLower() == "set") { if (string.IsNullOrEmpty(Service)) { Helper.DisplayError("Service name required."); } else { if (string.IsNullOrEmpty(Field)) { Helper.DisplayError("Field Name required."); } else { if (!CustomConfig.SetSetting(Service, Field, remainingArguments[2])) { Helper.DisplayError("Failed to make changes."); } Console.WriteLine("{0}:{1} has been updated.", Service, Field); } } } } return(0); }