Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / AI / Navmesh / Conditions / LowHealthCondition.cs
@Rackday Rackday on 21 Aug 925 bytes Project Added
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. [CreateAssetMenu(menuName = "Finite State Machine/Condition/LowHealthCondition")]
  5. public class LowHealthCondition : Condition
  6. {
  7. [SerializeField] private float lowhpvalue;
  8. protected override bool Test(FiniteStateMachine fsm)
  9. {
  10. /*Debug.Log("I'm on hp");
  11. if (fsm.monoDictionary.HasKey("hp"))
  12. {
  13. Health hp;
  14. fsm.TryGetComponent<Health>(out hp);
  15. fsm.monoDictionary.SetValue("hp", hp);
  16. return false;
  17. }
  18. else
  19. {
  20. Debug.Log((fsm.monoDictionary.GetValue("hp") as Health));
  21. return false;
  22. }*/
  23. if (!fsm.monoDictionary.HasKey("hp")) fsm.monoDictionary.SetValue("hp", fsm.GetComponent<Health>());
  24. return (fsm.monoDictionary.GetValue("hp") as Health).hp < lowhpvalue;
  25. }
  26. }