コード例 #1
0
    private void DispatchStatisticChangeEvents(StatisticType statistic, float previousValue, float currentValue)
    {
#if UNITY_EDITOR
        Debug.Log(LogUtility.MakeLogStringFormat("Player", "{0}: {1} ==> {2}", statistic, previousValue, currentValue));
#endif

        switch (statistic)
        {
        case StatisticType.WalkSpeed:
            OnWalkSpeedChange.Invoke(previousValue, currentValue);
            break;


        case StatisticType.JumpPower:
            OnJumpPowerChange.Invoke(previousValue, currentValue);
            break;


        case StatisticType.MaxHp:
            stats[StatisticType.Hp] += currentValue - previousValue;
            break;


        case StatisticType.CriticalChance:
            OnCriticalChanceChange.Invoke(previousValue, currentValue);
            break;


        case StatisticType.CriticalDamage:
            OnCriticalDamageChange.Invoke(previousValue, currentValue);
            break;


        case StatisticType.BaseDamage:
            OnBaseDamageChange.Invoke(previousValue, currentValue);
            break;


        case StatisticType.AttackSpeed:
            OnAttackSpeedChange.Invoke(previousValue, currentValue);
            break;


        case StatisticType.Hp:
            OnHpChange.Invoke(currentValue, stats[StatisticType.MaxHp]);
            break;
        }
    }
コード例 #2
0
    void HandleOnPickup(Pickups type)
    {
        if (type == Pickups.Health)
        {
            if (hp == maxHitPoints)
            {
                return;
            }

            hp += hpGainedOnPickup;
            if (hp > maxHitPoints)
            {
                hp = maxHitPoints;
            }

            OnHpChange?.Invoke(hp, maxHitPoints);
        }
    }