public override void Initialize(IApplication application) { base.Initialize(application); // Load storage game data GameStorage gameStorage; if (WaveServices.Storage.Exists<GameStorage>()) { gameStorage = WaveServices.Storage.Read<GameStorage>(); } else { gameStorage = new GameStorage(); } Catalog.RegisterItem<GameStorage>(gameStorage); // Register the SoundManager service WaveServices.RegisterService<SoundManager>(new SoundManager()); // Play background music WaveServices.MusicPlayer.Play(new MusicInfo(WaveContent.Assets.Audio.bg_music_mp3)); WaveServices.MusicPlayer.IsRepeat = true; // GameBackContext is visible always at the background. // For this reason the behavior is set to Draw and Update when the scene is in background. var backContext = new ScreenContext("GameBackContext", new GameScene()); backContext.Behavior = ScreenContextBehaviors.DrawInBackground | ScreenContextBehaviors.UpdateInBackground; //On init show the Main menu WaveServices.ScreenContextManager.Push(backContext); WaveServices.ScreenContextManager.Push(new ScreenContext("MenuContext", new MenuScene())); }
/// <summary> /// Creates the scene. /// </summary> /// <remarks> /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized. /// </remarks> protected override void CreateScene() { this.Load(WaveContent.Scenes.MenuScene); this.gameStorage = Catalog.GetItem<GameStorage>(); this.CreateUI(); #if DEBUG this.AddSceneBehavior(new DebugSceneBehavior(), SceneBehavior.Order.PreUpdate); #endif }
/// <summary> /// Creates the scene. /// </summary> /// <remarks> /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized. /// </remarks> protected override void CreateScene() { this.Load(WaveContent.Scenes.GameOverScene); this.gameStorage = Catalog.GetItem<GameStorage>(); if (this.gameStorage.BestScore < this.finalScore) { // Update best score this.gameStorage.BestScore = this.finalScore; // Save storage game data GameStorage gameStorage = Catalog.GetItem<GameStorage>(); WaveServices.Storage.Write<GameStorage>(gameStorage); } this.CreateUI(); #if DEBUG this.AddSceneBehavior(new DebugSceneBehavior(), SceneBehavior.Order.PreUpdate); #endif }