Beispiel #1
0
    private void OnStatChanged(EventData data)
    {
        Entity target = data.GetMonoBehaviour("Target") as Entity;

        if (target != player)
        {
            return;
        }

        Constants.BaseStatType stat = (Constants.BaseStatType)data.GetInt("Stat");

        if (stat != Constants.BaseStatType.Money && stat != Constants.BaseStatType.Keys)
        {
            return;
        }


        switch (stat)
        {
        case Constants.BaseStatType.Money:
            moneyText.text = "Money: " + "$" + player.stats.GetStatModifiedValue(Constants.BaseStatType.Money).ToString();
            break;

        case Constants.BaseStatType.Keys:
            keysText.text = "Keys: " + player.stats.GetStatModifiedValue(Constants.BaseStatType.Keys).ToString();
            break;
        }
    }
Beispiel #2
0
    private void OnStatChanged(EventData data)
    {
        Constants.BaseStatType stat = (Constants.BaseStatType)data.GetInt("Stat");
        float  value  = data.GetFloat("Value");
        Entity target = data.GetMonoBehaviour("Target") as Entity;
        Entity cause  = data.GetMonoBehaviour("Cause") as Entity;

        if (stat != this.stat)
        {
            return;
        }

        if (sourceWasChanged && target != parentAbility.source)
        {
            return;
        }

        if (sourceCausedChange && cause != parentAbility.source)
        {
            return;
        }

        if (gained && value < 0)
        {
            return;
        }

        if (!gained && value > 0)
        {
            return;
        }

        CheckReady();
    }
Beispiel #3
0
    private void OnDamageDealt(EventData data)
    {
        Constants.BaseStatType stat = (Constants.BaseStatType)data.GetInt("Stat");
        Entity target = data.GetMonoBehaviour("Target") as Entity;
        Entity cause  = data.GetMonoBehaviour("Cause") as Entity;
        float  value  = data.GetFloat("Value");

        //Debug.Log(target.gameObject + " has been damaged by " + cause.gameObject);

        if (cause != source)
        {
            return;
        }

        if (stat != Constants.BaseStatType.Health)
        {
            return;
        }

        if (value > 0)
        {
            return;
        }


        //Debug.Log(abilityName + " is activating on damage dealt");
        AddTarget(target);


        Activate();
    }
Beispiel #4
0
    protected virtual void OnStatChanged(EventData data)
    {
        Constants.BaseStatType stat = (Constants.BaseStatType)data.GetInt("Stat");
        Entity target = data.GetMonoBehaviour("Target") as Entity;

        //Debug.Log("Event Recieved: " + target.gameObject.name + " ::: " + stat);

        if (target != owner)
        {
            //Debug.Log(target.gameObject.name + " does not match " + owner.gameObject.name);

            return;
        }


        switch (stat)
        {
        case Constants.BaseStatType.MoveSpeed:
            //Debug.Log("MoveSpeed Event Recieved");
            maxSpeed = owner.stats.GetStatModifiedValue(Constants.BaseStatType.MoveSpeed);
            break;

        case Constants.BaseStatType.JumpForce:
            jumpForce = owner.stats.GetStatModifiedValue(Constants.BaseStatType.JumpForce);
            break;
        }
    }
Beispiel #5
0
    private void OnDamageTaken(EventData data)
    {
        Constants.BaseStatType stat = (Constants.BaseStatType)data.GetInt("Stat");
        //Entity target = data.GetMonoBehaviour("Target") as Entity;
        Entity cause  = data.GetMonoBehaviour("Cause") as Entity;
        Entity target = data.GetMonoBehaviour("Target") as Entity;
        float  value  = data.GetFloat("Value");

        if (cause == source)
        {
            return;
        }

        if (target != source)
        {
            return;
        }

        if (stat != Constants.BaseStatType.Health)
        {
            return;
        }

        if (value > 0)
        {
            return;
        }


        //Debug.Log("Activating an on-damage-taken ability");
        Activate();
    }
Beispiel #6
0
    public static void RemoveTrackedStatMod(Entity targetOfChange, Constants.BaseStatType stat, StatCollection.StatModifer mod)
    {
        targetOfChange.stats.RemoveTrackedMod(stat, mod);

        Debug.Log("Removing a mod: " + stat + " value of " + mod.value);

        combatManager.SendStatChangeEvent(null, targetOfChange, stat, mod.value);
    }
Beispiel #7
0
    private void SendStatChangeEvent(Entity causeOfChagne, Entity targetOfChagnge, Constants.BaseStatType stat, float value)
    {
        EventData data = new EventData();

        data.AddMonoBehaviour("Cause", causeOfChagne);
        data.AddMonoBehaviour("Target", targetOfChagnge);
        data.AddInt("Stat", (int)stat);
        data.AddFloat("Value", value);

        //Debug.Log("Event Sent: " + stat.ToString() + " :: " + value);
        EventGrid.EventManager.SendEvent(Constants.GameEvent.StatChanged, data);
    }
Beispiel #8
0
    private BaseStat GetStat(Constants.BaseStatType statType)
    {
        for (int i = 0; i < baseStats.Count; i++)
        {
            if (baseStats[i].statType == statType)
            {
                return(baseStats[i]);
            }
        }

        return(null);
    }
Beispiel #9
0
    public void InitializeDurationalStatChange(Constants.BaseStatType targetStat, StatCollection.StatModificationType modType, float statAdjValue)
    {
        this.targetStat   = targetStat;
        this.modType      = modType;
        this.statAdjValue = statAdjValue;


        if (StatusManager.IsTargetAlreadyAffected(targetEntity, this, sourceAbility) == false)
        {
            CreateStatMod();
        }
    }
Beispiel #10
0
    public float GetStatMultipler(Constants.BaseStatType statType)
    {
        for (int i = 0; i < baseStats.Count; i++)
        {
            if (baseStats[i].statType == statType)
            {
                return(baseStats[i].GetTotalMultiplier());
            }
        }

        return(1f);
    }
Beispiel #11
0
    public float GetStatMaxValue(Constants.BaseStatType statType)
    {
        for (int i = 0; i < baseStats.Count; i++)
        {
            if (baseStats[i].statType == statType)
            {
                return(baseStats[i].MaxValue);
            }
        }

        return(0);
    }
Beispiel #12
0
    public EffectStatus(EffectStatus effectStatus)
    {
        effectName       = effectStatus.effectName;
        riderTarget      = effectStatus.riderTarget;
        effectType       = effectStatus.effectType;
        deliveryMethod   = effectStatus.deliveryMethod;
        animationTrigger = effectStatus.animationTrigger;

        applyToSpecificTarget = effectStatus.applyToSpecificTarget;
        targetIndex           = effectStatus.targetIndex;
        riders = effectStatus.CloneRiders();

        scaleFromBaseDamage = effectStatus.scaleFromBaseDamage;
        percentOfBaseDamage = effectStatus.percentOfBaseDamage;
        damagePerInterval   = effectStatus.damagePerInterval;

        statusType  = effectStatus.statusType;
        stackMethod = effectStatus.stackMethod;
        maxStack    = effectStatus.maxStack;
        duration    = effectStatus.duration;
        interval    = effectStatus.interval;

        onCompleteEffectName = effectStatus.onCompleteEffectName;

        affectMoveType  = effectStatus.affectMoveType;
        affectMoveValue = effectStatus.affectMoveValue;
        knocbackAngle   = effectStatus.knocbackAngle;

        statType            = effectStatus.statType;
        statAdjustmentValue = effectStatus.statAdjustmentValue;
        modType             = effectStatus.modType;



        switch (deliveryMethod)
        {
        case Constants.EffectDeliveryMethod.Melee:
            meleeDelivery.prefabName = effectStatus.meleeDelivery.prefabName;
            meleeDelivery.layerMask  = effectStatus.meleeDelivery.layerMask;
            break;

        case Constants.EffectDeliveryMethod.Projectile:
            projectileDelivery.prefabName = effectStatus.projectileDelivery.prefabName;
            projectileDelivery.layerMask  = effectStatus.projectileDelivery.layerMask;
            break;
        }
    }
Beispiel #13
0
    protected void OnStatChanged(EventData data) {
        Constants.BaseStatType stat = (Constants.BaseStatType)data.GetInt("Stat");
        Entity target = data.GetMonoBehaviour("Target") as Entity;
        Entity cause = data.GetMonoBehaviour("Cause") as Entity;

        if (target != owner)
            return;

        if(stat == Constants.BaseStatType.Health) {
            //Debug.Log(owner.stats.GetStatModifiedValue(Constants.BaseStatType.Health) + " is the health of " + owner.gameObject.name);

            float currentHealth = owner.stats.GetStatModifiedValue(Constants.BaseStatType.Health);
            float maxHealth = owner.stats.GetStatMaxValue(Constants.BaseStatType.Health);

            UpdateHealthBar(currentHealth, maxHealth);

            if (currentHealth <= 0f) {
                if(!cheat)
                    Die(cause);
            }
        }

    }
Beispiel #14
0
    public static void ApplyUntrackedStatMod(Entity causeOfChagne, Entity targetOfChagnge, Constants.BaseStatType stat, float value, StatCollection.StatModificationType modType = StatCollection.StatModificationType.Additive)
    {
        float sendableValue = 0f;

        if (stat == Constants.BaseStatType.Health)
        {
            float armor = targetOfChagnge.stats.GetStatModifiedValue(Constants.BaseStatType.Armor);
            //Debug.Log(armor + " is the armor of " + targetOfChagnge.entityName);
            sendableValue = Mathf.Clamp(value + armor, value, 0f);

            float damageReduction = targetOfChagnge.stats.GetStatModifiedValue(Constants.BaseStatType.DamageReduction);

            float convertedDR = Mathf.Clamp(Mathf.Abs(damageReduction - 1f), 0f, 1f);

            sendableValue *= convertedDR;
        }
        else
        {
            sendableValue = value;
        }


        targetOfChagnge.stats.ApplyUntrackedMod(stat, sendableValue, causeOfChagne, modType);

        combatManager.SendStatChangeEvent(causeOfChagne, targetOfChagnge, stat, sendableValue);

        if (stat == Constants.BaseStatType.Health && value < 0f)
        {
            VisualEffectManager.MakeFloatingText(Mathf.Abs(sendableValue).ToString(), targetOfChagnge.transform.position);
        }
    }
Beispiel #15
0
    public void RemoveTrackedMod(Constants.BaseStatType statType, StatModifer mod)
    {
        BaseStat targetStat = GetStat(statType);

        targetStat.RemoveModifier(mod);
    }
Beispiel #16
0
    public void ApplyTrackedMod(Constants.BaseStatType statType, StatModifer mod)
    {
        BaseStat targetStat = GetStat(statType);

        targetStat.ModifyStat(mod);
    }
Beispiel #17
0
    public void ApplyUntrackedMod(Constants.BaseStatType statType, float value, Entity source, StatModificationType modType = StatModificationType.Additive)
    {
        BaseStat targetStat = GetStat(statType);

        targetStat.ModifyStat(value, modType);
    }
Beispiel #18
0
 public BaseStat(Constants.BaseStatType statType, float baseValue, float maxValue)
 {
     this.statType = statType;
     BaseValue     = baseValue;
     MaxValue      = maxValue;
 }
Beispiel #19
0
    public static void ApplyTrackedStatMod(Entity causeOfChagne, Entity targetOfChange, Constants.BaseStatType stat, StatCollection.StatModifer mod)
    {
        targetOfChange.stats.ApplyTrackedMod(stat, mod);

        combatManager.SendStatChangeEvent(causeOfChagne, targetOfChange, stat, mod.value);

        if (stat == Constants.BaseStatType.Health && mod.value < 0f)
        {
            VisualEffectManager.MakeFloatingText(Mathf.Abs(mod.value).ToString(), targetOfChange.transform.position);
        }
    }
 public static void AddStaticPlayerStatAdjustment(Constants.BaseStatType targetStat, float value)
 {
     ApplyUntrackedStatMod(null, GameManager.GetPlayer(), targetStat, value);
 }