private void RoundTimer_Tick(object sender, EventArgs e)
        {
            _ticks++;
            int myCountdown = roundLimit - _ticks;

            TimerCountTextbox.Text = myCountdown.ToString();
            if (_ticks == roundLimit)
            {
                RoundTimer.Stop();

                if (PlayerOneGroupbox.Enabled == true)
                {
                    TimeOutSwitch(PlayerOneGroupbox, PlayerTwoGroupbox);
                }
                else if (PlayerTwoGroupbox.Enabled == true)
                {
                    TimeOutSwitch(PlayerTwoGroupbox, PlayerThreeGroupbox);
                }
                else if (PlayerThreeGroupbox.Enabled == true)
                {
                    TimeOutSwitch(PlayerThreeGroupbox, PlayerOneGroupbox);
                }
                StartTimer();
            }
        }
Example #2
0
        }//End PlusLabel

        //Method For Timer
        private void RoundTimer_Tick(object sender, EventArgs e)
        {
            //If Time Remaining Is Not 0 Keep Ticking Down
            //Else Print 'Out Of Time Error'
            if (rtime != 0)
            {
                rtime           = rtime - 1;
                RTimeLabel.Text = rtime + " Seconds";
            }
            else
            {
                RoundTimer.Stop();
                RTimeLabel.Text = "Out Of Time!";
                MessageBox.Show("You Did Not Finish In The Time Allowed!", "Too Bad!");
                DoneButton.PerformClick();
            }//End If Else
            //Make Time Label Red If 10 Seconds Or Less Are Left
            if (rtime <= 10)
            {
                RTimeLabel.BackColor = Color.Red;
            } //End If
        }     //End Round Timer
        private void RoundTimer_Tick(object sender, EventArgs e)
        {
            _ticks++;
            int myCountdown = roundLimit - _ticks;

            TimeCountLabel.Text = myCountdown.ToString();
            if (_ticks == roundLimit)
            {
                RoundTimer.Stop();

                if (PlayerOneGroupbox.Enabled == true)
                {
                    SwitchPlayer(PlayerOneGroupbox, PlayerTwoGroupbox);
                }
                else if (PlayerTwoGroupbox.Enabled == true)
                {
                    SwitchPlayer(PlayerTwoGroupbox, PlayerOneGroupbox);
                }
                _ticks = 0;
                RoundTimer.Start();
            }
        }
        private void GamePlayCompare(Player activeP, Player passiveP, TextBox T, TextBox dispT, GroupBox activeG, GroupBox passiveG)
        {
            string response = activeP.Compare(T, passiveP);

            if (response == null)
            {
                MessageBox.Show("Invalid Entry!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }
            string display = T.Text + " - " + response;

            dispT.Text += display + "\r\n";
            Operation.ScrollTextBox(dispT);
            T.ResetText();
            if (response == Operation.WinWord)
            {
                MessageBox.Show($"{activeP.Name} won", "Game Over", MessageBoxButtons.OK, MessageBoxIcon.Information);
                RoundTimer.Stop();
                activeG.Enabled = false;
                return;
            }
            passiveG.Enabled = true;
            activeG.Enabled  = false;
        }
Example #5
0
        }//End Ready Button Click

        //Events Triggered By Pressing The 'Done' Button
        private void DoneButton_Click(object sender, EventArgs e)
        {
            //Declaring Necessary Variables
            int numright = 0, numwrong = 0, roundscore = 0;

            //Stop Timer and Calculate Number Of Correct Answers
            RoundTimer.Stop();
            if (ooanum + otanum == AAF.Value)
            {
                numright++;
            }//End Add Check If
            if (oosnum - otsnum == SAF.Value)
            {
                numright++;
            }//End Subtract Check If
            if (oomnum * otmnum == MAF.Value)
            {
                numright++;
            }//End Multiply Check If
            if (oodnum / otdnum == DAF.Value)
            {
                numright++;
            }//End Divide Check If
            if (oomodnum % otmodnum == ModAF.Value)
            {
                numright++;
            }//End Mod Check If
            //Events To Perform When 'Done' Button Clicked
            numwrong = 5 - numright;
            NextRoundButton.Enabled = true;
            roundscore = CalcRoundScore(numright, numwrong);
            UpdateScore(roundscore);
            AOLabel.Visible               = true;
            AAnswerLabel.Visible          = true;
            AAnswerLabel.Text             = aresult.ToString();
            ATLabel.Visible               = true;
            CSAnswerLabel.Visible         = true;
            CSAnswerLabel.Text            = sresult.ToString();
            ATHLabel.Visible              = true;
            CMAnswerLabel.Visible         = true;
            CMAnswerLabel.Text            = mresult.ToString();
            AFLabel.Visible               = true;
            CDAnswerLabel.Visible         = true;
            CDAnswerLabel.Text            = dresult.ToString();
            AFiLabel.Visible              = true;
            CModAnswerLabel.Visible       = true;
            CModAnswerLabel.Text          = modresult.ToString();
            DoneButton.Visible            = false;
            DoneButton.Enabled            = false;
            NextRoundButton.Enabled       = true;
            ExitButton.Visible            = true;
            ExitButton.Enabled            = true;
            RSLabel.Visible               = true;
            TopRoundScoreLabel.Visible    = true;
            TopRoundScoreLabel.Text       = numright.ToString();
            BottomRoundScoreLabel.Visible = true;
            LineScoreLabel.Visible        = true;
            AAF.Enabled   = false;
            SAF.Enabled   = false;
            MAF.Enabled   = false;
            DAF.Enabled   = false;
            ModAF.Enabled = false;

            //Message Box To Show The Number Of Points Rewarded After Each Round
            MessageBox.Show(" You Get " + roundscore + " Points! Click 'Next Round' When Ready.", "Results");

            //If User Scores Over 1000 Points Print Message and Picture
            if (totalscore >= 1000)
            {
                WinningPictureBox.Visible = true;
                MessageBox.Show("You Beat The Game! You Have Great Math Skills!", "Congratulations!");
                NextRoundButton.Enabled = false;
                DoneButton.Enabled      = false;
                AAF.Enabled             = false;
                SAF.Enabled             = false;
                MAF.Enabled             = false;
                DAF.Enabled             = false;
                ModAF.Enabled           = false;
                ReplayButton.Enabled    = true;
                ReplayButton.Visible    = true;
                ExitButton.Enabled      = true;
                ExitButton.Visible      = true;
            } //End If
        }     //end Done Button Click
        private void ThreePlayersGameplayCompare(
            RadioButton opp1Radio, RadioButton opp2Radio,
            Player activePlayer, Player opp1, Player opp2,
            TextBox activeNums, TextBox activeDisp, TextBox oppDisp, TextBox otherOppDisp,
            GroupBox activeGrp, GroupBox opp1Grp, GroupBox opp2Grp)
        {
            string response = null, display = null;

            //Check which player is selected for number comparison
            if (opp1Radio.Checked && opp1.IsActive)
            {
                response = activePlayer.Compare(activeNums, opp1);
            }

            else if (opp2Radio.Checked && opp2.IsActive)
            {
                response = activePlayer.Compare(activeNums, opp2);
            }

            else
            {
                MessageBox.Show("Choose an opponent in the game", "Notification"); return;
            }

            //Variable to store which player has been selected
            var opponent = (opp1Radio.Checked) ? opp1 : opp2;
            //Variable to hold other players who should get the result
            var otherOpponent = (opp1Radio.Checked) ? otherOppDisp : oppDisp;

            if (response == null)
            {
                MessageBox.Show("Invalid Entry!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
            }

            display = activeNums.Text + " - " + response + $" ({opponent.Name})";
            //Carriage return plus a new line
            activeDisp.Text    += display + "\r\n";
            otherOpponent.Text += display + "\r\n";
            Operation.ScrollTextBox(activeDisp);
            Operation.ScrollTextBox(otherOpponent);
            activeNums.ResetText();

            if (response == Operation.WinWord)
            {
                RoundTimer.Stop();
                MessageBox.Show($"{opponent.Name} is out of the game");
                activeGrp.Enabled = false;
                opponent.IsActive = false;
                if (opp1.IsActive)
                {
                    opp1Grp.Enabled = true;
                }
                else if (opp2.IsActive)
                {
                    opp2Grp.Enabled = true;
                }
                else
                {
                    RoundTimer.Stop(); MessageBox.Show($"{activePlayer.Name} has won", "Congratulations", MessageBoxButtons.OK);
                }
                return;
            }
            activeGrp.Enabled = false;
            if (opp1.IsActive)
            {
                opp1Grp.Enabled = true;
            }
            else if (opp2.IsActive)
            {
                opp2Grp.Enabled = true;
            }
        }