Beispiel #1
0
 void ApplyDamage(EiDamage damage)
 {
     if (HasShieldType(damage.DamageType))
     {
         if (HasShield)
         {
             // calculate armor Loss
             var shieldLoss    = shieldData.flatShieldLoss + shieldData.shieldLossByTotalDamagePercentage * damage.Damage;
             var preCalcDamage = damage.Damage;
             // Reduce damage
             damage.ReduceDamage(shieldData.flatReduction, shieldData.damageMultiplier, calculateFlatReductionFirst);
             //fix after reduction armor loss
             shieldLoss += (preCalcDamage - damage.Damage) * shieldData.shieldLossByDamagePercentage;
             //Check if needed further damage adjustments
             var tempArmor = CurrentShield;
             if (shieldLoss > tempArmor)
             {
                 var percentage = 1f - (tempArmor / shieldLoss);
                 currentShield.Value = 0f;
                 //do some magic stuff for doing more accurate damage reduction based on armor
                 damage.SetDamage(UnityEngine.Mathf.Lerp(damage.Damage, preCalcDamage, percentage));
             }
             else
             {
                 currentShield.Value -= shieldLoss;
             }
         }
     }
 }
Beispiel #2
0
 void ApplyHeal(EiDamage damage)
 {
     if (damage.DamageType == targetDamageType)
     {
         damage.Convert();
         onHealChange.Trigger();
     }
 }
Beispiel #3
0
 void ApplyHeal(EiDamage heal)
 {
     if (heal.HasHealing())
     {
         var healToBeAdded = Math.Min(MissingHealth, heal.Heal);
         currentHealth.Value += healToBeAdded;
         heal.RemoveHeal(healToBeAdded);
     }
 }
Beispiel #4
0
 void ApplyDamage(EiDamage damage)
 {
     if (damage.HasDamage())
     {
         var damageToBeDealt = Math.Min(CurrentHealth, damage.Damage);
         currentHealth.Value -= damageToBeDealt;
         damage.RemoveDamage(damageToBeDealt);
     }
 }
Beispiel #5
0
 void ApplyDamage(EiDamage damage)
 {
     for (int i = protection.Count - 1; i >= 0; i--)
     {
         var protData = protection [i];
         if (protData.damageType == damage.DamageType)
         {
             damage.ReduceDamage(protData.flatReduction, protData.damageMultiplier, calculateFlatProtectionFirst);
         }
     }
 }
Beispiel #6
0
 public void Damage(EiDamage damage)
 {
     if (damage.Target == null)
     {
         damage.Target = damageTarget;
     }
     else
     {
         if ((damage.Target) != damageTarget)
         {
             Debug.LogWarning("The damage target is different to what it hit\n" + Entity.EntityName);
         }
     }
     onHit.Trigger(damage);
     damage.ReduceDamage(flatDamageReduction.Value, damageMultiplier.Value, calculateFlatReducationFirst);
     damageTarget.Damage(damage);
 }
Beispiel #7
0
 public virtual void Heal(EiDamage heal)
 {
     for (int i = subscribedHealingPipeline.Count - 1; i >= 0; i--)
     {
         if (heal.Break)
         {
             break;
         }
         if (heal.HasDamage())
         {
             heal.Iteration++;
             Damage(heal);
             return;
         }
         subscribedHealingPipeline [i].Target(heal);
     }
     heal.Dispose();
 }
Beispiel #8
0
 public virtual void Damage(EiDamage damage)
 {
     for (int i = subscribedDamagePipeline.Count - 1; i >= 0; i--)
     {
         if (damage.Break)
         {
             break;
         }
         if (damage.HasHealing())
         {
             damage.Iteration++;
             Heal(damage);
             return;
         }
         subscribedDamagePipeline [i].Target(damage);
     }
     damage.Dispose();
 }
Beispiel #9
0
        void ApplyHeal(EiDamage heal)
        {
            if (!canRegenShieldByHealthRegen)
            {
                return;
            }
            if (!HasShieldType(heal.DamageType))
            {
                return;
            }

            var amountToHeal = Math.Min(MissingShield, heal.Heal);

            if (amountToHeal < 0f)
            {
                amountToHeal = 0f;
            }

            currentShield.Value += amountToHeal;

            heal.RemoveHeal(amountToHeal);
        }