示例#1
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);

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

        if (stat == Constants.BaseStatType.Health && value < 0f)
        {
            VisualEffectManager.MakeFloatingText(Mathf.Abs(sendableValue).ToString(), targetOfChagnge.transform.position);
        }
    }
    public void InitializeDurationalStatChange(StatCollection.BaseStat.BaseStatType targetStat, StatCollection.StatModificationType modType, float statAdjValue)
    {
        this.targetStat   = targetStat;
        this.modType      = modType;
        this.statAdjValue = statAdjValue;


        if (StatusManager.IsTargetAlreadyAffected(targetEntity, this, sourceAbility) == false)
        {
            CreateStatMod();
        }
    }