Example #1
0
        protected virtual Damage.Result TakeDamage(float value, Damage.Method method, Entity cause)
        {
            if (Defense != null)
            {
                value = Defense.Sample(value);
            }

            var initialHealth = Health.Value;

            if (Health.Value > 0f)
            {
                Health.Value -= value;
            }
            else
            {
            }

            var result = new Damage.Result(value, this, method, cause);

            if (OnTookDamage != null)
            {
                OnTookDamage(result);
            }

            if (initialHealth > 0)
            {
                if (IsDead)
                {
                    Death(result);
                }
            }

            return(result);
        }
Example #2
0
 public AttackData(float damage, int range, float distance, float duration, Damage.Method method)
 {
     this.power    = damage;
     this.range    = range;
     this.distance = distance;
     this.duration = duration;
     this.method   = method;
 }
Example #3
0
        public virtual Damage.Result DoDamage(float value, Damage.Method method, Entity target)
        {
            if (Armed == false)
            {
                throw new InvalidOperationException("Cannot do damage from projectile " + name + " because it's not Armed yet, please Arm first");
            }

            var result = Owner.DoDamage(value, method, target);

            return(result);
        }
Example #4
0
        public virtual Damage.Result DoDamage(float value, Damage.Method method, Entity target)
        {
            var result = target.TakeDamage(value, method, this);

            if (OnDoDamage != null)
            {
                OnDoDamage(result);
            }

            return(result);
        }