Example #1
0
    public virtual StatModifier ModifyStatAndReturnMod(float value, StatModifier.StatModificationType modType)
    {
        StatModifier newMod = new StatModifier(value, modType);

        ModifyStat(newMod);
        return(newMod);
    }
Example #2
0
    public StatModifier ApplyAndReturnTrackedMod(StatType type, float value, StatModificationType modType, GameObject cause, params StatModifierOption[] statOptions)
    {
        StatModifier newMod = new StatModifier(value, modType);

        ApplyTrackedMod(type, newMod, cause, statOptions);
        return(newMod);
    }
Example #3
0
    public virtual void ModifyStatPermanently(float value, StatModifier.StatModificationType modType)
    {
        switch (modType)
        {
        case StatModifier.StatModificationType.Additive:
            BaseValue += value;
            break;

        case StatModifier.StatModificationType.Multiplicative:
            float adj;

            if (value < 0)
            {
                adj = Mathf.Clamp01(1 + value);
            }
            else
            {
                adj = 1 + value;
            }

            BaseValue *= adj;

            break;
        }

        if (this is CappedStat)
        {
            CappedStat stat = this as CappedStat;

            if (stat.BaseValue > stat.MaxValue)
            {
                stat.Refresh();
            }
        }
    }
Example #4
0
    public void ApplyPermanentMod(StatType type, float value, StatModificationType modType, GameObject cause, params StatModifierOption[] statOptions)
    {
        List <StatModifierOption> options = ConvertStatOptionsToList(statOptions);

        BaseStat targetStat = GetStat(type);

        if (targetStat == null)
        {
            Debug.LogError("Stat: " + type + " not found");
            return;
        }

        if (options.Contains(StatModifierOption.Cap))
        {
            CappedStat capped = TryConvertToCappedStat(targetStat);

            if (capped != null)
            {
                capped.ModifyCapPermanently(value, modType);
                OnStatChanged(type, cause);
            }
        }

        if ((options.Count < 1 || options.Contains(StatModifierOption.Base)))
        {
            targetStat.ModifyStatPermanently(value, modType);
            OnStatChanged(type, cause);
        }
    }
Example #5
0
 public StatAdjustmentInfo(float adjValue, BaseStat.StatType targetStat, StatModifier.StatModificationType modType, List <StatCollection.StatModifierOption> options, bool permanent)
 {
     this.adjustmentValue = adjValue;
     this.targetStat      = targetStat;
     this.modType         = modType;
     this.permanent       = permanent;
     this.options         = options;
 }
Example #6
0
    protected float GetTotalModByType(StatModifier.StatModificationType type)
    {
        float total = 0f;

        int count = mods.Count;

        for (int i = 0; i < count; i++)
        {
            total += mods[i].GetValueByModType(type);
        }

        return(total);
    }
Example #7
0
    //public StatusStatAdjustment(StatusInfo info, StatAdjustmentInfo adjInfo, float duration, float interval ) : base (info, duration, interval)
    //{
    //    StatAdjSetup(adjInfo);
    //}

    private void StatAdjSetup(StatAdjustmentInfo adjInfo)
    {
        this.baseAdjustmentvalue = adjInfo.adjustmentValue;
        this.adjValue            = adjInfo.adjustmentValue;
        this.targetStat          = adjInfo.targetStat;
        this.modType             = adjInfo.modType;
        this.permanent           = adjInfo.permanent;
        this.options             = adjInfo.options.ToArray();

        //mod = new StatModifier(adjValue, modType);

        Tick();
    }
Example #8
0
    protected float GetTotalModByType(StatModifier.StatModificationType type)
    {
        float total = 0f;

        int count = mods.Count;

        for (int i = 0; i < count; i++)
        {
            total += mods[i].GetValueByModType(type);
        }


        if (Type == StatType.MoveSpeed && type == StatModifier.StatModificationType.Multiplicative)
        {
            //Debug.Log(mods.Count + " mods found");
            //Debug.Log(Type + " has a multiplyer of " + total);
        }

        return(total);
    }
Example #9
0
 public void ModifyCap(float value, StatModifier.StatModificationType modType)
 {
     maxValue.ModifyStat(value, modType);
 }
Example #10
0
 public void ModifyCapPermanently(float value, StatModifier.StatModificationType modType)
 {
     maxValue.ModifyStatPermanently(value, modType);
 }
Example #11
0
 public virtual void ModifyStat(float value, StatModifier.StatModificationType modType, ref float update)
 {
     ModifyStat(new StatModifier(value, modType), ref update);
 }
Example #12
0
 public virtual void ModifyStat(float value, StatModifier.StatModificationType modType)
 {
     ModifyStat(new StatModifier(value, modType));
 }
    //public static void ApplyUntrackedStatMod(StatAdjustment adj) {
    //    adj.target.ApplyUntrackedMod(adj.statType, adj.value, adj.modType, adj.adjustmentOptions);
    //}

    public static StatModifier ApplyTrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value, StatModificationType modType, params StatModifierOption[] statOptions)
    {
        GameObject   s   = source != null ? source.Owner : null;
        GameObject   t   = target != null ? target.Owner : null;
        StatModifier mod = target.ApplyAndReturnTrackedMod(stat, value, modType, s, statOptions);

        if (t != null)
        {
            SendStatChangeEvent(s, t, stat, value);
            return(mod);
        }
        else
        {
            Debug.LogWarning("a stat mod: " + mod + " could not be added to a target because it was null");
            return(null);
        }
    }
    public static void ApplyUntrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value, StatModificationType modType, params StatModifierOption[] statOptions)
    {
        if (target == null)
        {
            return;
        }

        target.ApplyPermanentMod(stat, value, modType, source.Owner, statOptions);
        SendStatChangeEvent(source.Owner, target.Owner, stat, value);
    }
Example #15
0
    //public static void ApplyUntrackedStatMod(StatAdjustment adj) {
    //    adj.target.ApplyUntrackedMod(adj.statType, adj.value, adj.modType, adj.adjustmentOptions);
    //}

    public static StatModifier ApplyTrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value, StatModificationType modType, params StatModifierOption[] statOptions)
    {
        StatModifier mod = target.ApplyAndReturnTrackedMod(stat, value, modType, source.Owner, statOptions);

        SendStatChangeEvent(source.Owner, target.Owner, stat, value);
        return(mod);
    }
Example #16
0
 public StatAdjustment(StatCollection source, StatCollection target, StatType statType, float value, StatModificationType modType, params StatModifierOption[] options)
     : this(source, target, statType, options)
 {
     this.value   = value;
     this.modType = modType;
 }