/// <summary> /// Menu selection /// </summary> private void MenuSelection() { int posYMenu = 20; string howToMove = "Appuyez sur les flèches directionnels ↑ ↓ pour vous déplacer."; Console.SetCursorPosition(Console.WindowWidth / 2 - howToMove.Length / 2, 16); Console.WriteLine(howToMove); string[] menuOption = new string[] { "JOUER", "OPTIONS", "HIGHSCORE", "INFOS", "QUITTER" }; Console.ForegroundColor = ConsoleColor.Yellow; for (int i = 0; i < menuOption.Length; i++) { Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[i].Length / 2, posYMenu); Console.WriteLine(menuOption[i]); posYMenu += 2; Console.ForegroundColor = ConsoleColor.White; } posYMenu = 20; int index = 0; while (!_continueKey) { _keyPressed = Console.ReadKey(true); //Sub menu movement switch (_keyPressed.Key) { case ConsoleKey.UpArrow: Sound.PlaySound(Sound.Sounds.Blip_Select); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[index].Length / 2, posYMenu); Console.Write(menuOption[index]); if (index > 0) { index--; Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[index].Length / 2, posYMenu -= 2); } break; case ConsoleKey.DownArrow: Sound.PlaySound(Sound.Sounds.Blip_Select); Console.ForegroundColor = ConsoleColor.White; Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[index].Length / 2, posYMenu); Console.Write(menuOption[index]); if (index < 4) { index++; Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[index].Length / 2, posYMenu += 2); } break; case ConsoleKey.Enter: Console.ForegroundColor = ConsoleColor.White; if (index == 0) { PlayGame(); } if (index == 1) { GameOptions(); } if (index == 2) { GameHighscore(); } if (index == 3) { Infos(); } if (index == 4) { Environment.Exit(0); } else { Sound.PlaySound(Sound.Sounds.Blip_Select); _continueKey = true; } break; case ConsoleKey.Escape: Environment.Exit(0); break; default: break; } Console.ForegroundColor = ConsoleColor.Yellow; switch (index) { case 0: Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[0].Length / 2, posYMenu); Console.Write(menuOption[0]); break; case 1: Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[1].Length / 2, posYMenu); Console.Write(menuOption[1]); break; case 2: Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[2].Length / 2, posYMenu); Console.Write(menuOption[2]); break; case 3: Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[3].Length / 2, posYMenu); Console.Write(menuOption[3]); break; case 4: Console.SetCursorPosition(Console.WindowWidth / 2 - menuOption[4].Length / 2, posYMenu); Console.Write(menuOption[4]); break; } } Console.ForegroundColor = ConsoleColor.White; }
/// <summary> /// Display Pause Menu /// </summary> public void PauseMenu() { //variables string[] options = new string[] { " Retourner au jeu ", " Retourner au menu ", " Quitter le jeu " }; int posX = 28; int posY = 22; int Y; int index = 1; _continueKey = false; //Sound in the menu Sound.PlaySound(Sound.Sounds.Blip_Select); Console.SetCursorPosition(posX, posY++); Console.WriteLine(" "); Console.SetCursorPosition(posX, posY); Console.WriteLine(" GAME PAUSED "); while (!_continueKey) { Y = posY + 1; for (int i = 0; i < options.Length; i++) { Console.SetCursorPosition(posX, Y++); Console.WriteLine(" "); if (i == index - 1) { Console.ForegroundColor = ConsoleColor.Yellow; } Console.SetCursorPosition(posX, Y++); Console.WriteLine($"{options[i]}"); Console.ResetColor(); } _keyPressed = Console.ReadKey(true); //Sub menu movement switch (_keyPressed.Key) { case ConsoleKey.UpArrow: index--; if (index <= 0) { index = options.Length; } break; case ConsoleKey.DownArrow: index++; if (index > options.Length) { index = 1; } break; case ConsoleKey.Enter: switch (index) { case 1: { Sound.PlaySound(Sound.Sounds.Blip_Select); for (int i = 0; i < options.Length + 2; i++) { Console.SetCursorPosition(posX, posY + (2 * i)); Console.WriteLine(" "); } _continueKey = true; break; } case 2: { Sound.PlaySound(Sound.Sounds.Blip_Select); Sound.Music.Stop(); Game._gamePaused = false; MainMenu(); break; } case 3: { Environment.Exit(0); break; } } break; } } }
/// <summary> /// Prints the game options /// </summary> private void GameOptions() { // Variables const int OPTIONSXAXETITLE = 17; int optionsYAxeTitle = 1; int index = 0; string[] optionsArray = new string[5] { " ██████ ██████ ████████ ██ ██████ ███ ██ ███████ ", "██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ", "██ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ███████ ", "██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ", " ██████ ██ ██ ██ ██████ ██ ████ ███████ " }; Console.Clear(); // Writing the "OPTIONS" for (int i = 0; i < optionsArray.Length; i++) { Console.SetCursorPosition(OPTIONSXAXETITLE, optionsYAxeTitle++); Console.WriteLine(optionsArray[i]); } WriteOptions(index); Console.SetCursorPosition(21, 30); Console.Write("Appuyez sur ESC pour revenir au menu principal..."); while (!_continueKey) { _keyPressed = Console.ReadKey(true); // Sub menu movement switch (_keyPressed.Key) { case ConsoleKey.UpArrow: Sound.PlaySound(Sound.Sounds.Blip_Select); index = 0; WriteOptions(index); break; case ConsoleKey.DownArrow: Sound.PlaySound(Sound.Sounds.Blip_Select); index = 1; WriteOptions(index); break; case ConsoleKey.Enter: Sound.PlaySound(Sound.Sounds.Blip_Select); if (index == 0) { Sound.SoundOn = !Sound.SoundOn; WriteOptions(index); } else if (index == 1) { if (Game._difficulty == 0) { Game._difficulty = 1; WriteOptions(index); } else { Game._difficulty = 0; WriteOptions(index); } } break; case ConsoleKey.Escape: MainMenu(); break; } } }