/// <summary> /// Add an instant modifier x times /// </summary> /// <param name="mod">modifier</param> /// <param name="count">times to apply</param> public void AddInstantModifier(StatModifier mod, int count) { switch (mod.effectType) { case EffectTypes.Instant: if (!value.IsNumeric()) { Debug.Log(name + " only sustained modifiers can be used on stats with non-numeric values"); return; } mod.Initialize(this); float change = mod.AppliedValue * count; switch (mod.valueTarget) { case EffectValueTarget.MaximumValue: CurrentBaseMaximum += change; break; case EffectValueTarget.MinimumValue: CurrentBaseMinimum += change; break; case EffectValueTarget.RegenAmount: CurrentBaseRegenAmount += change; break; case EffectValueTarget.RegenDelay: CurrentBaseRegenDelay += change; break; case EffectValueTarget.Value: CurrentBaseValue += change; break; } break; } }
/// <summary> /// Add a new modifer /// </summary> /// <param name="mod"></param> public void AddModifier(StatModifier mod) { switch (mod.effectType) { case EffectTypes.Instant: if (!value.IsNumeric()) { Debug.Log(name + " only sustained modifiers can be used on stats with non-numeric values"); return; } mod.Initialize(this); switch (mod.valueTarget) { case EffectValueTarget.MaximumValue: CurrentBaseMaximum += mod.AppliedValue; break; case EffectValueTarget.MinimumValue: CurrentBaseMinimum += mod.AppliedValue; break; case EffectValueTarget.RegenAmount: CurrentBaseRegenAmount += mod.AppliedValue; break; case EffectValueTarget.RegenDelay: CurrentBaseRegenDelay += mod.AppliedValue; break; case EffectValueTarget.Value: CurrentBaseValue += mod.AppliedValue; break; } break; case EffectTypes.Recurring: if (!value.IsNumeric()) { Debug.Log(name + " only sustained modifiers can be used on stats with non-numeric values"); return; } mod.Initialize(this); ActiveModifiers.Add(mod); break; case EffectTypes.Sustained: mod.Initialized = false; ActiveModifiers.Add(mod); switch (mod.valueTarget) { case EffectValueTarget.MaximumValue: ReCalcCurrentMax(); break; case EffectValueTarget.MinimumValue: ReCalcCurrentMin(); break; case EffectValueTarget.Value: ReCalcCurrentValue(CurrentBaseValue); break; case EffectValueTarget.RegenAmount: ReCalcCurrentRegenAmount(); break; case EffectValueTarget.RegenDelay: ReCalcCurrentRegenDelay(); break; } break; } }