public void PrintGameField() { UIUtilities.PrintPongTitle(); for (int i = 0; i < GameField.GetLength(0); i++) { for (int j = 0; j < GameField.GetLength(1); j++) { Console.Write(GameField[i, j]); } Console.WriteLine(); } }
private void CheckGameOver() { if (playerData.Score == GameManager.GOALS_TO_REACH) { UIUtilities.PrintWinner(playerData.Name); if (playerData.Name.Equals(_computer)) { Console.SetCursorPosition(30, 16); Console.WriteLine("Good luck next time..."); } GameOver?.Invoke(); } }
private int GetUserOption() { int result; do { Console.Clear(); UIUtilities.PrintPongTitle(); Console.SetCursorPosition(28, 7); Console.Write("Will you want to restart the game?"); Console.SetCursorPosition(26, 8); Console.Write("Enter -1- to restart or -2- to exit: "); } while (!int.TryParse(Console.ReadLine(), out result)); return(result); }
private string SetPlayerName() { if (IsSecondUserAndPlaySingle()) { return(_computer); } Console.ForegroundColor = ConsoleColor.Cyan; Console.SetCursorPosition(3, 7); Console.Write($"Enter -player{_playersCount}'s- name: "); string playerName = Console.ReadLine(); UIUtilities.ClearTitles(); Console.ForegroundColor = ConsoleColor.White; return(playerName); }
public void Start() { int _leftForCursorIcon = 22; int _topForCursorIcon = 3; bool isPressed = false; Console.Clear(); do { UIUtilities.PrintTitles(); MainMenuInstructions(); ConsoleKeyInfo key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.UpArrow: if (_topForCursorIcon > 9) { _topForCursorIcon -= 6; SetMainMenuCursor(_leftForCursorIcon, _topForCursorIcon); } break; case ConsoleKey.DownArrow: if (_topForCursorIcon < 21) { _topForCursorIcon += 6; SetMainMenuCursor(_leftForCursorIcon, _topForCursorIcon); } break; case ConsoleKey.Enter: MainMenuOptions mainMenuOptions = (MainMenuOptions)_topForCursorIcon; switch (mainMenuOptions) { case MainMenuOptions.SinglePlayer: GameManager.GameMode = GameMode.SinglePlayer; isPressed = true; break; case MainMenuOptions.PVP: GameManager.GameMode = GameMode.PVP; isPressed = true; break; case MainMenuOptions.Highscore: HighscoreManager _highscore = new HighscoreManager(); UIUtilities.PrintHighscoreTitle(); _highscore.HighscoreReader(); Console.ReadKey(true); Start(); isPressed = true; break; } break; case ConsoleKey.Escape: Console.Clear(); Environment.Exit(0); break; } } while (!isPressed); }