Example #1
0
        /// <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;
            }
        }