Exemplo n.º 1
0
    public void RemoveTrackedMod(StatType type, StatModifier mod, GameObject cause, params StatModifierOption[] statOptions)
    {
        List <StatModifierOption> options = ConvertStatOptionsToList(statOptions);

        BaseStat targetStat = GetStat(type);

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

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

            if (capped != null)
            {
                capped.RemoveCapModifier(mod);
                OnStatChanged(type, cause);
            }
        }

        if ((options.Count < 1 || options.Contains(StatModifierOption.Base)))
        {
            targetStat.RemoveModifier(mod);
            OnStatChanged(type, cause);
        }
    }
Exemplo n.º 2
0
 private void OnStatChanged(BaseStat.StatType stat, GameObject source)
 {
     if (stat == BaseStat.StatType.MoveSpeed)
     {
         maxSpeed = ProjectileStats.GetStatModifiedValue(BaseStat.StatType.MoveSpeed);
     }
 }
Exemplo n.º 3
0
 private void OnStatChanged(StatType type, GameObject cause)
 {
     if (onStatChanged != null)
     {
         onStatChanged(type, cause);
     }
 }
Exemplo n.º 4
0
 private StatAdjustment(StatCollection source, StatCollection target, StatType statType, params StatModifierOption[] options)
 {
     this.source            = source;
     this.target            = target;
     this.statType          = statType;
     this.adjustmentOptions = options;
 }
Exemplo n.º 5
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);
        }
    }
Exemplo n.º 6
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);
    }
Exemplo n.º 7
0
    public float GetCappedStatRatio(StatType type)
    {
        BaseStat targetStat = GetStat(type);

        //Debug.Log("trying to get the stat ratio for " + type);

        CappedStat cap = TryConvertToCappedStat(targetStat);

        if (cap != null)
        {
            //Debug.Log(type + " has a ratio of " + cap.Ratio);

            return(cap.Ratio);
        }



        //if (targetStat != null && targetStat is CappedStat) {
        //    CappedStat capped = targetStat as CappedStat;

        //    return capped.Ratio;
        //}

        Debug.LogError("The ratio value was reqested for a stat with no max. Returning 0");

        return(0f);
    }
Exemplo n.º 8
0
 private void OnStatChanged(BaseStat.StatType type, GameObject source)
 {
     if (type == BaseStat.StatType.CoolDown)
     {
         coolDownTimer.SetNewDuration(Stats.GetStatModifiedValue(BaseStat.StatType.CoolDown));
     }
 }
Exemplo n.º 9
0
    //public void UpdateHealth()
    //{
    //    if (Health <= 0f && dying == false && cheat == false)
    //    {
    //        Die();
    //    }
    //}


    public void OnStatChanged(EventData data)
    {
        GameObject target = data.GetGameObject("Target");

        BaseStat.StatType stat  = (BaseStat.StatType)data.GetInt("Stat");
        float             value = data.GetFloat("Value");

        //Debug.Log(target.name + " " + stat + " " + value);

        if (target != Owner.gameObject)
        {
            return;
        }

        if (stat != BaseStat.StatType.Health)
        {
            return;
        }

        if (value < 0f)
        {
            Owner.AnimHelper.PlayAnimTrigger("Flinch");
        }

        //Debug.Log(Health + " is the current health of " + Owner.gameObject.name);

        if (Health <= 0f && dying == false && cheat == false)
        {
            Die();
        }
    }
Exemplo n.º 10
0
    public void ResetStat(StatType type, params StatModifierOption[] statOptions)
    {
        List <StatModifierOption> options = ConvertStatOptionsToList(statOptions);

        BaseStat targetStat = GetStat(type);

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

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

            if (capped != null)
            {
                capped.ResetCap();
                OnStatChanged(type, null);
            }
        }

        if ((options.Count < 1 || options.Contains(StatModifierOption.Base)))
        {
            targetStat.Reset();
            OnStatChanged(type, null);
        }
    }
Exemplo n.º 11
0
    private static bool ValidateOnStatChanged(EventData data, AbilityActivationInfo activator, Ability ability)
    {
        //bool result = false;

        BaseStat.StatType stat   = (BaseStat.StatType)data.GetInt("Stat");
        GameObject        target = data.GetGameObject("Target");
        //GameObject cause = data.GetGameObject("Cause");
        float value = data.GetFloat("Value");

        if (activator.targetstat != stat)
        {
            return(false);
        }

        switch (activator.gainedOrLost)
        {
        case EffectConstraint.GainedOrLost.Gained:
            if (value <= 0)
            {
                return(false);
            }
            break;

        case EffectConstraint.GainedOrLost.Lost:
            if (value >= 0)
            {
                return(false);
            }
            break;
        }

        switch (activator.statChangeTarget)
        {
        case EffectConstraint.TargetConstraintType.Ally:
            if (target.IsSelfOrAlly(ability.Source) == false)
            {
                return(false);
            }
            break;

        case EffectConstraint.TargetConstraintType.Enemy:
            if (target.IsSelfOrAlly(ability.Source) == true)
            {
                return(false);
            }
            break;

        case EffectConstraint.TargetConstraintType.SelfOnly:
            if (target != ability.Source)
            {
                return(false);
            }
            break;
        }



        return(true);
    }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
0
    private void OnStatChanged(BaseStat.StatType type, GameObject cause)
    {
        //Local Event

        //Global Event
        //EventData data = new EventData();
        //data.AddInt("Type", (int)type);
        //data.AddGameObject("Target", this.gameObject);
        //data.AddGameObject("Cause", cause);
        //EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data);
    }
Exemplo n.º 14
0
    public void RemoveStat(StatType type)
    {
        BaseStat targetStat = GetStat(type);

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

        RemoveStat(targetStat);
    }
Exemplo n.º 15
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();
    }
Exemplo n.º 16
0
    private void UpdateNavAgent(BaseStat.StatType type)
    {
        switch (type)
        {
        case BaseStat.StatType.MoveSpeed:
            navAgent.speed = Stats.GetStatModifiedValue(BaseStat.StatType.MoveSpeed);
            break;

        case BaseStat.StatType.RotateSpeed:
            navAgent.angularSpeed = Stats.GetStatModifiedValue(BaseStat.StatType.RotateSpeed);
            break;
        }
    }
Exemplo n.º 17
0
    public static void SendStatChangeEvent(GameObject source, GameObject target, StatType stat, float value)
    {
        EventData data = new EventData();

        data.AddGameObject("Cause", source);
        data.AddGameObject("Target", target);
        data.AddInt("Stat", (int)stat);
        data.AddFloat("Value", value);

        EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data);


        Debug.Log(source.name + " has altered " + stat + " on " + target.name + " by " + value);
    }
Exemplo n.º 18
0
    private BaseStat GetStat(StatType type)
    {
        int count = stats.Count;

        for (int i = 0; i < count; i++)
        {
            if (stats[i].Type == type)
            {
                return(stats[i]);
            }
        }

        return(null);
    }
Exemplo n.º 19
0
    public static void SendStatChangeEvent(GameObject source, GameObject target, StatType stat, float value)
    {
        EventData data = new EventData();

        data.AddGameObject("Cause", source);
        data.AddGameObject("Target", target);
        data.AddInt("Stat", (int)stat);
        data.AddFloat("Value", value);

        EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data);

        if (stat == StatType.Health && target != null)
        {
            VisualEffectLoader.MakeFloatingText(value.ToString(), target.transform.position);

            //Debug.Log(source.name + " has altered " + stat + " on " + target.name + " by " + value);
        }
    }
Exemplo n.º 20
0
    private void OnStatChanged(EventData data)
    {
        GameObject target = data.GetGameObject("Target");

        BaseStat.StatType type = (BaseStat.StatType)data.GetInt("Stat");

        if (target != owner.gameObject)
        {
            return;
        }

        if (type != BaseStat.StatType.AttackSpeed)
        {
            return;
        }


        UpdateAttackFloat();
    }
Exemplo n.º 21
0
    public float GetStatMaxValue(StatType type)
    {
        BaseStat targetStat = GetStat(type);

        CappedStat cap = TryConvertToCappedStat(targetStat);

        if (cap != null)
        {
            return(cap.MaxValue);
        }

        //if(targetStat != null && targetStat is CappedStat) {
        //    CappedStat capped = targetStat as CappedStat;

        //    return capped.MaxValue;
        //}

        Debug.LogError("The maximum value was reqested for a stat with no max. Returning 0");

        return(0f);
    }
Exemplo n.º 22
0
    public float GetStatBaseValue(StatType type)
    {
        BaseStat targetStat = GetStat(type);

        return(targetStat != null ? targetStat.BaseValue : 0f);
    }
Exemplo n.º 23
0
    //public void BuffStat(BaseStat stat)
    //{
    //    FindStat(stat.Type).Buff(stat.FinalValue);
    //}

    public void RemoveBuffStat(BaseStat.StatType type, int value)
    {
        FindStat(type).RemoveBuff(value);
    }
Exemplo n.º 24
0
 public BaseStat FindStat(BaseStat.StatType type)
 {
     return(Stats.Find(stat => stat.Type == type));
 }
Exemplo n.º 25
0
 private void OnStatChanged(BaseStat.StatType type, GameObject cause)
 {
 }
Exemplo n.º 26
0
    public void AddStat(StatType type, float value, float maxValue)
    {
        CappedStat newCappedStat = new CappedStat(type, value, maxValue);

        AddStat(newCappedStat);
    }
Exemplo n.º 27
0
 public static void ApplyUntrackedStatMod(StatCollection source, StatCollection target, StatType stat, float value)
 {
     target.ApplyPermanentMod(stat, value, StatModificationType.Additive, source.Owner);
     SendStatChangeEvent(source.Owner, target.Owner, stat, value);
 }
Exemplo n.º 28
0
    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);
    }
Exemplo n.º 29
0
    public static void RemoveTrackedStatMod(StatCollection source, StatCollection target, StatType stat, StatModifier mod, params StatModifierOption[] statOptions)
    {
        GameObject s = source != null ? source.Owner : null;
        GameObject t = target != null ? target.Owner : null;

        if (t != null)
        {
            target.RemoveTrackedMod(stat, mod, s, statOptions);
            SendStatChangeEvent(source.Owner, t, stat, -mod.Value);
        }
        else
        {
            Debug.LogWarning("a stat mod: " + mod + " could not be removed from a target because it was null");
        }
    }
Exemplo n.º 30
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)
    {
        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);
        }
    }