}//end throwButton private void timer1_Tick(object sender, EventArgs e) { Two_Up_Game.IncrementCounter(); bool heads = true; bool tails = false; int counter = Two_Up_Game.GetCounter(); if ((counter == 1) || (counter == 3) || (counter == 5) || (counter == 7) || (counter == 9)) { UpdatePictureBoxImage(pictureBox1, heads); UpdatePictureBoxImage(pictureBox2, heads); } else if ((counter == 2) || (counter == 4) || (counter == 6) || (counter == 8)) { UpdatePictureBoxImage(pictureBox1, tails); UpdatePictureBoxImage(pictureBox2, tails); } else { timer1.Stop(); Two_Up_Game.TossCoins(); //tosses the coins UpdateImage(); //updates the images with correct images label1.Text = Two_Up_Game.TossOutcome(); //updates label1 with the outcome of the toss label1.Visible = true; //makes label1 visible label3.Text = Two_Up_Game.GetPlayersScore().ToString(); //updates player's score when outcome is heads label5.Text = Two_Up_Game.GetComputersScore().ToString(); //updates computer's score when outcome is tails playButton.Visible = true; //makes 'play' button visible } }
public Two_Up() { InitializeComponent(); label1.Visible = false; playButton.Visible = false; Two_Up_Game.SetUpGame(); UpdateImage(); }//end Two_Up form constructor
public Two_Up() { InitializeComponent(); Two_Up_Game.SetUpGame(); againButton.Visible = false; pictureBox1.Visible = true; pictureBox2.Visible = true; label5.Visible = false; }
}// end UpdatePictureBoxImage // A throw button will be implemented where a timer will start (where multiple coins faces // will be seen before the outcome happens) private void throwButton_Click(object sender, EventArgs e) { counter = 0; timer1.Start(); if (Two_Up_Game.TossOutcome() == "Heads" || Two_Up_Game.TossOutcome() == "Tails") { throwButton.Enabled = false; againButton.Visible = true; } }
/// <summary> /// creates the delay for the coin flip animation /// calls toss coin funcation /// </summary> private void timer1_Tick(object sender, EventArgs e) { UpdatePictureBoxImage(pictureBox1, temp); UpdatePictureBoxImage(pictureBox2, !temp); temp = !temp; if (timerClickCounter == 10) { Two_Up_Game.TossCoins(); label1.Text = Two_Up_Game.TossOutcome(); UpdateScores(); UpdateImages(); timer1.Stop(); } else { timerClickCounter++; label1.Visible = true; } }
// a timer click will be implemented, where during the throw button, the coin will // siphon through either heads or tails until after a certain time, it will then land and choose // either heads or tails private void timer1_Tick(object sender, EventArgs e) { counter += 1; Two_Up_Game.TossCoin(); UpdatePictureBoxImage(pictureBox1, Two_Up_Game.IsHeads(0)); UpdatePictureBoxImage(pictureBox2, Two_Up_Game.IsHeads(1)); label5.Visible = true; label5.Text = Two_Up_Game.TossOutcome(); throwButton.Enabled = false; if (counter == 10) { timer1.Stop(); if (Two_Up_Game.TossOutcome() == "Odd") { throwButton.Enabled = true; } playernumberLabel.Text = Convert.ToString(Two_Up_Game.GetPlayersScore()); computernumberLabel.Text = Convert.ToString(Two_Up_Game.GetComputersScore()); } }
}// End DisplayGuiHand /// <summary> /// Deals 2 card for plays and Deaker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Two_Up_Game.SetUpGame(); hit.Enabled = true; stand.Enabled = true; Twenty_One_Game.SetUpGame(); busted1.Visible = false; busted2.Visible = false; Twenty_One_Game.DealOneCardTo(Twenty_One_Game.DEALER); Twenty_One_Game.DealOneCardTo(Twenty_One_Game.DEALER); Twenty_One_Game.DealOneCardTo(Twenty_One_Game.PLAYER); Twenty_One_Game.DealOneCardTo(Twenty_One_Game.PLAYER); hit.Enabled = true; stand.Enabled = true; Hand HandForPlayer = Twenty_One_Game.GetHand(Twenty_One_Game.PLAYER); Hand HandForDealer = Twenty_One_Game.GetHand(Twenty_One_Game.DEALER); Twenty_One_Game.CalculateHandTotal(Twenty_One_Game.PLAYER); ppoints.Text = String.Format("{0}", Twenty_One_Game.GetTotalPoints(Twenty_One_Game.PLAYER)); hpoints.Text = String.Format("{0}", Twenty_One_Game.CalculateHandTotal(Twenty_One_Game.DEALER)); DisplayGuiHand(HandForDealer, tableLayoutPanel1); DisplayGuiHand(HandForPlayer, tableLayoutPanel2); }
/// <summary> /// Reset form hides label /// </summary> private void ResetForm() { Two_Up_Game.SetUpGame(); UpdateScores(); label1.Visible = false; }
/// <summary> /// Updates Scores /// </summary> private void UpdateScores() { playerScore.Text = Two_Up_Game.GetPlayersScore().ToString(); computerScore.Text = Two_Up_Game.GetComputersScore().ToString(); }
}// end UpdatePictureBoxImage /// <summary> /// Updates the pictureboxs /// </summary> private void UpdateImages() { UpdatePictureBoxImage(pictureBox1, Two_Up_Game.IsHeads(1)); UpdatePictureBoxImage(pictureBox2, Two_Up_Game.IsHeads(2)); }
int timerClickCounter; // Keeps track of the number of flip animations /// <summary> /// Initialises class variables and initilises the default coin images /// </summary> public Two_Up() { InitializeComponent(); Two_Up_Game.SetUpGame(); UpdateImages(); }
}//end playButton private void throwButton_Click(object sender, EventArgs e) { Two_Up_Game.InitCounter(); throwButton.Enabled = false;//disables 'throw' button again timer1.Start(); }//end throwButton
}//end Two_Up form constructor private void UpdateImage() { UpdatePictureBoxImage(pictureBox1, Two_Up_Game.IsHeads(1)); //updates picturebox1 with coin image UpdatePictureBoxImage(pictureBox2, Two_Up_Game.IsHeads(2)); //updates picturebox2 with coin image }//end UpdateImage