using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenu(menuName = "Finite State Machine/Condition/LowHealthCondition")] public class LowHealthCondition : Condition { [SerializeField] private float lowhpvalue; protected override bool Test(FiniteStateMachine fsm) { /*Debug.Log("I'm on hp"); if (fsm.monoDictionary.HasKey("hp")) { Health hp; fsm.TryGetComponent<Health>(out hp); fsm.monoDictionary.SetValue("hp", hp); return false; } else { Debug.Log((fsm.monoDictionary.GetValue("hp") as Health)); return false; }*/ if (!fsm.monoDictionary.HasKey("hp")) fsm.monoDictionary.SetValue("hp", fsm.GetComponent<Health>()); return (fsm.monoDictionary.GetValue("hp") as Health).hp < lowhpvalue; } }