JumperAIAction.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using BehaviorDesigner.Runtime.Tasks;
  3. using ExtensionMethods;
  4. using UnityEngine;
  5. public class JumperAIAction
  6. {
  7. [TaskDescription("跳拳攻击")]
  8. [TaskCategory("Enemy/Jumper")]
  9. public class JumperAttack : BehaviorDesigner.Runtime.Tasks.Action
  10. {
  11. private Transform player
  12. {
  13. get
  14. {
  15. return R.Player.Transform;
  16. }
  17. }
  18. public override void OnAwake()
  19. {
  20. this.action = base.GetComponent<JumperAction>();
  21. }
  22. public override void OnStart()
  23. {
  24. int dir = InputSetting.JudgeDir(this.transform.position, this.player.position);
  25. switch (this.atkType)
  26. {
  27. case JumperAIAction.JumperAttack.AtkType.Atk1:
  28. this.action.Attack1(dir);
  29. break;
  30. case JumperAIAction.JumperAttack.AtkType.Atk2:
  31. this.action.Attack2(dir);
  32. break;
  33. case JumperAIAction.JumperAttack.AtkType.Atk3:
  34. this.action.Attack3(dir);
  35. break;
  36. case JumperAIAction.JumperAttack.AtkType.Atk4:
  37. this.action.Attack4(dir);
  38. break;
  39. case JumperAIAction.JumperAttack.AtkType.Atk5:
  40. this.action.Attack5(dir);
  41. break;
  42. }
  43. }
  44. public override TaskStatus OnUpdate()
  45. {
  46. return (!this.action.stateMachine.currentState.IsInArray(JumperAction.AttackSta)) ? TaskStatus.Success : TaskStatus.Running;
  47. }
  48. public JumperAIAction.JumperAttack.AtkType atkType;
  49. private JumperAction action;
  50. public enum AtkType
  51. {
  52. Atk1,
  53. Atk2,
  54. Atk3,
  55. Atk4,
  56. Atk5
  57. }
  58. }
  59. [TaskDescription("跳拳防御")]
  60. [TaskCategory("Enemy/Jumper")]
  61. public class JumperDefence : BehaviorDesigner.Runtime.Tasks.Action
  62. {
  63. public override void OnAwake()
  64. {
  65. this.action = base.GetComponent<JumperAction>();
  66. }
  67. public override void OnStart()
  68. {
  69. this.action.Defence();
  70. }
  71. public override TaskStatus OnUpdate()
  72. {
  73. return (!this.action.IsInDefenceState()) ? TaskStatus.Success : TaskStatus.Running;
  74. }
  75. private JumperAction action;
  76. }
  77. }