private static void GameCompleted(ConsoleGame game) { Console.SetCursorPosition(0, _gameSettings.GameBoardHeight + 3); Console.WriteLine("Your score --> {0}", game.Score); if (_resultsAnalysis.CheckResult(game.Score)) { Console.WriteLine("Your name:"); string name = Console.ReadLine(); _resultsAnalysis.AddScore(game.Score, name); } _resultsAnalysis.ShowResults(); _gameSettings.ReadFromConfig(); _resultsAnalysis = new ResultAnalysis(_gameSettings); }
static void Main(string[] args) { Console.WriteLine("Snake Defender"); Console.WriteLine("Press 'Enter' for start"); ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Enter) { do { var game = new ConsoleGame(_gameSettings, _randomGenerator); _resultsAnalysis.RaiseMyEvent += game.ShowResults; game.StartGame(); // when Game Over GameCompleted(game); Console.WriteLine("Press 'Enter' for restart"); keyInfo = Console.ReadKey(); Console.Clear(); } while (keyInfo.Key == ConsoleKey.Enter); } }
static void Main(string[] args) { var resultsAnalysis = new ResultsProcessing(); Console.WriteLine("Snake Defender"); Console.WriteLine("Press 'Enter' for start"); ConsoleKeyInfo key_info = Console.ReadKey(); if (key_info.Key == ConsoleKey.Enter) { while (key_info.Key == ConsoleKey.Enter) { var game = new ConsoleGame(); game.StartGame(); // when Game Over Console.WriteLine("Your score --> {0}", game.Score); resultsAnalysis.CheckResult(game.Score); resultsAnalysis.ShowResults(); Console.WriteLine("Press 'Enter' for restart"); key_info = Console.ReadKey(); Console.Clear(); } } }