protected void Initialize() { this.RequiredSizeMet.SubscribeOnce(() => { var shooterKeys = new ShooterKeys(() => this.Scene); this.KeyboardInput.KeyMap = shooterKeys.ToKeyMap(); this.Load("default"); 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); }); }
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); }); }); }); }