示例#1
0
文件: Shot.cs 项目: Rogachev99/PUBG
        private void HaveAttacked(SolidBody attacked, Vec2 position, float angle, IBullet bullet)
        {
            PointF locationObject = attacked.Shape.Location;
            ulong  idParent       = (Parent as Weapon).Owner.ID;

            float newDistance = VectorMethod.DefineDistance(position, new Vec2(locationObject.X, locationObject.Y));

            Parent.Model.AddOutgoingMessage(new MakedShot(idParent, angle, newDistance));

            if (attacked == null)
            {
                return;
            }

            var damageMsg = new GotDamage(idParent, bullet.Damage);

            attacked.Parent.Update(damageMsg);

            //определяем убили ли мы противника
            Healthy healthyAttacked = attacked.Parent.Components.GetComponent <Healthy>();

            if (healthyAttacked == null)
            {
                return;
            }
            //если убили засчитываем фраг
            if (healthyAttacked.HP < bullet.Damage)
            {
                (Parent as Weapon).Owner.Update(new MakedKill(idParent));
            }
        }
示例#2
0
 public void EnergyLow(int n)
 {
     _energy -= n;
     GotDamage?.Invoke(n);
 }