// this sets what happens when we click the button to roll the dice for player 1 private void btn_p1RollDice_Click(object sender, EventArgs e) { // if player 1 has not played if (!player1.Played) { player1.RollDice(); // roll the dice for player one // Here we set the images for the dice for player 1 after the roll. // // When we used the RollDice() method to roll the dice we stored the // results for each of them in the dice[] array located inside the player object. // We access this by using the getter Dice to return the values located in the private // dice array inside the player object. // // So we need to know which image in the diceImages array to set the label image to... // How do we do that? Well we take the dice result for each die using the Dice getter // which will be a 1, 2, 3, 4, 5, 6 and use that as the index of the diceImages array // to set the label image to the proper image to reflect the players roll. // // So if the first die player1 rolled was a 4 we would get this number by using player1.Dice[0] // we would use 0 because that is the first index of the array and this would return 4 to us. Now // we need to get the picture for a die showing side 4. If you notice that diceImages[0] is the blank // die image and then starting with 1 through 6 it is the images for a die showing 1 through 6. So we // would get this image simply by passing the diceImages array an index of the value rolled for each // die. So diceImages[player1.Dice[0]] would simply be diceImages[4] since the first die rolled is 4 // and this will set the label to the proper image. lbl_p1Dice1.Image = diceImages[player1.Dice[0]]; lbl_p1Dice2.Image = diceImages[player1.Dice[1]]; lbl_p1Dice3.Image = diceImages[player1.Dice[2]]; lbl_p1Dice4.Image = diceImages[player1.Dice[3]]; lbl_p1Dice5.Image = diceImages[player1.Dice[4]]; lbl_p1DisplayResults.Text = player1.Result; // now that player1 has rolled set that they have played player1.Played = true; // this will check after each roll to see if both players have rolled // and if they have it will check their dice to see who wins or if it is a tie CheckWinner(); } }
public bool ContinueTurn() { diceRollList = currentPlayer.RollDice(dice); if (!CompareToKillList()) { DisplayTurnOverScreen(); return(true); } else { CreateDiceRollString(); AddScore(); DisplayScreen(); cursorX = 4; cursorY = 19; SetCursor(); currentPlayer.GetPause(); } killList = currentPlayer.BuildKillList(); return(currentPlayer.score <= 0); }