コード例 #1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (time_count == 10)
     {
         time_count = 0;
         timer1.Stop();
         if (Pig_Double_Die_Game.PlayGame() == true)
         {
             MessageBox.Show("Sorry you have thrown a 1\n Your turn is over!\n");
             if (Pig_Double_Die_Game.current_player == "Player 1")
             {
                 Whose_Turn_to_label.Text             = "Player 2 Roll Die";
                 Pig_Double_Die_Game.current_player   = "Player 2";
                 Pig_Double_Die_Game.current_dice_sum = 0;
             }
             else
             {
                 Whose_Turn_to_label.Text             = "Player 1 Roll Die";
                 Pig_Double_Die_Game.current_player   = "Player 1";
                 Pig_Double_Die_Game.current_dice_sum = 0;
             }
         }
         else
         {
         }
     }
     else
     {
         time_count++;
         pictureBox1.Image = Games.Images.GetDieImage(Pig_Double_Die_Game.GetFaceValue()[0]);
         pictureBox2.Image = Games.Images.GetDieImage(Pig_Double_Die_Game.GetFaceValue()[1]);
     }
 }
コード例 #2
0
        /// <summary>
        /// Play the game when the dice animation is clicked and determine the outcome of the round.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void playGame()
        {
            enableButtons(true);
            int points = Pig_Double_Die_Game.GetPointsTotal(pigLabelWhosTurnTo.Text);

            if (!Pig_Double_Die_Game.PlayGame())
            {
                SetupRound();
                CountPoints();
            }
            else
            {
                SetupRound();
                UpdatePoints(points);
                Program.showOKMessageBox("Sorry, you've thrown a 1.\nYour turn is over.\nYour score reverts to " + points + ".");
                pigLabelWhosTurnTo.Text = Pig_Double_Die_Game.GetNextPlayersName();
            }

            if (Pig_Double_Die_Game.HasWon())
            {
                WonGame();
            }
        }