private void TmrCountdown_Tick(object sender, EventArgs e)
        {                                            // On tick of the TmrCountdown
            TimerCount--;                            // Decrease one from the timer
            LblToStart.Text = TimerCount.ToString(); // Display the timer value on the panel

            if (TimerCount == 3)
            {                                // If the timer value is equal to 3
                LblGameStart.Visible = true; // Display the time till game start text
            }

            if (TimerCount == 0)
            {                                 // If the timer value is equal to 0
                LblToStart.Visible   = false; // Hide the second countdown
                LblGameStart.Visible = false; // Hide the time till game start text

                ButtonClicked = 1;            // Set the button as clicked

                // Enable the games timers
                TmrShark.Enabled       = true;
                TmrSurfer.Enabled      = true;
                BottleTimer.Enabled    = true;
                BottleTimeWait.Enabled = true;

                TmrCountdown.Stop(); // Stop the TmrCountdown

                TmrPopUp.Start();
                LblPopUp.Visible = true; // Display the popup text
                LblPopUp.Text    = "Game started";
            }
        }
        private void BtnHard_Click(object sender, EventArgs e)
        {     // If the user clicks on the hard difficulty button
            if (UsernameValid == 0)
            { // If the user name is valid
                // Show the countdown to the game starts
                LblToStart.Visible   = true;
                LblGameStart.Visible = true;

                // Display the sidebar elements such as lives textbox, lives label, etc
                LvlCount.Visible      = true;
                LvlTxt.Visible        = true;
                ScoreCount.Visible    = true;
                ScoreTxt.Visible      = true;
                label1.Visible        = true;
                LvsCount.Visible      = true;
                LvsTxt.Visible        = true;
                LevelProgress.Visible = true;
                LblName.Visible       = true;

                // Hide the welcome to game message, username, instructions
                LblInstructions.Visible = false;
                TbUsername.Visible      = false;
                LblWelcome.Visible      = false;
                LblUsername.Visible     = false;

                // Hide the difficulty buttons
                BtnHard.Visible   = false;
                BtnMedium.Visible = false;
                BtnEasy.Visible   = false;

                // Disable the difficulty buttons to allow the surfer to move
                BtnHard.Enabled   = false;
                BtnMedium.Enabled = false;
                BtnEasy.Enabled   = false;

                // Disable the timers
                TmrShark.Enabled       = false;
                TmrSurfer.Enabled      = false;
                BottleTimer.Enabled    = false;
                BottleTimeWait.Enabled = false;

                lives       = 1;                             // Set the lives count to 1
                LvsTxt.Text = lives.ToString();              // Display the lives count in the LvsText textbox

                TmrCountdown.Start();                        // Start the countdown timer

                LblName.Text = "Welcome " + TbUsername.Text; // Edit the text to say Welcome then their name

                TmrPopUp.Start();
                LblPopUp.Visible = true; // Display the popup text
                LblPopUp.Text    = "Hard difficulty selected";
            }
        }
示例#3
0
        private void TmrCountdown_Tick(object sender, EventArgs e)
        {
            count--;                         //decrease count by 1
            LblTime.Text = count.ToString(); //display count in LblTime

            if (count == 0)
            {
                TmrCountdown.Stop();
                TmrAlien.Stop();
                LblScore.Enabled = false;
                LblTime.Enabled  = false;
                MessageBox.Show("Game Over!");
            }
        }
示例#4
0
        private void PnlGame_MouseDown(object sender, MouseEventArgs e)
        {
            int    diffX  = e.X - alienRec.X;
            int    diffY  = e.Y - alienRec.Y;
            double length = Math.Sqrt(Math.Pow(diffX, 2) + Math.Pow(diffY, 2));

            if (length < 70)
            {
                score++;                          //add 1 to the score
                LblScore.Text = score.ToString(); // display the score
            }
            if (score == 10)
            {
                TmrAlien.Interval -= 70;
                label8.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 20)
            {
                TmrAlien.Interval -= 95;
                label5.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 30)
            {
                TmrAlien.Interval -= 150;
                label6.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 40)
            {
                TmrAlien.Interval -= 190;
                label7.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 50)
            {
                label9.ForeColor = System.Drawing.Color.Green;
                TmrCountdown.Stop();
                TmrAlien.Stop();
                LblScore.Enabled = false;
                LblTime.Enabled  = false;
                MessageBox.Show("Game Over! You win");
            }
        }
示例#5
0
 private void MnuStart_Click(object sender, EventArgs e)
 {
     score = 0;
     TmrAlien.Start(); //start the timer
     TmrCountdown.Start();
 }