private static void ProcessMainOptions(ConsoleKeyInfo input) { switch (input.Key) { case ConsoleKey.D1: p.window = new TestGameWindow(); p.window.Show(); p.window.Close(); break; case ConsoleKey.D2: SubscribeEvents(p.game = new Game("gamecfg.json")); exitHandler = () => { p.game?.Quit(); }; //p.game.Keyboard.KeyPress; p.game.Run(); break; case ConsoleKey.D3: SubscribeEvents(p.game = new Game("gamecfg.jss")); exitHandler = () => { p.game?.Quit(); }; break; case ConsoleKey.X: exitHandler?.Invoke(); break; default: writeOptions = WriteMainOptions; break; } writeOptions?.Invoke(); }
/// <summary> /// 退出此State时会被调用 /// </summary> /// <param name="e"></param> public virtual void OnExit(StateExitEventArgs e) { ExitHandler?.Invoke(this, e); }