/// <summary> /// Controls the game activities sequence, from intro to ending, /// including gameplay and settings activity. /// </summary> protected override async Task Play() { var startScreen = new StartScreen(this); var setupScreen = new GamePlaySetup(this); while (true) { try { switch (await startScreen.Run()) { case StartScreen.Options.Exit: return; case StartScreen.Options.HowToPlay: await new HowToPlay(this).Run(); continue; case StartScreen.Options.Play: break; default: throw new NotImplementedException(); } bool playAgain; do { var setup = await setupScreen.Run(); if (setup.Aborted) { break; } var gamePlay = new GamePlay(this, setup); var gameResult = await gamePlay.Run(); playAgain = gameResult.Aborted; if (!gameResult.Aborted) { await new ShowResults(this, gameResult).Run(); } } while(playAgain); } catch (Exception ex) { Console.WriteLine(ex); #if DEBUG if (Debugger.IsAttached) { Debugger.Break(); } #endif } } }
public static void Main() { Console.BufferHeight = Console.WindowHeight = 30; Console.BufferWidth = Console.WindowWidth = 70; Console.CursorVisible = false; // Infinite loop allows for multiple game sessions while (true) { IEngine startScreen = new StartScreen(); startScreen.Run(); IEngine gameEngine = new GameEngine(scoreContainer); gameEngine.Run(); IEngine gameOverScreeen = new GameOverScreen(scoreContainer); gameOverScreeen.Run(); } }