using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenu(menuName = "Finite State Machine/Action/Consume Mana")] public class ConsumeManaAction : Action { public float quantity; public bool isPercentage; public override void Act(FiniteStateMachine fsm) { Mana manaBehaviour; if (fsm.target != null && fsm.target.TryGetComponent<Mana>(out manaBehaviour)) { if (manaBehaviour.mana > 0) { float value = 0; if (isPercentage) { value = manaBehaviour.mana * (quantity / 100); } else { value = quantity * Time.deltaTime; } manaBehaviour.Consume(value); } } } }