public override void Update(GameTime gameTime) { base.Update(gameTime); if (m_SceneChanges.ContainsKey(CurrentScene)) { foreach (SceneChange sc in m_SceneChanges[CurrentScene]) { if (sc.ChangeNow(gameTime)) { m_NextScene = sc.To; if (CurrentScene != null) { CurrentScene.OnExit(); StopMainTune(m_NextScene); CurrentScene.StopTune(); } CurrentScene = m_NextScene; CurrentScene.StartTime = gameTime.TotalRealTime(); CurrentScene.Reset(); CurrentScene.OnEnter(); CurrentScene.StartTune(); StartMainTune(); } } } }
private static void UpdateTransitions() { if (!transitionInProgress) { return; } if (!exitCompleted) { if (exitTransition == null) { LoadNextScene(); enterTransition?.Begin(); exitCompleted = true; if (enterTransition == null) { transitionInProgress = false; exitCompleted = false; } } else { exitTransition.Update(); if (exitTransition.Done) { CurrentScene.OnExit(); exitTransition.Reset(); exitTransition = null; LoadNextScene(); enterTransition?.Begin(); exitCompleted = true; if (enterTransition == null) { transitionInProgress = false; exitCompleted = false; } } } } else { enterTransition.Update(); if (enterTransition.Done) { enterTransition.Reset(); enterTransition = null; transitionInProgress = false; exitCompleted = false; } } }
public static void Play() { //scenesCreation TitleScene aivTitle = new TitleScene("Assets/aivBG.png", KeyCode.Return); WelcomeScene welcome = new WelcomeScene("Assets/welcomeBg.jpg", KeyCode.Return); PlayScene playScene = new PlayScene(); GameOverScene gameover = new GameOverScene(); //scenes config aivTitle.NextScene = welcome; aivTitle.ShowTime = 3; aivTitle.FadeIn = true; aivTitle.FadeOut = true; welcome.NextScene = playScene; welcome.FadeOut = false; playScene.NextScene = gameover; gameover.NextScene = playScene; aivTitle.Start(); CurrentScene = aivTitle; //GfxManager.Load(); while (Window.opened) { if (!CurrentScene.IsPlaying) { //next scene if (CurrentScene.NextScene != null) { CurrentScene.OnExit(); CurrentScene = CurrentScene.NextScene; CurrentScene.Start(); } else return; } //Input if (Window.GetKey(KeyCode.Esc)) break; CurrentScene.Input(); //Update CurrentScene.Update(); //Draw CurrentScene.Draw(); Window.Update(); } }
public void SetScene(Scene newScene) { if (CurrentScene != null) { CurrentScene.OnExit(); } CurrentScene = newScene; if (CurrentScene != null) { CurrentScene.OnEnter(CurrentScene.FirstTime); CurrentScene.FirstTime = false; } }
public static void Play() { while (window.opened) { AudioManager.SetStreamingMusic("intro", 0.5f); //backGround.Stream(intro, window.deltaTime); //audio background if (!CurrentScene.IsPlaying) { //next scene if (CurrentScene.NextScene != null) { CurrentScene.OnExit(); CurrentScene = CurrentScene.NextScene; CurrentScene.Start(); } else { return; } } //totalTime += GfxTools.Win.deltaTime; Console.SetCursorPosition(0, 0); //float fps = 1 / window.deltaTime; //if(fps<59) // Console.Write((1 / window.deltaTime) + " "); //Input if (window.GetKey(KeyCode.Esc)) { break; } CurrentScene.Input(); //Update CurrentScene.Update(); //Draw CurrentScene.Draw(); window.Update(); } }
public static void Play() { while (window.opened) { if (!CurrentScene.IsPlaying) { //next scene if (CurrentScene.NextScene != null) { CurrentScene.OnExit(); CurrentScene = CurrentScene.NextScene; CurrentScene.Start(); } else { return; } } //totalTime += GfxTools.Win.deltaTime; //Console.SetCursorPosition(0, 0); //Console.Write((1 / window.deltaTime)+" "); //Input if (window.GetKey(KeyCode.Esc)) { break; } CurrentScene.Input(); //Update CurrentScene.Update(); //Draw CurrentScene.Draw(); window.Update(); } }