Exemplo n.º 1
0
        /// <summary>
        /// roll dice get roll out come and checks to see if need to roll again gets points
        /// </summary>
        private void roldice(object sender, EventArgs e)
        {
            if (!secondRoll)
            {
                secondRoll = Snake_Eyes_Game.FirstRoll();
                if (!secondRoll)
                {
                    result.Text = (Snake_Eyes_Game.GetPlayersPoints() > 0) ? won : (Snake_Eyes_Game.GetHousePoints() > 0) ? lose : draw;
                    if (Snake_Eyes_Game.GetRollTotal() == 2)
                    {
                        dummyLabel.Text = string.Format(pointsWon, 2);
                    }
                    else if (Snake_Eyes_Game.GetRollTotal() == 7 || Snake_Eyes_Game.GetRollTotal() == 11)
                    {
                        dummyLabel.Text = string.Format(pointsWon, 1);
                    }
                    else if (Snake_Eyes_Game.GetRollTotal() == 3 || Snake_Eyes_Game.GetRollTotal() == 12)
                    {
                        dummyLabel.Text = string.Format(pointsLost, 2);
                    }
                }
                else
                {
                    result.Text     = rollAgain;
                    dummyLabel.Text = string.Format(requiredPoints, Snake_Eyes_Game.GetPossiblePoints());
                }
            }
            else
            {
                anotherRoll = Snake_Eyes_Game.AnotherRoll();
                secondRoll  = false;
                result.Text = (Snake_Eyes_Game.GetPlayersPoints() > 0) ? won : (Snake_Eyes_Game.GetHousePoints() > 0) ? lose : draw;
                if (!anotherRoll)
                {
                    dummyLabel.Text = string.Format(pointsWon, Snake_Eyes_Game.GetPossiblePoints());
                }
                else if (Snake_Eyes_Game.GetRollTotal() == 7)
                {
                    dummyLabel.Text = string.Format(pointsLost, 2);
                }
                else
                {
                    dummyLabel.Text = nothing;
                }
            }
            dummyLabel.Visible = true;
            playerScore.Text   = Snake_Eyes_Game.GetPlayersPoints().ToString();
            houseScore.Text    = Snake_Eyes_Game.GetHousePoints().ToString();
            playAgain.Enabled  = true;
            rollDice.Enabled   = false;
            Cancel.Enabled     = true;

            UpdateImages();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Trying to get animations working no idea
        /// </summary>
        private void timer1_Tick(object sender, EventArgs e)
        {
            ///tempDiceState = 1;
            if (timerClickCounter == 10)
            {
                Snake_Eyes_Game.AnotherRoll();

                timer1.Stop();
            }
            else
            {
                timerClickCounter++;
            }
        }
Exemplo n.º 3
0
        //The click button now must be created to have an if statement within it to make sure
        // that if certain numbers are rolled at the first roll, it will then ask to play again

        private void button1_Click(object sender, EventArgs e)
        {
            if (first)
            {
                Snake_Eyes_Game.FirstRoll();
                switch (Snake_Eyes_Game.GetRollTotal())
                {
                case 2:
                    button1.Enabled = false;
                    break;

                case 3:
                    button1.Enabled = false;
                    break;

                case 7:
                    button1.Enabled = false;
                    break;

                case 11:
                    button1.Enabled = false;
                    break;

                case 12:
                    button1.Enabled = false;
                    break;
                }
                rollPictureBox1.Visible = true;
                rollPictureBox2.Visible = true;
                first = false;
            }
            else
            {
                Snake_Eyes_Game.AnotherRoll();
            }
            dummyLabel.Visible      = true;
            playagainButton.Enabled = true;
            UpdatePictureBoxImage(rollPictureBox1, Snake_Eyes_Game.GetDiceFacevalue(0));
            UpdatePictureBoxImage(rollPictureBox2, Snake_Eyes_Game.GetDiceFacevalue(1));
            playerscoreLabel.Text = Snake_Eyes_Game.GetPlayerPoints().ToString();
            housescoreLabel.Text  = Snake_Eyes_Game.GetHousePoints().ToString();
            dummyLabel.Text       = Snake_Eyes_Game.GetPossiblePoints().ToString();
            label1.Text           = Snake_Eyes_Game.GetRollOutcome().ToString();
        }
        }//unintentional event-handler

        private void timer1_Tick(object sender, EventArgs e)
        {
            bool   temp1;
            bool   temp2;
            string output;
            string headline;
            int    counter;
            Random random = new Random();

            Snake_Eyes_Game.IncrementCounter();     //increments counter
            counter = Snake_Eyes_Game.GetCounter(); //gets counter

            int faceValue = random.Next(1, 6);      //creates random number between 1 and 6

            if (counter < 9)
            {
                UpdatePictureBoxImage(pictureBox1, faceValue); //updates pictureBox1 with random face value
                UpdatePictureBoxImage(pictureBox2, faceValue); //updates pictureBox2 with random face value
            }
            else
            {
                timer1.Stop();                           //stops timer
                Snake_Eyes_Game.RollDice();              //rolls dice
                if (Snake_Eyes_Game.RollCount() < 2)     //if rollcount is less than 2
                {
                    temp1 = Snake_Eyes_Game.FirstRoll(); //execute FirstRoll()
                    if (temp1 == false)
                    {
                        playButton.Enabled = true;
                        playButton.Visible = true;
                    }
                    else
                    {
                        rollButton.Enabled = true;
                    }//end if
                }
                else if (Snake_Eyes_Game.RollCount() >= 2)
                {
                    rollButton.Enabled = true;
                    temp2 = Snake_Eyes_Game.AnotherRoll();
                    if (temp2 == false)
                    {
                        playButton.Enabled = true;
                        playButton.Visible = true;
                        rollButton.Enabled = false;
                    }
                    else
                    {
                        rollButton.Enabled = true;
                    } //end if
                }     //end else-if

                UpdateImage();//updates dice images with new face values
                output = Snake_Eyes_Game.GetRollOutcome();                              //creates output variable
                dummyTextLabel.Text    = output;                                        //displays output in dummy label
                dummyTextLabel.Visible = true;                                          //makes dummy label visible
                headline               = Snake_Eyes_Game.GetRollHeadline();             //creates headline variable
                firstRollLabel.Text    = headline;                                      //displays headline on form
                playersScoreLabel.Text = Snake_Eyes_Game.GetPlayersPoints().ToString(); //displays players points on form
                houseScoreLabel.Text   = Snake_Eyes_Game.GetHousePoints().ToString();   //displays house points on form
            }//end else
        }