Beispiel #1
0
 private static void CheckResultInHallOfFame()
 {
     if (HallOfFame.CheckForFameResult(score))
     {
         Console.Clear();
         Console.SetCursorPosition(18, 9);
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("So You've got a great result! Congratulations!!!");
         Console.SetCursorPosition(18, 13);
         Console.ForegroundColor = ConsoleColor.Green;
         Console.Write("Please, enter your name without spaces: ");
         Console.ForegroundColor = ConsoleColor.White;
         Console.CursorVisible   = true;
         string name = Console.ReadLine();
         Console.CursorVisible = false;
         HallOfFameEntry entry = new HallOfFameEntry();
         if (name.Contains(' '))
         {
             string[] res = name.Trim().Split();
             name = res[0];
         }
         entry.Name  = name;
         entry.Score = score;
         HallOfFame.EnterHallOfFame(entry);
     }
 }
Beispiel #2
0
        public static void RunMenu()
        {
            // Menu de 3 posiciones , no permite nada mas , distintos colores para diferente aspecto
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(32, 8);
            Console.Write("1-Start new game");
            Console.SetCursorPosition(32, 10);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write("2-Hall of fame");
            Console.SetCursorPosition(32, 12);
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write("3-Exit");
            Console.CursorVisible   = false;
            Console.ForegroundColor = ConsoleColor.White;

            // Unica variable
            var key = Console.ReadKey();

            // Hacemos el Swtch de 3 opciones
            switch (key.Key)
            {
            case ConsoleKey.D1:
                Console.Clear();
                Game.StartNewGame();
                break;

            case ConsoleKey.D2:
                Console.Clear();
                HallOfFame.Show();
                break;

            case ConsoleKey.D3:
                Console.Clear();
                return;

            default:
                Console.Clear();
                RunMenu();
                break;
            }
        }