}//end playButton

        private void rollButton_Click(object sender, EventArgs e)
        {
            Snake_Eyes_Game.InitCounter();
            timer1.Enabled = true;
            timer1.Start();
            rollButton.Enabled = false;
        }//end rollButton
 public Snake_Eyes()
 {
     InitializeComponent();
     dummyTextLabel.Visible = false;
     playButton.Enabled     = false;
     Snake_Eyes_Game.SetUpGame();
     UpdateImage();
 }//end Snake_Eyes form constructor
Esempio n. 3
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();
        }
Esempio n. 4
0
        public Snake_Eyes()
        {
            //First must set up snake eyes where the game is initated

            InitializeComponent();
            first = true;
            Snake_Eyes_Game.SetUpGame();
            dummyLabel.Visible      = false;
            label1.Visible          = true;
            rollPictureBox1.Visible = false;
            rollPictureBox2.Visible = false;
            playagainButton.Enabled = false;
        }
Esempio n. 5
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++;
            }
        }
        }//end Snake_Eyes form constructor

        private void cancelButton_Click(object sender, EventArgs e)
        {
            if (Snake_Eyes_Game.GetPlayersPoints() > Snake_Eyes_Game.GetHousePoints())
            {
                MessageBox.Show("You won! Well done.");
                this.Close();
            }
            else if (Snake_Eyes_Game.GetPlayersPoints() < Snake_Eyes_Game.GetHousePoints())
            {
                MessageBox.Show("House won! Better luck next time.");
                this.Close();
            }
            else
            {
                MessageBox.Show("It was a draw!");
                this.Close();
            } //end if-else
        }     //end cancelButton
Esempio n. 7
0
        /// <summary>
        /// Quit the game and giving final results
        /// </summary>
        private void cancel(object sender, EventArgs e)
        {
            string cancel = "";

            if (Snake_Eyes_Game.GetHousePoints() > Snake_Eyes_Game.GetPlayersPoints())
            {
                cancel = "You Lose";
            }
            else
            {
                cancel = "You won";
            }

            cancel += String.Format(" Scores:\n|  PLayer:  {0}    |   House:   {1}  |", Snake_Eyes_Game.GetPlayersPoints(), Snake_Eyes_Game.GetHousePoints());
            MessageBox.Show(cancel);

            this.Close();
        }
Esempio n. 8
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
        }
        }//end rollButton

        private void UpdateImage()
        {
            UpdatePictureBoxImage(pictureBox1, Snake_Eyes_Game.GetDieFaceValue(1)); //updates picturebox1 with die image
            UpdatePictureBoxImage(pictureBox2, Snake_Eyes_Game.GetDieFaceValue(2)); //updates picturebox2 with die image
        }//end UpdateImage
        }     //end cancelButton

        private void playButton_Click(object sender, EventArgs e)
        {
            rollButton.Enabled = true;
            playButton.Visible = false;
            Snake_Eyes_Game.SetUpGame();
        }//end playButton
Esempio n. 12
0
 /// <summary>
 /// Updates pictureboxs
 /// </summary>
 private void UpdateImages()
 {
     UpdatePictureBoxImage(pictureBox1, Snake_Eyes_Game.GetDiceFaceValue(0));
     UpdatePictureBoxImage(pictureBox2, Snake_Eyes_Game.GetDiceFaceValue(1));
 }
Esempio n. 13
0
 public Snake_Eyes()
 {
     InitializeComponent();
     Snake_Eyes_Game.SetUpGame();
     UpdateImages();
 }