示例#1
0
//Start the Game
        private void GameTimer_Start(object sender, EventArgs e)
        {
            Invalidate();
            BG.BackGroundMove();
            BG1.BackGroundMove();
            moveTheRocekts();
            moveTheBullets();
            if (!BosFight)
            {
                EnemyPlaneMove();
            }
            else
            {
                boss.move();
                moveBossRocket();
            }
            moveClouds();
            int min = TimeLeft / 60;
            int sec = TimeLeft % 60;

            TimerLabel.Text     = string.Format("{0:00}:{1:00}", min, sec);
            ScoreLabel.Text     = string.Format("High Score: {0}", scoore.getScore());
            RemainingLifes.Text = string.Format("Player Lifes: {0}", playerPlane.getPlayerLife());
            if (TimeLeft == 60)
            {
                BosFight = true; BosRocketTimer.Enabled = true; BosLife.Visible = true;
            }
            if (playerPlane.getPlayerLife() == 0 || TimeLeft == 0)
            {
                freezScreen();
                sounds.playGameOverMusic();
                if (MessageBox.Show(string.Format("You lost.\nHigh score: {0}\t Time left: {1}:{2}\nDo you want to play again ?", scoore.getScore(), TimeLeft / 60, TimeLeft % 60), "Game Over", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    Run();
                }
                else
                {
                    Close();
                }
            }
            else if (boss.getLife() == 0)
            {
                freezScreen();
                sounds.playMissionComplete();
                ScoreLabel.Text = string.Format("High Score: {0}", scoore.getScore() + 10000);
                if (MessageBox.Show(string.Format("You wooooon\nHigh score: {0}\t  Time left: {1}:{2}\t Lifes: {3}\nDo you want to play again ?", scoore.getScore() + 10000, TimeLeft / 60, TimeLeft % 60, playerPlane.getPlayerLife()), "You won !!", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    Run();
                }
                else
                {
                    Close();
                }
            }
        }