static void StartGame() { score = 0; bool exit = false; Thread thread = new Thread(new ThreadStart(ReadKeyThread)); int life = 3; string name = GetName(); if (name.Length == 0) { name = "Инкогнито"; } Keyboard(); InitScene(life); thread.IsBackground = true; thread.Start(); do { if (crash) { InitScene(--life); } if (!thread.IsAlive) { exit = true; } } while ((!exit && life > 0)); timer.Dispose(); Console.Clear(); Console.SetCursorPosition(widthScreen / 2 - 5, heightScreen / 2 - 5); Console.ForegroundColor = ConsoleColor.White; Console.Write($"Вы набрали {score}"); HistoryArr.AddResult(score, name); if (thread.IsAlive) { thread.Abort(); //не вытаскивает из Console.ReadKey(true) exeptuon вознимает после нажатия клавиши while (thread.IsAlive) //знаючто это не правильно но не знаю как ещё вытащит из ожидания клавиши и сделать вид что мы ожидаем клавишу для продолжения { } } else { Console.ReadKey(); } }
static void DrawHistory() { Console.Clear(); Console.ForegroundColor = ConsoleColor.Green; if (HistoryArr.LengthHistory == 0) { Console.SetCursorPosition(widthScreen / 2 - 5, heightScreen / 2 - 10); Console.Write($"Ещё никто не летал"); } else { for (int i = 0; i < HistoryArr.LengthHistory; i++) { Console.SetCursorPosition(widthScreen / 2 - 5, heightScreen / 2 - 10 + i); Console.Write($"{i + 1} {HistoryArr.GetHistoryByPosStr(i)}"); } } Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(widthScreen / 2 - 15, heightScreen - 2); Console.Write("Для возврата нажмите любую кнопку"); Console.ReadKey(); Console.ResetColor(); }