Ejemplo n.º 1
0
        private void btnScore_Click(object sender, EventArgs e)
        {
            FinalScore final = new FinalScore();

            this.Hide();
            final.ShowDialog();
            this.Dispose();
            this.Close();
        }
Ejemplo n.º 2
0
        public void EndGame()
        {
            if (game.EndGame)
            {
                timer.Dispose();
                timer.Enabled = false;
                timer2.Dispose();
                timer2.Enabled      = false;
                pictureBox1.Visible = true;
                DialogResult dialogResault = MessageBox.Show(string.Format("Your score is {0}", game.Points), "END GAME", MessageBoxButtons.OK);
                Menu         menu          = new Menu();
                FinalScore   final         = new FinalScore();

                if (game.Points >= max)
                {
                    SetValueForFinalePoints = game.Points;
                    max = SetValueForFinalePoints;
                }
                this.Hide();
                menu.ShowDialog();
                this.Dispose();
                this.Close();
            }
        }
Ejemplo n.º 3
0
        public void NewGame()
        {
            if (ball.isNewGame)
            {
                game.ClearBall();
                if (Misses > 1)
                {
                    ball      = new Ball(new Point(BallX, BallY));
                    rectangle = new Rectangle(RectangleX, RectangleY);
                    isMoved   = 0;
                    Misses--;
                    timer.Enabled = false;
                    timer.Dispose();
                    timer2.Enabled = false;
                    timer2.Dispose();
                    progrssBar.Value = 0;
                    timer            = new Timer();
                    timer.Interval   = 30;
                    timer.Tick      += new EventHandler(timer_Tick);
                    timer.Start();
                    if (supriseCount <= 4)
                    {
                        lblSuprise.ForeColor = Color.Red;
                        isClickedSurprise    = true;
                    }
                }
                else if (Misses == 1)
                {
                    timer.Enabled = false;

                    DialogResult dialogResault = MessageBox.Show("Do you want to play again?", "GAME OVER", MessageBoxButtons.RetryCancel);

                    if (dialogResault == DialogResult.Retry)
                    {
                        timer          = new Timer();
                        timer.Interval = 30;
                        timer.Tick    += new EventHandler(timer_Tick);
                        timer.Start();

                        game.ClearBall();
                        ball          = new Ball(new Point(BallX, BallY));
                        rectangle     = new Rectangle(RectangleX, RectangleY);
                        game          = new Game();
                        bonusGame     = new BonusGame();
                        isBall2       = false;
                        isNewBall     = false;
                        isClickedMore = false;

                        Misses   = 3;
                        isMoved  = 0;
                        CountTwo = 1;
                        timer2.Dispose();
                        timer2.Enabled   = false;
                        progrssBar.Value = 0;

                        SetValueForFinalePoints = 0;
                        suprise              = 0;
                        supriseCount         = 0;
                        lblSuprise.ForeColor = Color.Red;
                        isClickedSurprise    = true;

                        lblMore.ForeColor = Color.Coral;
                        lblTwo.ForeColor  = Color.Coral;
                    }
                    else
                    {
                        try
                        {
                            timer.Dispose();
                            timer.Enabled = false;
                            timer2.Dispose();
                            timer2.Enabled = false;
                            Menu       menu  = new Menu();
                            FinalScore final = new FinalScore();

                            if (game.Points >= max)
                            {
                                SetValueForFinalePoints = game.Points;
                                max = SetValueForFinalePoints;
                            }
                            this.Hide();
                            menu.ShowDialog();
                            this.Dispose();
                            this.Close();
                        }
                        catch { }
                    }
                }

                if (isBall2)
                {
                    game.Balls.Remove(ball_2);
                    isBall2 = false;
                }
            }
            lblLives.Text  = Misses.ToString();
            lblPoints.Text = game.Points.ToString();
        }