Example #1
0
 private void panel1ScarletButton(object sender, EventArgs e)
 {
     panel1.Controls.Clear();
     panelView                      = PanelView.game;
     timerMapMove.Enabled           = true;
     timerEnemyShoot.Enabled        = true;
     timerGenerateObstacles.Enabled = true;
     avenger = new Avenger("ScarletWitch", new Point(1000 / 2, 500 - 120));
     Prev    = "ScarletWitch";
     boss    = new Boss(new Point(1000 / 2, 0));
     map     = new Map(500, 1000, avenger.Name, r);
 }
Example #2
0
 private void panel1StartOverButton(object sender, EventArgs e)
 {
     panel1.Controls.Clear();
     panelView = PanelView.game;
     timerGenerateObstacles.Interval = timerMapMove.Interval * 108;
     timerMapMove.Enabled            = true;
     timerEnemyShoot.Enabled         = true;
     timerGenerateObstacles.Enabled  = true;
     avenger = new Avenger(Prev, new Point(1000 / 2, 500 - 120));
     boss    = new Boss(new Point(1000 / 2, 0));
     map     = new Map(500, 1000, avenger.Name, r);
 }
Example #3
0
 public void checkCollisionWeaponEnemy(Avenger avenger)
 {
     //detektra dali avengerot pogodil enemy
     for (int i = enemies.Count - 1; i > -1; i--)
     {
         Rectangle a = new Rectangle(enemies[i].Location.X, enemies[i].Location.Y, enemies[i].image.Width, enemies[i].image.Height);
         for (int j = avenger.shots.Count - 1; j > -1; j--)
         {
             Rectangle b = new Rectangle(avenger.shots[j].Location.X, avenger.shots[j].Location.Y, avenger.shots[j].WeaponImage.Width, avenger.shots[j].WeaponImage.Height);
             if (a.IntersectsWith(b))
             {
                 avenger.shots.RemoveAt(j);
                 enemies.RemoveAt(i);
                 Progress++;
                 break;
             }
         }
     }
 }
Example #4
0
 public void checkCollisionWeaponObstacle(Avenger avenger)
 //detektira dali avengerot pogodil nekoja precka
 {
     for (int i = obstacles.Count - 1; i > -1; i--)
     {
         Rectangle a = new Rectangle(obstacles[i].Location.X, obstacles[i].Location.Y, obstacles[i].image.Width, obstacles[i].image.Height);
         for (int j = avenger.shots.Count - 1; j > -1; j--)
         {
             Rectangle b = new Rectangle(avenger.shots[j].Location.X, avenger.shots[j].Location.Y, avenger.shots[j].WeaponImage.Width, avenger.shots[j].WeaponImage.Height);
             if (a.IntersectsWith(b))
             {
                 avenger.shots.RemoveAt(j);
                 obstacles.RemoveAt(i);
                 Progress++;
                 break;
             }
         }
     }
 }
Example #5
0
        public bool checkCollisionAvengerEnemy(Avenger avenger)
        {
            //vraka true ako avengerot se sudri so nekoj neprijatel
            Rectangle a = new Rectangle(avenger.Location.X, avenger.Location.Y, avenger.Character.Width, avenger.Character.Height);
            bool      t = false;
            int       i;

            for (i = 0; i < enemies.Count; i++)
            {
                Rectangle b = new Rectangle(enemies[i].Location.X, enemies[i].Location.Y, enemies[i].image.Width, enemies[i].image.Height);
                if (a.IntersectsWith(b))
                {
                    t = true;
                    enemies.RemoveAt(i);
                    break;
                }
            }
            return(t);
        }
Example #6
0
        public void Move(Avenger avenger)
        {
            if (avenger.Location.X < Location.X)
            {
                Step = -2;
            }
            else if (avenger.Location.X > Location.X)
            {
                Step = 2;
            }
            else
            {
                Step = 0;
            }

            if (Location.X + Step >= 0 && Location.X + Step <= width - Character.Width)
            {
                Location = new Point(Location.X + Step, Location.Y);
            }
        }
Example #7
0
        public bool checkCollisionAvengerEnemyWeapon(Avenger avenger)
        //detektira dali avengerot e pogoden od istrel na enemy
        {
            bool      t = false;
            Rectangle a = new Rectangle(avenger.Location.X, avenger.Location.Y, avenger.Character.Width, avenger.Character.Height);

            for (int i = enemies.Count - 1; i > -1; i--)
            {
                for (int j = enemies[i].shots.Count - 1; j > -1; j--)
                {
                    Rectangle b = new Rectangle(enemies[i].shots[j].Location.X, enemies[i].shots[j].Location.Y, enemies[i].shots[j].WeaponImage.Width, enemies[i].shots[j].WeaponImage.Height);
                    if (a.IntersectsWith(b))
                    {
                        enemies[i].shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                }
            }
            return(t);
        }
Example #8
0
        public Obstacle findNearObstacleHulk(Avenger avenger)
        {
            Rectangle a = new Rectangle(new Point(avenger.Location.X - 75, avenger.Location.Y - 75), new Size(avenger.Character.Width + 150, avenger.Character.Height + 150));
            Obstacle  t = null;
            int       i;

            for (i = 0; i < obstacles.Count; i++)
            {
                Rectangle b = new Rectangle(obstacles[i].Location, new Size(obstacles[i].image.Width, obstacles[i].image.Height));
                if (a.IntersectsWith(b))
                {
                    break;
                }
            }
            if (i != obstacles.Count)
            {
                t       = new Obstacle(obstacles[i].Location, "Hulk");
                t.image = obstacles[i].image;
                obstacles.RemoveAt(i);
            }
            return(t);
        }
Example #9
0
        public bool checkCollisionAvengerObstacle(Avenger avenger)
        {
            //vraka true ako avengerot se sudri so nekoja prepreka
            Rectangle a = new Rectangle(avenger.Location.X, avenger.Location.Y, avenger.Character.Width, avenger.Character.Height);
            bool      t = false;
            int       i;

            for (i = 0; i < obstacles.Count; i++)
            {
                Rectangle b = new Rectangle(obstacles[i].Location.X, obstacles[i].Location.Y, obstacles[i].image.Width, obstacles[i].image.Height);
                if (a.IntersectsWith(b))
                {
                    t = true;
                    break;
                }
            }
            if (t)
            {
                obstacles.RemoveAt(i);
            }
            return(t);
        }
Example #10
0
        public void checkCollisionWeaponBoss(Avenger avenger)
        {
            //detektra dali avengerot go pogodil boss

            for (int j = 0; j < avenger.shots.Count; j++)
            {
                Point p = this.Location;
                if (avenger.shots[j].Location.X > p.X && avenger.shots[j].Location.X < p.X + Character.Width)
                {
                    if (avenger.shots[j].Location.Y > p.Y && avenger.shots[j].Location.Y < p.Y + Character.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                    if (avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height > p.Y && avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height < p.Y + Character.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                }
                if (avenger.shots[j].Location.X + avenger.shots[j].WeaponImage.Width > p.X && avenger.shots[j].Location.X + avenger.shots[j].WeaponImage.Width < p.X + Character.Width)
                {
                    if (avenger.shots[j].Location.Y > p.Y && avenger.shots[j].Location.Y < p.Y + Character.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                    if (avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height > p.Y && avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height < p.Y + Character.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                }


                if (p.X > avenger.shots[j].Location.X && p.X < avenger.shots[j].Location.X + avenger.shots[j].WeaponImage.Width)
                {
                    if (p.Y > avenger.shots[j].Location.Y && p.Y < avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                    if (p.Y + Character.Height > avenger.shots[j].Location.Y && p.Y + Character.Height < avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                }
                if (p.X + Character.Width > avenger.shots[j].Location.X && p.X + Character.Width < avenger.shots[j].Location.X + avenger.shots[j].WeaponImage.Width)
                {
                    if (p.Y > avenger.shots[j].Location.Y && p.Y < avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                    if (p.Y + Character.Height > avenger.shots[j].Location.Y && p.Y + Character.Height < avenger.shots[j].Location.Y + avenger.shots[j].WeaponImage.Height)
                    {
                        avenger.shots.RemoveAt(j);
                        Damage++;
                        break;
                    }
                }
            }
        }
Example #11
0
        public Boolean checkCollisionAvengerBossWeapon(Avenger avenger)
        //detektira dali avengerot e pogoden od istrel na boss
        {
            bool t = false;

            for (int j = 0; j < shots.Count; j++)
            {
                Point p = shots[j].Location;
                if (avenger.Location.X > p.X && avenger.Location.X < p.X + shots[j].WeaponImage.Width)
                {
                    if (avenger.Location.Y > p.Y && avenger.Location.Y < p.Y + shots[j].WeaponImage.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                    if (avenger.Location.Y + avenger.Character.Height > p.Y && avenger.Location.Y + avenger.Character.Height < p.Y + shots[j].WeaponImage.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                }
                if (avenger.Location.X + avenger.Character.Width > p.X && avenger.Location.X + avenger.Character.Width < p.X + shots[j].WeaponImage.Width)
                {
                    if (avenger.Location.Y > p.Y && avenger.Location.Y < p.Y + shots[j].WeaponImage.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                    if (avenger.Location.Y + avenger.Character.Height > p.Y && avenger.Location.Y + avenger.Character.Height < p.Y + shots[j].WeaponImage.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                }
                if (p.X > avenger.Location.X && p.X < avenger.Location.X + avenger.Character.Width)
                {
                    if (p.Y > avenger.Location.Y && p.Y < avenger.Location.Y + avenger.Character.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                    if (p.Y + shots[j].WeaponImage.Height > avenger.Location.Y && p.Y + shots[j].WeaponImage.Height < avenger.Location.Y + avenger.Character.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                }
                if (p.X + shots[j].WeaponImage.Width > avenger.Location.X && p.X + shots[j].WeaponImage.Width < avenger.Location.X + avenger.Character.Width)
                {
                    if (p.Y > avenger.Location.Y && p.Y < avenger.Location.Y + avenger.Character.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                    if (p.Y + shots[j].WeaponImage.Height > avenger.Location.Y && p.Y + shots[j].WeaponImage.Height < avenger.Location.Y + avenger.Character.Height)
                    {
                        shots.RemoveAt(j);
                        t = true;
                        break;
                    }
                }
            }

            return(t);
        }