Example #1
0
 public void RemoveBomb(Bomb item)
 {
     bombs.Remove(item);
 }
Example #2
0
 public void AddBomb(Bomb item)
 {
     bombs.Add(item);
 }
Example #3
0
 public void RemoveBomb(Bomb item)
 {
     bombs.Remove(item);
 }
Example #4
0
        private void HandlerShot(Hero player, int shotX, int shotY)
        {
            Random tempRand = new Random();

            Track(new Point(shotX, shotY));

            foreach (CombatUnit tank in player.GetList())
            {
                if (tank is Vehicle)
                {
                    PictureBox tempUnit = (tank as Vehicle).Item;
                    int        locX     = tempUnit.Location.X;
                    int        locY     = tempUnit.Location.Y;
                    int        sizX     = tempUnit.Width;
                    int        sizY     = tempUnit.Height;

                    //Проверка на попадание
                    if ((shotX >= locX && shotX <= locX + sizX) && (shotY >= locY && shotY <= locY + sizY))
                    {
                        bool check = false;
                        Bomb item  = null;
                        if (player is LeftHero && bombSelectRight.SelectedItem != null)
                        {
                            check = true;
                            item  = bombSelectRight.SelectedItem as Bomb;
                        }
                        else if (player is RightHero && bombSelectLeft.SelectedItem != null)
                        {
                            check = true;
                            item  = bombSelectLeft.SelectedItem as Bomb;
                        }

                        if (check)
                        {
                            int totalDamage = item.damage;
                            foreach (Warrior unit in (tank as Vehicle).Items)
                            {
                                if (!unit.killed)
                                {
                                    if (unit.hp <= totalDamage)
                                    //if (totalDamage - unit.Damage() >= 0)
                                    {
                                        totalDamage -= unit.Damage();
                                        unit.killed  = true;
                                    }
                                    else
                                    {
                                        unit.hp    -= totalDamage;
                                        totalDamage = 0;
                                    }
                                }
                            }

                            //Проверка на полное уничтожение
                            if (tank.Damage() <= totalDamage)
                            {
                                (tank as Vehicle).killed = true;
                                tempUnit.BackColor       = Color.Red;

                                if (player is LeftHero)
                                {
                                    (player as LeftHero).NotifyObserver();
                                }
                                else if (player is RightHero)
                                {
                                    (player as RightHero).NotifyObserver();
                                }
                            }
                        }

                        (tank as Vehicle).Title.Text = (tank as Vehicle).Damage().ToString();

                        return;
                    }
                }
            }
        }
Example #5
0
 public void AddBomb(Bomb item)
 {
     bombs.Add(item);
 }