public static void RunMenu() { Console.Clear(); Console.ForegroundColor = ConsoleColor.Yellow; Console.SetCursorPosition(4, 3); Console.Write("MECHANICS: GET ALL THE NUMBERS AND AVOID TO COLLIDE IN ANY SIDE OF SQUARE"); Console.ForegroundColor = ConsoleColor.DarkGray; Console.SetCursorPosition(4, 5); Console.Write("CONTROLS: LEFT ARROW KEY, UP ARROW KEY, RIGHT ARROW KEY, DOWN ARROW KEY"); Console.Write(""); Console.ForegroundColor = ConsoleColor.Yellow; Console.SetCursorPosition(32, 9); Console.Write("OPTIONS:"); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.DarkGray; Console.SetCursorPosition(32, 11); Console.Write("1 = Start new game"); Console.SetCursorPosition(32, 12); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write("2 = Hall of Fame"); Console.SetCursorPosition(32, 13); Console.ForegroundColor = ConsoleColor.DarkGray; Console.Write("3 = Exit"); Console.CursorVisible = false; Console.ForegroundColor = ConsoleColor.White; var key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.D1: Console.Clear(); Game.StartNewGame(); break; case ConsoleKey.D2: Console.Clear(); HallOfFame.Show(); break; case ConsoleKey.D3: Console.Clear(); ExitQuestion(); break; default: Console.Clear(); RunMenu(); break; } }
private static void CheckResultInHallOfFame() { if (HallOfFame.CheckForFameResult(score)) { Console.Clear(); Console.SetCursorPosition(6, 9); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Congratulations! You have now a place in Top 10 Hall of Fame Players"); Console.SetCursorPosition(14, 11); Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine("REMINDER: Avoid space ' ', instead use underscore '_'"); Console.SetCursorPosition(18, 13); Console.ForegroundColor = ConsoleColor.Green; Console.Write("Please enter your name without space: "); Console.ForegroundColor = ConsoleColor.White; Console.CursorVisible = true; string userNamed = Console.ReadLine(); Console.CursorVisible = false; HallOfFameEntry entry = new HallOfFameEntry(); string checkerUserNamed = userNamed.Substring(0, 2); int x; if (userNamed == "" || userNamed == " ") { CheckResultInHallOfFame(); } else if (Int32.TryParse(checkerUserNamed, out x)) { CheckResultInHallOfFame(); } else if (userNamed != "" || userNamed != " ") { if (userNamed.Contains(' ')) { string[] res = userNamed.Trim().Split(); userNamed = res[0]; } entry.Name = userNamed; entry.Score = score; HallOfFame.EnterHallOfFame(entry); } } }