Example #1
0
 /// <summary> Checks if an attack can be made, and if so subtracts resistance adjusted damage from the given hitPoints. </summary>
 public void Attack(ref float hitPoints, ResistanceInfo resistances)
 {
     if (CanAttack())
     {
         hitPoints -= GetDamage(resistances);
     }
 }
Example #2
0
        ///<summary> Calculates damage based on DamageInfo options chosen in the inspector. </summary>
        public float GetDamage(ResistanceInfo resistances)
        {
            float finalDamage = (!dynamicDamage) ? ((!resistances) ? damage : adjustedDamage) : GetAdjustedDamage(resistances);

            UpdateLimit(finalDamage);

            return(finalDamage);
        }
Example #3
0
        ///<summary> Sets variables up for use, sets adjustedDamage to resistance adjusted damage if dynamicDamage is not chosen. </summary>
        public void Setup(ResistanceInfo targetR)
        {
            delay.ResetTimer();
            attackGap.timer = 0;

            if (limitType == DamageLimit.NONE)
            {
                limit.timer = 1;
            }
            else
            {
                limit.ResetTimer();
            }

            if (!dynamicDamage)
            {
                adjustedDamage = (targetR != null) ? GetAdjustedDamage(targetR) : damage;
            }
        }
Example #4
0
        ///<summary> Searches given ResistanceInfo for resistances matching the damage ID. If a resistance is found, it will be used to calculate and return damage, otherwise damage is returned. </summary>
        private float GetAdjustedDamage(ResistanceInfo resistances)
        {
            Resistance res = resistances.resistanceList.Find(r => r.resistanceID == ID);

            return((res == null) ? damage : res.GetAdjustedDamage(damage));
        }