Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / NPC / Orc / Actions / RequestPosition.cs
@Rackday Rackday on 29 Oct 857 bytes Major Update
  1. using UnityEngine;
  2. using MyCollections.AI.FinitStateMachine;
  3. [CreateAssetMenu(menuName = "Finite State Machine/Action/RequestPosition")]
  4. public class RequestPosition : Action
  5. {
  6. public override void Run(FSM fsm)
  7. {
  8. fsm.Controller.Agent.agentStop = true;
  9. if (fsm == null)
  10. {
  11. Debug.Log("Fsm is null");
  12. }
  13. if (fsm.Controller == null)
  14. {
  15. Debug.Log("Controller is NUll");
  16. }
  17. if (fsm.Controller.Agent == null)
  18. {
  19. Debug.Log("Agent is NUll");
  20. }
  21. if (fsm.Controller.timer > 0f)
  22. {
  23. fsm.Controller.timer -= Time.deltaTime;
  24. }
  25. else
  26. {
  27. //Request a path
  28. fsm.Controller.NPCManager.RequestPosition(fsm.Controller.Agent);
  29. fsm.Controller.timer = 0f;
  30. }
  31. }
  32. }