//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(); } } }
//Function to re-load the scene if we want to play again. public void Run() { // Get max Width and max height of the Form maxWidth = this.ClientSize.Width; maxHeight = this.ClientSize.Height; // Make the players playerPlane = new PlayerPlane(maxWidth, maxHeight); //Make enemy planes and fill the list Planes = new List <EnemyPlane>(); fillList(); //Make the Boss and his Rocket boss = new Boss(300, 20, this.ClientSize.Width); bossRockets = new List <Rocket>(); //Check if there is a boss on the screen BosFight = false; // Set the Backgounds [2 Backgrounds repeteng them selfs] BG = new BackGround(-764); BG1 = new BackGround(0); //Make Clouds on the screen clouds = new List <cloud>(); fillClouds(); // Set the buffer this.DoubleBuffered = true; // Set the Blast Image, Scores, Remaining lifes, Time left, and Boss HP bar Blast = false; Images = new BlastImages(); scoore = new HighScore(); ScoreLabel.Text = string.Format("High Score: {0}", scoore.getScore()); RemainingLifes.Text = string.Format("Player Lifes: {0}", playerPlane.getPlayerLife()); TimeLeft = 180; BosLife.Visible = false; BosLife.Value = boss.getLife(); //Set the sounds sounds = new Sounds(); sounds.playMainMusic(); //Get the timers Ready GameTimer.Enabled = true; PlayerTime.Enabled = true; }
//Function to re-load the scene if we want to play again. public void Run() { // Get max Width and max height of the Form maxWidth = this.ClientSize.Width; maxHeight = this.ClientSize.Height; // Make the players playerPlane = new PlayerPlane(maxWidth, maxHeight); //Make enemy planes and fill the list Planes = new List<EnemyPlane>(); fillList(); //Make the Boss and his Rocket boss = new Boss(300, 20, this.ClientSize.Width); bossRockets = new List<Rocket>(); //Check if there is a boss on the screen BosFight = false; // Set the Backgounds [2 Backgrounds repeteng them selfs] BG = new BackGround(-764); BG1 = new BackGround(0); //Make Clouds on the screen clouds = new List<cloud>(); fillClouds(); // Set the buffer this.DoubleBuffered = true; // Set the Blast Image, Scores, Remaining lifes, Time left, and Boss HP bar Blast = false; Images = new BlastImages(); scoore = new HighScore(); ScoreLabel.Text =string.Format("High Score: {0}",scoore.getScore()); RemainingLifes.Text =string.Format("Player Lifes: {0}",playerPlane.getPlayerLife()); TimeLeft = 180; BosLife.Visible = false; BosLife.Value = boss.getLife(); //Set the sounds sounds = new Sounds(); sounds.playMainMusic(); //Get the timers Ready GameTimer.Enabled = true; PlayerTime.Enabled = true; }