override void CreateScene() { this.Load(WaveContent.Scenes.GameOverScene); this.EntityManager.Find("defaultCamera2D").FindComponent<Camera2D>().CenterScreen(); this.gameStorage = Catalog.GetItem<GameStorage>(); this.gameScene = WaveServices.ScreenContextManager.FindContextByName("GamePlay") .FindScene<GamePlayScene>(); if (this.gameStorage.BestScore < this.gameScene.CurrentScore) { // Update best score this.gameStorage.BestScore = this.gameScene.CurrentScore; // Save storage game data GameStorage gameStorage = Catalog.GetItem<GameStorage>(); WaveServices.Storage.Write<GameStorage>(gameStorage); #if ANDROID await WaveServices.GetService<SocialService>().AddNewScore(LeaderboardCode, this.gameScene.CurrentScore); await WaveServices.GetService<SocialService>().ShowLeaderboard(LeaderboardCode); #endif } this.CreateUI(); // Music Volume WaveServices.MusicPlayer.Volume = 0.2f; }
protected override void CreateScene() { this.Load(WaveContent.Scenes.MainMenuScene); this.EntityManager.Find("defaultCamera2D").FindComponent<Camera2D>().CenterScreen(); this.gameStorage = Catalog.GetItem<GameStorage>(); this.CreateUI(); }
public override void Initialize(IApplication application) { base.Initialize(application); application.Adapter.DefaultOrientation = DisplayOrientation.Portrait; application.Adapter.SupportedOrientations = DisplayOrientation.Portrait; #if ANDROID InitializeAndRegisterSocialService(); #endif // Load storage game data GameStorage gameStorage; if (WaveServices.Storage.Exists<GameStorage>()) { gameStorage = WaveServices.Storage.Read<GameStorage>(); } else { gameStorage = new GameStorage(); } Catalog.RegisterItem(gameStorage); // Register the SoundManager service WaveServices.RegisterService<SoundManager>(new SoundManager()); // Use ViewportManager to ensure scaling in all devices ViewportManager vm = WaveServices.ViewportManager; vm.Activate(768, 1024, ViewportManager.StretchMode.Uniform); var backContext = new ScreenContext("BackContext", new BackgroundScene()) { Behavior = ScreenContextBehaviors.DrawInBackground | ScreenContextBehaviors.UpdateInBackground }; var mainContext = new ScreenContext(new MainMenuScene()); WaveServices.ScreenContextManager.Push(backContext); WaveServices.ScreenContextManager.Push(mainContext); // Play music WaveServices.MusicPlayer.Play(new MusicInfo(WaveContent.Assets.Sounds.bg_music_mp3)); WaveServices.MusicPlayer.Volume = 1.0f; WaveServices.MusicPlayer.IsRepeat = true; }
protected override void CreateScene() { this.Load(WaveContent.Scenes.GameOverScene); this.EntityManager.Find("defaultCamera2D").FindComponent<Camera2D>().CenterScreen(); this.gameStorage = Catalog.GetItem<GameStorage>(); this.gameScene = WaveServices.ScreenContextManager.FindContextByName("GamePlay") .FindScene<GamePlayScene>(); if (this.gameStorage.BestScore < this.gameScene.CurrentScore) { // Update best score this.gameStorage.BestScore = this.gameScene.CurrentScore; // Save storage game data GameStorage gameStorage = Catalog.GetItem<GameStorage>(); WaveServices.Storage.Write<GameStorage>(gameStorage); } this.CreateUI(); // Music Volume WaveServices.MusicPlayer.Volume = 0.2f; }