コード例 #1
0
 private void HoldButton_Click(object sender, EventArgs e)
 {
     Pig_Double_Dice_Game.SetThisPlayer(Pig_Double_Dice_Game.GetNextPlayersName());     // Move to next player
     HoldBtn.Enabled = false;
     UpdateForm();
 }
コード例 #2
0
 /// <summary>
 /// "Help" function that is called at the end of the timer, updates buttons according the game rules and links the GUI with the game logic library
 /// </summary>
 private void Roll()
 {
     HoldBtn.Enabled = true;      // Enabled the hold button once a die has been thrown
     if (Pig_Double_Dice_Game.PlayGame())
     {                            // If a 1 has been thrown
         HoldBtn.Enabled = false; // Disable the hold button
         UpdateForm();
         MessageBox.Show("Sorry you have thrown a 1.\nYour turn is over!\nYour score reverts to " + Pig_Double_Dice_Game.GetPointsTotal(Pig_Double_Dice_Game.GetNextPlayersName()));
     }
     else
     {
         UpdateForm();
         if (Pig_Double_Dice_Game.HasWon())
         { // If a player has won the game
             MessageBox.Show(Pig_Double_Dice_Game.GetThisPlayer() + " has won!\nWell done.");
             // Disable gameplay buttons until the user makes a choice whether to play again
             RollBtn.Enabled = false;
             HoldBtn.Enabled = false;
             // Enable the user to make a choice whether to play again
             GameTerminal.Enabled = true;
         }
     }
 }