//Modifies health over time. public void ModifyHealth(float amount, HpModType type, float duration) { amount = (amount / ((ticksPerSecond * duration) + 1)); SetHealthBarValues(amount * ((ticksPerSecond * duration) + 1), type); StartCoroutine(ModifyHealthOverTime(amount, type, duration)); }
public void Damage(float amount, HpModType type, float duration, Side attackerSide) { if (!myAttackerSides.Contains(attackerSide)) { myAttackerSides.Add(attackerSide); //ATTACKER SIDE LOGIC } ModifyHealth(amount, type, duration); }
IEnumerator ModifyHealthOverTime(float amount, HpModType type, float duration) { while (duration >= 0) { if (canTakeDamage || type == HpModType.heal) { currentHealth += FindRealAmount(amount, type); } SetHealthBarValues(-amount, type); SetHealthBarLines(); duration -= 1 / ticksPerSecond; yield return(new WaitForSeconds(1 / ticksPerSecond)); } }
//Deals damage or heals. public void ModifyHealth(float amount, HpModType type) { amount = FindRealAmount(amount, type); if (canTakeDamage || type == HpModType.heal) { currentHealth += amount; if (type == HpModType.heal) { animatingHeal += amount; } else { animatingDamage -= amount; } } }
//========================================================= Health Modification ========================================================= //Calculates defensive stats. float FindRealAmount(float amount, HpModType type) { switch (type) { case HpModType.physicalDamage: amount *= (100 - DefensiveStats[HpModType.physicalDamage]) / -100; break; case HpModType.magicalDamage: amount *= (100 - DefensiveStats[HpModType.magicalDamage]) / -100; break; case HpModType.trueDamage: amount = -amount; break; case HpModType.heal: amount *= (100 - DefensiveStats[HpModType.heal]) / 100; break; } return(amount); }
//Modifiels health proportionally. public void ModifyHealth(float amount, HpModType type, RatioType ratioType) { ModifyHealth(FindRealAmount(amount, ratioType), type); }
void SetHealthBarValues(float amount, HpModType type) { HpModOverTime[type] += amount; }
//Removes the defensive stat modifier. IEnumerator RemoveDefensiveStatModifier(float amount, HpModType type, float duration) { yield return(new WaitForSeconds(duration)); DefensiveStats[type] = (DefensiveStats[type] - 100) / (1 - amount / 100) + 100; }
//Adds a defensive stat modifier for a limited time. public void AddDefensiveStatModifier(float amount, HpModType type, float duration) { DefensiveStats[type] = (DefensiveStats[type] - 100) * (1 - amount / 100) + 100; StartCoroutine(RemoveDefensiveStatModifier(amount, type, duration)); }
//========================================================= Defensive Stat Modification ========================================================= //Adds a defensive stat modifier. public void AddDefensiveStatModifier(float amount, HpModType type) { DefensiveStats[type] = (DefensiveStats[type] - 100) * (1 - amount / 100) + 100; }
public HpMod(float value, HpModType type) { Value = value; Type = type; }
public HpMod(double value, HpModType type, bool useHealthBuffer = false) { Value = value; Type = type; UseHealthBuffer = useHealthBuffer; }