public void NextTurn() { if (currentPlayer.IsFinished() == true) { // Runs a method that sets the Game Over GUI. gameOverControls(); } // If the current player index is larger than the // number of players on the binding list it loops back to 0. if (currentPlayerindex > form.numberofplayers() - 2) { currentPlayerindex = 0; } else { currentPlayerindex++; } currentPlayer = players[currentPlayerindex]; string name = Names[currentPlayerindex]; playersFinished++; string message = "Roll 1"; for (int i = 0; i < dice.Length; i++) { dieLabels[i].Text = ""; } numRolls = 0; currentPlayer.ShowScores(); form.DisableAllButtons(); form.DisableAndClearCheckBoxes(); form.EnableRollButtons(); form.ShowPlayerName(name); form.ShowMessage(message); form.HideOKButton(); }
/// <summary> /// Creates a new game and initiates the GUI desgin and starting buttons. /// </summary> /// <param name="form"></param> public Game(Form1 form) { form.clearScoreLabels(); players.ResetBindings(); players.Add(new Player(Names[0], form.GetScoreTotals())); string message = "Please Select the Number of Players"; currentPlayerindex = 0; playersFinished = 0; numRolls = 0; this.form = form; this.dieLabels = this.form.GetDice(); for (int i = 0; i < dice.Length; i++) { dice[i] = new Die(dieLabels[i]); } currentPlayer = players[currentPlayerindex]; for (int i = 0; i < dice.Length; i++) { dieLabels[i].Text = ""; } string name = Names[currentPlayerindex]; form.DisableAndClearCheckBoxes(); form.DisableAllButtons(); form.ShowPlayerName(name); form.EnableUpDown(); form.EnableRollButtons(); form.ShowMessage(message); form.HideOKButton(); form.enablesave(); form.disableload(); }