RiftMayhem/Assets/Scripts/ClassResource.cs
2025-02-21 18:35:51 +00:00

43 lines
903 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class ClassResource : Resource
{
protected override void Start()
{
currentValue = 0f;
onResourceChanged.Invoke(currentValue);
canRegen = false;
}
public override void ChangeValue(float value)
{
if (value == 0) return;
//Debug.Log("Class resource change value:" + value);
currentValue += value;
currentValue = Mathf.Clamp(currentValue, 0, maxValue);
onResourceChanged.Invoke(currentValue);
}
public override void SetCurrentValue(float value)
{
currentValue = value;
currentValue = Mathf.Clamp(currentValue, 0, maxValue);
onResourceChanged.Invoke(currentValue);
}
public bool EnoughResource(float cost)
{
return currentValue >= cost;
}
}