ActionDie.cs 958 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using BehaviorDesigner.Runtime;
  5. using BehaviorDesigner.Runtime.Tasks;
  6. using UnityEngine.SceneManagement;
  7. using UnityGameFramework.Runtime;
  8. /// <summary>
  9. /// 行为 死亡
  10. /// </summary>
  11. public class ActionDie : Action
  12. {
  13. [BehaviorDesigner.Runtime.Tasks.Tooltip("等待时间")]
  14. public SharedFloat waitingTime = 3;
  15. /// <summary>
  16. /// 开始时间
  17. /// </summary>
  18. private float startTime;
  19. private Role role = null;
  20. public override void OnAwake()
  21. {
  22. role = gameObject.GetComponent<Role>();
  23. }
  24. public override void OnStart()
  25. {
  26. startTime = Time.time;
  27. }
  28. public override TaskStatus OnUpdate()
  29. {
  30. if (startTime + waitingTime.Value < Time.time)
  31. {
  32. RoleManager.Instance.DeleteRole(role);
  33. return TaskStatus.Success;
  34. }
  35. return TaskStatus.Running;
  36. }
  37. }