/// <summary> /// Basic draw of each button with the Play button selected /// </summary> protected virtual void DrawOptions() { // Draw some text if it's about page if (this == GameManager.Instance.Menus[3]) { DrawText(_ABOUT_TITLE_1, _ABOUT_1); DrawText(_ABOUT_TITLE_2, _ABOUT_2); } // Draw some text if it's highscore page else if (this == GameManager.Instance.Menus[2]) { // Catch the first 5 best scores (name and score) string[,] firstFive = HighscoreDB.SortFirstFive(HighscoreDB.GetScores()); for (int i = 0; i < firstFive.GetLength(0); i++) { // If it's not empty if (firstFive[i, 0] != "") { string name = firstFive[i, 0]; string score = firstFive[i, 1]; DrawText((i + 1) + ". " + name, " " + score); } } } DrawButtons(); }
protected override void KeyManager() { // Can write characters GameManager.Instance.Input = Console.ReadKey(false); switch (GameManager.Instance.Input.Key) { // Loop for the selection of an option by pressing enter case ConsoleKey.Enter when _playerNames.Count != 0: { Console.CursorVisible = false; HighscoreDB.WriteScore(new string(_playerNames.ToArray()).Trim(), Score); _playerNames.Clear(); _redraw = true; // Clear because we change the menu page Console.Clear(); GameManager.Instance.CurrentMenu = GameManager.Instance.Menus[0]; GameManager.Instance.State = GameManager.GameManagerState.MainMenu; break; } case ConsoleKey.Enter: { Console.CursorLeft = Console.WindowWidth / 2 - nameRectangle[0].Length / 2 + 2; break; } case ConsoleKey.Backspace when _playerNames.Count != 0: { _playerNames.RemoveAt(_playerNames.Count - 1); Console.Write(" \b"); break; } case ConsoleKey.Backspace: { // Stay here Console.Write(" "); break; } default: { if (_playerNames.Count <= 22) { _playerNames.Add(GameManager.Instance.Input.KeyChar); GameManager.Instance.Input.Key.ToString().ToUpper(); } else { Console.Write("\b \b"); } break; } } }