/// <summary> /// Start the game and then enter the main game loop /// </summary> private static void StartGame() { CurrentPlayer = Players[0]; Players[0].DoTurn(); Players[0].DoTurn(); for (int i = 1; i < 1666; i++) { CurrentPlayer = Players[i % 2]; CurrentPlayer.DoTurn(); if (FastMode && CurrentPlayer.ScoreTotal >= 3) { RenderInfo.ScreenMessage($"Player {i + 1} WINS!"); break; } else if (!FastMode) { if (CurrentPlayer.ScoreRed >= 1 && CurrentPlayer.ScoreBlue >= 1 && CurrentPlayer.ScoreYellow >= 1) { RenderInfo.ScreenMessage($"Player {i + 1} WINS!"); break; } } } EndGame(); }
/// <summary> /// Asks the outside Input class for Input and then /// evalute it in the context of the board grid. /// </summary> /// <param name="ghostToBeMoved"> The Ghost that the player /// wants to move.</param> /// <returns> A valid grid position for the Ghost to be moved into /// </returns> public static Vector AskTileSelect(GhostObject ghostToBeMoved) { ValidGridInputs = GameController.GBoard.GetValidTiles(ghostToBeMoved); float x, y; InputRequest: RenderInfo.ScreenMessage("Select a Tile"); InputSender.AwaitVectorInput(out x, out y); foreach (Vector v in ValidGridInputs) { if (!(v.X == x && v.Y == y)) { RenderInfo.ScreenMessage("Invalid Tile!"); goto InputRequest; } else { break; } } return(new Vector((int)x, (int)y)); }
/// <summary> /// Constructor creates the Players and builds the Board. /// </summary> public static void SetupGame() { GBoard = new GameBoard(); GBoard.DropPlacement = true; Players[0] = new Player(); Players[1] = new Player(); Players[0].playerNumber = 1; Players[1].playerNumber = 2; RenderInfo.ScreenMessage("Turn fast mode ON?"); FastMode = InputReceiver.AskBoolSelect(); RenderInfo.ScreenMessage("FastMode is currently: " + FastMode); StartGame(); }
/// <summary> /// Ask the outer class for input and wait until it gets a valid one. /// </summary> /// <returns> A Vector with x:[0,2] and y:[0,18]</returns> public static Vector AskGhostSelect() { float x, y; InputRequest: RenderInfo.ScreenMessage("Select a Ghost"); InputSender.AwaitVectorInput(out x, out y); if (!(x >= 0 && x <= 2) && !(y >= 0 && y <= 18)) { RenderInfo.ScreenMessage("Invalid Input!"); goto InputRequest; } return(new Vector((int)x, (int)y)); }
/// <summary> /// Once the game loop is exited, show a message to indicate the game /// is over. /// </summary> private static void EndGame() { RenderInfo.ScreenMessage("GAME OVER!"); }