Пример #1
0
        private void CheckDoors()
        {
            bool deadguys = false;

            for (int i = 0; i < allBadGuys.Count; i++)
            {
                PictureBox badguys = allBadGuys[i];


                if (pictureBoxGoodGuy.IsTouching(pictureBoxTeleport))
                {
                    MainForm.NextForm = "ThirdForm";
                    Close();
                }

                if (deadguys == true)
                {
                    badguys.Visible = false;
                }


                if (badguys.IsTouching(pictureBoxGoodGuy) && badguys.Visible == true)
                {
                    Death();
                }
            }
            if (pictureBoxGoodGuy.IsTouching(pictureBoxBack))
            {
                MainForm.NextForm = "FirstForm";
                Close();
            }
        }
Пример #2
0
        private void TrackBullets()
        {
            for (int i = 0; i < bulletList.Count; i++)
            {
                PictureBox bullet = bulletList[i];
                bullet.Left += bulletSpeed;

                // Remove the bullet if it leaves the screen
                if (bullet.IsInsideOfForm() == false)
                {
                    // remove it from both the List and from the Window's
                    // Controls collection.
                    bulletList.Remove(bullet);
                    this.Controls.Remove(bullet);
                }

                // Kill a bad guy if the bullet hits him
                for (int j = 0; j < allBadGuys.Count; j++)
                {
                    PictureBox badGuy = allBadGuys[j];

                    // Skip if invisible (already dead)
                    if (badGuy.Visible == false)
                    {
                        continue;
                    }


                    if (badGuy.IsTouching(bullet))
                    {
                        // remove the bullet from both the List and from the
                        // Window's Controls collection.
                        bulletList.Remove(bullet);
                        this.Controls.Remove(bullet);
                        this.Controls.Remove(badGuy);

                        // "Kill" the bad guy
                        badGuy.Visible = false;

                        // Add to list of dead bad guys and check for win
                        deadBadGuys.Add(badGuy);



                        break;
                    }
                }
            }
        }
Пример #3
0
 private bool CanMove(PictureBox pb)
 {
     if (pb.IsInsideOfForm() == false)
     {
         return(false);
     }
     foreach (var trees in trees)
     {
         if (pb.IsTouching(trees) == true)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #4
0
        private void CheckDoors()
        {
            bool allDead = false;

            for (int i = 0; i < allBadGuys.Count; i++)
            {
                PictureBox badguys = allBadGuys[i];


                if (pictureBoxPlayer.IsTouching(HeavenLights))
                {
                    MainForm.NextForm = "GameOver";
                    Close();
                }

                if (allDead == true && badguys.Visible == false)
                {
                    Win();
                    Close();
                }

                if (badguys.IsTouching(pictureBoxPlayer) && badguys.Visible == true)
                {
                    Death();
                    Close();
                }



                if (pictureBoxPlayer.IsTouching(BacktoCaverns))
                {
                    MainForm.NextForm = "SecondForm";
                    Close();
                }
            }
        }