ActionBehit.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 ActionBehit : Action
  12. {
  13. [BehaviorDesigner.Runtime.Tasks.Tooltip("等待时间")]
  14. public SharedFloat waitTime = 1;
  15. /// <summary>
  16. /// 开始时间
  17. /// </summary>
  18. private float startTime;
  19. /// <summary>
  20. /// 动画控制器
  21. /// </summary>
  22. private Animator animator = null;
  23. public override void OnAwake()
  24. {
  25. animator = gameObject.GetComponentInChildren<Animator>();
  26. }
  27. public override void OnStart()
  28. {
  29. startTime = Time.time;
  30. animator.SetBool("Hit", true);
  31. }
  32. public override TaskStatus OnUpdate()
  33. {
  34. if (startTime + waitTime.Value < Time.time)
  35. {
  36. return TaskStatus.Success;
  37. }
  38. return TaskStatus.Running;
  39. }
  40. }