// Use this for initialization
 void Awake()
 {
     Instance         = this;
     m_BarPoints      = new List <Image> ();
     m_BarPointParent = this.transform;
     m_DisableColor   = new Color(219, 219, 219, 255) / 255;
     m_ActiveColor    = new Color(69, 212, 0, 255) / 255;
     m_PointName      = "LifePoint";
 }
Beispiel #2
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (goleft && player.Left >= 20)
     {
         player.Left -= playerSpeed;
     }
     else if (goright && player.Left <= 650)
     {
         player.Left += playerSpeed;
     }
     else if (goup)
     {
         player.Top -= playerSpeed;
     }
     else if (godown)
     {
         player.Top += playerSpeed;
     }
     if (PlayerLifeBar.Value == 180)
     {
         StopSimpleSound();
         gameOver();
         player.Dispose();
         MessageBox.Show("You Have Been Destroyed");
     }
     foreach (Control x in this.Controls)
     {
         if (x is PictureBox && x.Tag == "invaders")
         {
             if (((PictureBox)x).Bounds.IntersectsWith(player.Bounds))
             {
                 StopSimpleSound();
                 gameOver();
                 MessageBox.Show("You Have Been Captured");
             }
             ((PictureBox)x).Left += speed;
             if (((PictureBox)x).Left > 720)
             {
                 ((PictureBox)x).Top += ((PictureBox)x).Height + 10;
                 ((PictureBox)x).Left = -50;
             }
         }
         if (x is PictureBox && x.Tag == "invaders2")
         {
             if (((PictureBox)x).Bounds.IntersectsWith(player.Bounds))
             {
                 StopSimpleSound();
                 gameOver();
                 MessageBox.Show("You Have Been Captured");
             }
             ((PictureBox)x).Left -= speed + 1;
             if (((PictureBox)x).Left < 0)
             {
                 ((PictureBox)x).Top += ((PictureBox)x).Height + 40;
                 ((PictureBox)x).Left = 720;
             }
         }
     }
     foreach (Control y in this.Controls)
     {
         if (y is PictureBox && y.Tag == "bullet")
         {
             y.Top -= 20;
             if (((PictureBox)y).Top < this.Height - 490)
             {
                 this.Controls.Remove(y);
             }
         }
     }
     foreach (Control y in this.Controls)
     {
         if (y is PictureBox && y.Tag == "bullet2")
         {
             y.Top += 15;
             if (((PictureBox)y).Top < this.Height - 490)
             {
                 this.Controls.Remove(y);
             }
         }
     }
     foreach (Control i in this.Controls)
     {
         foreach (Control j in this.Controls)
         {
             if (i is PictureBox && i.Tag == "invaders")
             {
                 if (j is PictureBox && j.Tag == "bullet")
                 {
                     if (i.Bounds.IntersectsWith(j.Bounds))
                     {
                         score += 100;
                         this.Controls.Remove(i);
                         this.Controls.Remove(j);
                         currentEnemies--;
                         Enemies.Remove(i);
                         SystemSounds.Exclamation.Play();
                     }
                 }
             }
             if (i is PictureBox && i.Tag == "invaders2")
             {
                 if (j is PictureBox && j.Tag == "bullet")
                 {
                     if (i.Bounds.IntersectsWith(j.Bounds))
                     {
                         score += 100;
                         this.Controls.Remove(i);
                         this.Controls.Remove(j);
                         currentEnemies--;
                         Enemies.Remove(i);
                         SystemSounds.Exclamation.Play();
                     }
                 }
             }
         }
     }
     foreach (Control i in this.Controls)
     {
         foreach (Control j in this.Controls)
         {
             if (i is PictureBox && i.Tag == "bullet")
             {
                 if (j is PictureBox && j.Tag == "bullet2")
                 {
                     if (i.Bounds.IntersectsWith(j.Bounds))
                     {
                         this.Controls.Remove(i);
                         this.Controls.Remove(j);
                     }
                 }
             }
             if (i is PictureBox && i.Tag == "bullet")
             {
                 if (j is PictureBox && j.Tag == "bullet2")
                 {
                     if (i.Bounds.IntersectsWith(j.Bounds))
                     {
                         this.Controls.Remove(i);
                         this.Controls.Remove(j);
                     }
                 }
             }
         }
     }
     foreach (Control i in this.Controls)
     {
         if (i is PictureBox && i.Tag == "bullet2")
         {
             if (((PictureBox)i).Bounds.IntersectsWith(player.Bounds))
             {
                 PlayerLifeBar.Increment(25);
                 this.Controls.Remove(i);
             }
         }
     }
     label1.Text = "Score : " + score;
     label2.Text = "Ammo : " + number_of_bullets;
     if ((score / 100) >= totalEnemies - 1)
     {
         gameOver();
         StopSimpleSound();
         MessageBox.Show("You Have Saved The Galaxy!!");
     }
 }