Ejemplo n.º 1
0
 //The main logic of the game.
 static void PlayGame()
 {
     SetGameField();
     DrawOnTheConsole.DrawMenu();
     DrawOnTheConsole.PrintOnTheConsole(dwarfBeginPositionColumn, dwarfBeginPositionRow, "(0)", ConsoleColor.Green);
     while (true)
     {
         GenerateRocks();
         bool isGamePlay = ChangeRockPosition();
         if (isGamePlay == false)
         {
             break;
         }
         if (Console.KeyAvailable)
         {
             ConsoleKeyInfo key = Console.ReadKey(true);
             ChangePlayerDirection(key);
             MoveDwarf();
             DrawOnTheConsole.PrintOnTheConsole(dwarfBeginPositionColumn, dwarfBeginPositionRow, "(0)", ConsoleColor.Green);
         }
         Thread.Sleep(150);
     }
     DrawOnTheConsole.PrintGameOver();
     IsGameContinue();
 }
Ejemplo n.º 2
0
 //Restart the game and print Max Scores
 static void ResetGame()
 {
     Console.Clear();
     rocksCollection.Clear();
     autonumber = 0;
     if (score > maxScore)
     {
         maxScore = score;
     }
     if (maxScore > 0)
     {
         DrawOnTheConsole.PrintOnTheConsole(playingScreen + 4, 7, string.Format("Max score: {0}", maxScore), ConsoleColor.DarkGreen);
     }
     score = 0;
     PlayGame();
 }