/// <summary> /// Rolls all dice, and updates their value into the form window. /// Enables and disables score buttons as nessecary. /// </summary> public void RollDice() { // roll each die for (int i = 0; i < Num_Die; i++) { if (dice[i].Active) { dice[i].Roll(); } form.GetDice()[i].Text = dice[i].FaceValue().ToString(); // updates dice label } // Enable Score buttons EnableAllScoreButtons(); numRolls++; // increment numRolls UpdateRollMessage(); // update message label // update message label form.ShowMessage(messages[numRolls]); // Disable roll button if neccesary if (numRolls == 3) { form.DisableRollButton(); } }
}//end ContinueGame /// <summary> /// Link the labels on the GUI form to the dice and players /// </summary> /// <param name="form"></param> private void LoadLabels(Yahtzee form) { Label[] diceLabels = form.GetDice(); for (int i = 0; i < dice.Length; i++) { dice[i].Load(diceLabels[i]); } for (int i = 0; i < players.Count; i++) { players[i].Load(form.GetScoresTotals()); } }
/// <summary> /// Constructor for Game /// </summary> /// <param name="myForm"> Application form </param> public Game(Yahtzee myForm) { numPlayers = 2; form = myForm; currentPlayerIndex = 0; players = new BindingList <Player>(); for (int i = 0; i < numPlayers; i++) { players.Add(new Player("Player " + (i + 1), form.GetScoresTotals())); } currentPlayer = players[currentPlayerIndex]; dice = new Die[Num_Die]; dieLabels = form.GetDice(); for (int i = 0; i < Num_Die; i++) { dice[i] = new Die(dieLabels[i]); } playersFinished = 0; numRolls = 0; }