예제 #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;
             }
         }
     }
 }
예제 #2
0
 void ApplyHeal(EiDamage damage)
 {
     if (damage.DamageType == targetDamageType)
     {
         damage.Convert();
         onHealChange.Trigger();
     }
 }
예제 #3
0
 void ApplyHeal(EiDamage heal)
 {
     if (heal.HasHealing())
     {
         var healToBeAdded = Math.Min(MissingHealth, heal.Heal);
         currentHealth.Value += healToBeAdded;
         heal.RemoveHeal(healToBeAdded);
     }
 }
예제 #4
0
 void ApplyDamage(EiDamage damage)
 {
     if (damage.HasDamage())
     {
         var damageToBeDealt = Math.Min(CurrentHealth, damage.Damage);
         currentHealth.Value -= damageToBeDealt;
         damage.RemoveDamage(damageToBeDealt);
     }
 }
예제 #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);
         }
     }
 }
예제 #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);
 }
예제 #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();
 }
예제 #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();
 }
예제 #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);
        }