public override void Initialize(IApplication application) { base.Initialize(application); GameStorage gameStorage; if (WaveServices.Storage.Exists<GameStorage>()) { gameStorage = WaveServices.Storage.Read<GameStorage>(); } else { gameStorage = new GameStorage(); } Catalog.RegisterItem(gameStorage); application.Adapter.DefaultOrientation = DisplayOrientation.Portrait; application.Adapter.SupportedOrientations = DisplayOrientation.Portrait; ScreenContext screenContext = new ScreenContext(new MainMenuScene()); // Play background music WaveServices.MusicPlayer.Play(new MusicInfo(WaveContent.Assets.Sounds.bg_music_mp3)); WaveServices.MusicPlayer.IsRepeat = true; WaveServices.ScreenContextManager.To(screenContext); }
/// <summary> /// Initializes a new instance of the <see cref="ScorePanel" /> class. /// </summary> /// <param name="name">Entity name</param> public ScorePanel(string name) { this.scores = 1; this.gameStorage = Catalog.GetItem<GameStorage>(); this.entity = new Entity(name) .AddComponent(new Transform2D()) .AddComponent(new PanelControl(241, 104)) .AddComponent(new PanelControlRenderer()) .AddChild(new Image(WaveContent.Assets.Textures.scorePanel_png) { DrawOrder = 0.4f, }.Entity); this.scoreText = new TextBlock("scoresText") { Width = 40, Text = this.Scores.ToString(), FontPath = WaveContent.Assets.Fonts.OCR_A_Extended_16_TTF, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 15, 50, 0), DrawOrder = 0.2f, }; this.entity.AddChild(this.scoreText.Entity); this.bestText = new TextBlock("bestText") { Width = 40, Text = this.gameStorage.BestScore.ToString(), FontPath = WaveContent.Assets.Fonts.OCR_A_Extended_16_TTF, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 0, 50, 5), DrawOrder = 0.2f, }; this.entity.AddChild(this.bestText.Entity); }