protected void Initialize() { this.RequiredSizeMet.SubscribeOnce(() => { var introPanel = new PowerArgsGamesIntro(); var frameRateControl = LayoutRoot.Add(new FramerateControl(introPanel) { ZIndex = 100 }); LayoutRoot.Add(introPanel).Play().Then(() => { QueueAction(() => { LayoutRoot.Controls.Remove(frameRateControl); this.shooterKeys = new ShooterKeys(() => this.Scene); this.KeyboardInput.KeyMap = this.shooterKeys.ToKeyMap(); EnableThemeToggling(); LayoutRoot.Add(new HeadsUpDisplay(this, shooterKeys)).CenterHorizontally().DockToBottom(); this.Load("IntroCutScene"); var requiredSizeCausedPause = false; this.RequiredSizeNotMet.SubscribeForLifetime(() => { if (Scene.IsRunning) { this.Pause(false); requiredSizeCausedPause = true; } else { requiredSizeCausedPause = false; } }, this); this.RequiredSizeMet.SubscribeForLifetime(() => { if (requiredSizeCausedPause) { this.Resume(); } }, this); Sound.Loop("bgmusicmain").Then(d => bgMusicHandle = d); this.Paused.SubscribeForLifetime(() => { bgMusicHandle?.Dispose(); bgMusicHandle = null; }, this); this.Resumed.SubscribeForLifetime(() => { Sound.Loop("bgmusicmain").Then(d => bgMusicHandle = d); }, this); }); }); }); }
public async Task TestPowerArgsIntroCompletesOnItsOwn() { var app = new ConsoleApp(80, 30); var appTask = app.Start().AsAwaitable(); PowerArgsGamesIntro intro = null; await app.QueueAction(() => intro = app.LayoutRoot.Add(new PowerArgsGamesIntro()).CenterVertically()).AsAwaitable(); Assert.IsNotNull(intro); await app.QueueAction(async() => { await intro.Play().AsAwaitable(); app.Stop(); }).AsAwaitable(); await appTask; }