/// <summary> /// "Help" function to update the form with the game value /// </summary> void FormUpdate() { diePictureBox.Image = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue()); // Set the image to the die value TotalPointsPlayer1.Text = Pig_Single_Die_Game.GetPointsTotal("Player 1").ToString(); // Set the Player 1 points label to player 1's points TotalPointsPlayer2.Text = Pig_Single_Die_Game.GetPointsTotal("Player 2").ToString(); // Set the Player 2 points label to player 2's points textLine1.Text = Pig_Single_Die_Game.GetThisPlayer(); // Set the information text's first line to the player name textLine2.Text = (HoldBtn.Enabled) ? "Roll or Hold" : "Roll Die"; // Set the information text's second line to the player's available action }
/// <summary> /// Count the points in real time as player rolls the die. /// </summary> private void CountPoints() { if (pigLabelWhosTurnTo.Text == "Player 1") { playerOneTextBox.Text = (Int32.Parse(playerOneTextBox.Text) + Pig_Single_Die_Game.GetFaceValue()).ToString(); } else { playerTwoTextBox.Text = (Int32.Parse(playerTwoTextBox.Text) + Pig_Single_Die_Game.GetFaceValue()).ToString(); } }
/// <summary> /// Rolls die through .PlayGame(), updates image, changes player, checks for wins /// Updates WhosTurnToLabel, updates textbox, enables groupbox. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RollButton_Click(object sender, EventArgs e) { if (Pig_Single_Die_Game.current_player == 1) { Pig_Single_Die_Game.PlayGame(); PictureBox.Image = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue()); PlayerOneTotalTextBox.Text = Pig_Single_Die_Game.overall_points.ToString(); if (Pig_Single_Die_Game.did_roll_one == 1) { MessageBox.Show("You have thrown a 1.\n Your turn is over!\n Your overall_points reverts to " + Pig_Single_Die_Game.GetPointsTotal() + "!"); Pig_Single_Die_Game.current_player = 2; WhoseTurnToLabel.Text = "Player 2"; } if (Pig_Single_Die_Game.HasWon()) { MessageBox.Show("Player 1 has won!\n Well done!"); AnotherGameGroupBox.Enabled = true; } } else if (Pig_Single_Die_Game.current_player == 2) { Pig_Single_Die_Game.PlayGame(); PictureBox.Image = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue()); PlayerTwoTotalTextBox.Text = Pig_Single_Die_Game.overall_points.ToString(); if (Pig_Single_Die_Game.did_roll_one == 1) { MessageBox.Show("You have thrown a 1.\n Your turn is over!\n Your overall_points reverts to " + Pig_Single_Die_Game.GetPointsTotal() + "!"); Pig_Single_Die_Game.current_player = 1; WhoseTurnToLabel.Text = "Player 1"; Pig_Single_Die_Game.did_roll_one = 0; } if (Pig_Single_Die_Game.HasWon()) { MessageBox.Show("Player 2 has won!\n Well done!"); AnotherGameGroupBox.Enabled = true; } } }//end of RollButton_Click
/// <summary> /// Render the die images. /// </summary> private void renderImage() { pigPictureBox.Image = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue()); pigPictureBox.SizeMode = PictureBoxSizeMode.StretchImage; }
public Pig_Game_Form() { InitializeComponent(); Pig_Single_Die_Game.SetUpGame(); PictureBox.Image = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue()); }
// Created Methods /// <summary> /// Sets the die image based on the values rolled /// </summary> private void SetDieImage() { picDie.Image = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue()); } // end SetDieImage