Example #1
0
        public virtual void ApplyChange(float value)
        {
            if (debug)
            {
                Debug.Log(gameObject.name + " " + nameof(currentValue) + " is " + currentValue + " before " + value + " change");
            }

            currentValue = Mathf.Clamp(currentValue + value, 0, maximumValue.Value);
            if (nullify)
            {
                currentValue = 0;
            }

            if (debug)
            {
                Debug.Log(gameObject.name + " " + nameof(currentValue) + " is " + currentValue + " after " + value + " change");
            }

            EventResourceChanged?.Invoke(currentValue, maximumValue.Value);

            if (currentValue == 0)
            {
                EventResourceEmpty?.Invoke();
            }
        }
Example #2
0
        public virtual void SetValue(float value)
        {
            currentValue = value;

            if (currentValue == 0)
            {
                EventResourceEmpty?.Invoke();
            }
        }