Ejemplo n.º 1
0
 public static void GameEndedCongratAndReset(ref bool gameInProgress)
 {
     Console.SetCursorPosition(0, 15);
     ConsoleManipulation.ClearCurrentLine();
     Console.WriteLine("\nCongratulations you escaped with {0} moves.\n", currentMoves);
     gameInProgress       = false;
     gameEndedRecordScore = true;
 }
Ejemplo n.º 2
0
        public static void PlayGame(Labyrinth labyrinth, int row, int col)
        {
            bool gameInProgress = true;

            currentMoves = 0;
            Console.WriteLine("\nEnter your move (Left Arrow = left, Right Arrow = right, Down Arrow = down, Up Arrow = up)");
            Console.SetCursorPosition(0, 15);

            LabyrinthNavigation navigation = new LabyrinthNavigation();

            while (gameInProgress)
            {
                ConsoleKeyInfo userChoice = Console.ReadKey(true);

                // Set currsor position outside of labyrinth and deletes previous turn message if any
                // I think this should be edited latter to not use magic numbers
                Console.SetCursorPosition(0, 15);
                ConsoleManipulation.ClearCurrentLine();

                switch (userChoice.Key)
                {
                case ConsoleKey.LeftArrow:
                    navigation.TryMoveLeft(labyrinth, ref gameInProgress, ref row, ref col);
                    break;

                case ConsoleKey.RightArrow:
                    navigation.TryMoveRight(labyrinth, ref gameInProgress, ref row, ref col);
                    break;

                case ConsoleKey.DownArrow:
                    navigation.TryMoveDown(labyrinth, ref gameInProgress, ref row, ref col);
                    break;

                case ConsoleKey.UpArrow:
                    navigation.TryMoveUp(labyrinth, ref gameInProgress, ref row, ref col);
                    break;

                case ConsoleKey.T:
                    PrintTopScores(scores);
                    break;

                case ConsoleKey.R:
                    gameInProgress = false;
                    break;

                case ConsoleKey.E:
                    Console.WriteLine("Good bye!");
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("Invalid command!");
                    break;
                }
            }
        }