private static void GameOver() { string gameOver = "GAME OVER!"; string printPoint = string.Format("You won {0} points.", points); PrintAtPosition(columns / 2 - gameOver.Length / 2, rows / 2, gameOver, ConsoleColor.Black, ConsoleColor.Yellow); PrintAtPosition(columns / 2 - printPoint.Length / 2, rows / 2 + 1, printPoint, ConsoleColor.Black, ConsoleColor.Yellow); // Initialize a new instance of the SpeechSynthesizer. SpeechSynthesizer synth = new SpeechSynthesizer(); // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); // Speak a string. synth.Speak(string.Format("Game Over! You won {0} points.", points)); Thread.Sleep(1000); HighScores score = new HighScores(); if (score.CheckHighScore(points)) { string highScore = "You make a highscore!"; PrintAtPosition(columns / 2 - highScore.Length / 2, rows / 2 + 2, highScore, ConsoleColor.White, ConsoleColor.DarkMagenta); score.AddScore(points, Start.NickName); synth.Speak("You make a highscore!"); Console.BackgroundColor = ConsoleColor.Black; Thread.Sleep(2000); Start.EffectsWithPrinting(); HighScores myScore = new HighScores(); myScore.ShowHighScore(); Menu.ExitSelection(); } Console.BackgroundColor = ConsoleColor.Black; points = 0; }
private static void DrawGameFinish() { string message = string.Format("Congratulations! You completed The GAME !"); PrintAtPosition(columns / 2 - message.Length / 2, rows / 2, message, ConsoleColor.Yellow, ConsoleColor.Black); // Initialize a new instance of the SpeechSynthesizer. SpeechSynthesizer synth = new SpeechSynthesizer(); // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); // Speak a string. synth.Speak(string.Format("Congratulations! You completed The GAME !")); Thread.Sleep(1000); HighScores score = new HighScores(); if (score.CheckHighScore(points)) { string highScore = "You make a highscore!"; PrintAtPosition(columns / 2 - highScore.Length / 2, rows / 2 + 1, highScore, ConsoleColor.White, ConsoleColor.DarkMagenta); score.AddScore(points, Start.NickName); synth.Speak("You make a highscore!"); Console.BackgroundColor = ConsoleColor.Black; Thread.Sleep(2000); Start.EffectsWithPrinting(); HighScores myScore = new HighScores(); myScore.ShowHighScore(); Menu.ExitSelection(); } Console.BackgroundColor = ConsoleColor.Black; points = 0; }
public static void Show() { Console.Clear(); Console.CursorVisible = false; Console.TreatControlCAsInput = true; string[] title = { "@@@@ @@@@@ @@@@@@@@@@@@ @@@@@ @@@@ @@@@ @@@@", "@@@@ @@@@@ @@@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@", "@@@@@ @@@@@ @@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@@@ @@@@@@ @@@@@@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@ @@ @@@@@@@ @@@@@@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@ @@ @@ @@@@@ @@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@ @@@ @@@@@ @@@@@@@@@@@ @@@@ @@@@@@ @@@ @@@", "@@@@ @ @@@@@ @@@@@@@@@@@@ @@@@ @@@@@ @@@@@@@@", " ", " ", " ,,, ,,, ,,, ,,, ,,, ,,, ", " __//*) __//*) __//*) __//*) __//*) __//*) ", "~(__) ~(__) ~(__) ~(__) ~(__) ~(__) ", "// \\\\ \\\\// // \\\\ \\\\// // \\\\ \\\\// " }; Console.WriteLine("\n"); Console.ForegroundColor = ConsoleColor.Cyan; for (int i = 0; i < title.Length - 4; i++) { Console.SetCursorPosition(26, Console.CursorTop); Console.WriteLine(title[i]); } Console.ForegroundColor = ConsoleColor.Red; for (int i = title.Length - 4; i < title.Length; i++) { Console.SetCursorPosition(26, Console.CursorTop); Console.WriteLine(title[i]); } string[] menu = new string[] { " PLAY\n\n\n\n", " HOW TO PLAY\n\n\n\n", " HIGH SCORES\n\n\n\n", " EXIT\n\n\n\n" }; Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop + 4); Console.Write(menu[0]); for (int i = 1; i < 4; i++) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[i]); } PrintHorseInFront(42, 18); int row = 1; while (true) { ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.DownArrow && row == 1) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 20); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[1]); PrintHorseInFront(42, 22); DeleteHorse(42, 18); row++; } else if (keyInfo.Key == ConsoleKey.UpArrow && row == 2) { Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, 20); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[1]); DeleteHorse(42, 22); PrintHorseInFront(42, 18); row--; } else if (keyInfo.Key == ConsoleKey.DownArrow && row == 2) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 20); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[2]); PrintHorseInFront(42, 26); DeleteHorse(42, 22); row++; } else if (keyInfo.Key == ConsoleKey.DownArrow && row == 3) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 20); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[2]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[3]); PrintHorseInFront(42, 30); DeleteHorse(42, 26); row++; } else if (keyInfo.Key == ConsoleKey.UpArrow && row == 3) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 20); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[2]); DeleteHorse(42, 26); PrintHorseInFront(42, 22); row--; } else if (keyInfo.Key == ConsoleKey.UpArrow && row == 4) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 20); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[2]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop); Console.Write(menu[3]); DeleteHorse(42, 30); PrintHorseInFront(42, 26); row--; } else if (keyInfo.Key == ConsoleKey.Enter && row == 1) { Start.EffectsWithPrinting(); Game.Play(); return; } else if (keyInfo.Key == ConsoleKey.Enter && row == 2) { Start.EffectsWithPrinting(); Hints.Hint(); ExitSelection(); return; } else if (keyInfo.Key == ConsoleKey.Enter && row == 3) { Start.EffectsWithPrinting(); HighScores myScore = new HighScores(); myScore.ShowHighScore(); ExitSelection(); return; } else if (keyInfo.Key == ConsoleKey.Enter && row == 4) { Environment.Exit(0); } } }
public static void Show() { Console.Clear(); Console.CursorVisible = false; Console.TreatControlCAsInput = true; string[] title = { "@@@@ @@@@@ @@@@@@@@@@@@ @@@@@ @@@@ @@@@ @@@@", "@@@@ @@@@@ @@@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@", "@@@@@ @@@@@ @@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@@@ @@@@@@ @@@@@@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@ @@ @@@@@@@ @@@@@@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@ @@ @@ @@@@@ @@@@ @@@@ @@ @@@@ @@@@ @@@@", "@@@@ @@@ @@@@@ @@@@@@@@@@@ @@@@ @@@@@@ @@@ @@@", "@@@@ @ @@@@@ @@@@@@@@@@@@ @@@@ @@@@@ @@@@@@@@", " ", " ", " ,,, ,,, ,,, ,,, ,,, ,,, ", " __//*) __//*) __//*) __//*) __//*) __//*) ", "~(__) ~(__) ~(__) ~(__) ~(__) ~(__) ", "// \\\\ \\\\// // \\\\ \\\\// // \\\\ \\\\// " }; Console.WriteLine("\n"); Console.ForegroundColor = ConsoleColor.Cyan; for (int i = 0; i < title.Length - 4; i++) { Console.SetCursorPosition(26, Console.CursorTop); Console.WriteLine(title[i]); } Console.ForegroundColor = ConsoleColor.Red; for (int i = title.Length - 4; i < title.Length; i++) { Console.SetCursorPosition(26, Console.CursorTop); Console.WriteLine(title[i]); } List <string> menu = new List <string>(4); menu.Add(" PLAY\n\n\n\n"); menu.Add(" HOW TO PLAY\n\n\n\n"); menu.Add(" HIGH SCORES\n\n\n\n"); menu.Add(" EXIT\n\n\n\n"); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop + 5); Console.Write(menu[0]); for (int i = 1; i < 4; i++) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[i]); } PrintHorseInFront(42, 20); int row = 0; while (true) { if (Console.KeyAvailable) { ConsoleKey key = Console.ReadKey().Key; switch (key) { case ConsoleKey.UpArrow: { if (row != 0) { if (row == 1) { Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, 21); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[1]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[2]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[3]); DeleteHorse(42, 27); PrintHorseInFront(42, 20); } else if (row == 2) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 21); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[2]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[3]); DeleteHorse(42, 34); PrintHorseInFront(42, 27); } else { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 21); Console.Write(menu[0]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[2]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[3]); DeleteHorse(42, 41); PrintHorseInFront(42, 34); } row--; } } break; case ConsoleKey.DownArrow: { if (row != 3) { if (row == 0) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 21); Console.Write(menu[0]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[2]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[3]); DeleteHorse(42, 20); PrintHorseInFront(42, 27); } else if (row == 1) { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 21); Console.Write(menu[0]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[1]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[2]); Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[3]); DeleteHorse(42, 27); PrintHorseInFront(42, 34); } else { Console.ForegroundColor = ConsoleColor.Green; Console.SetCursorPosition(44, 21); Console.Write(menu[0]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[1]); Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[2]); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(44, Console.CursorTop + 3); Console.Write(menu[3]); DeleteHorse(42, 34); PrintHorseInFront(42, 41); } row++; } } break; case ConsoleKey.Enter: { if (row == 0) // Play { Start.EffectsWithPrinting(); Game.Play(); return; } else if (row == 1) // How to Play { Start.EffectsWithPrinting(); Hints.hint(); ExitSelection(); return; } else if (row == 2) //High Scores { Start.EffectsWithPrinting(); HighScores myScore = new HighScores(); myScore.ShowHighScore(); ExitSelection(); return; } else { Environment.Exit(0); } } break; default: { Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop); Console.Write(" "); Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop); } break; } } } }