Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / role / enemy / advancedState / AiAstonishedState.cs
  1. using Godot;
  2.  
  3. namespace AdvancedState;
  4.  
  5. /// <summary>
  6. /// 发现目标时的惊讶状态
  7. /// </summary>
  8. public class AiAstonishedState : StateBase<AdvancedEnemy, AIAdvancedStateEnum>
  9. {
  10. /// <summary>
  11. /// 下一个状态
  12. /// </summary>
  13. public AIAdvancedStateEnum NextState;
  14.  
  15. private object[] _args;
  16. private float _timer;
  17. public AiAstonishedState() : base(AIAdvancedStateEnum.AiAstonished)
  18. {
  19. }
  20.  
  21. public override void Enter(AIAdvancedStateEnum prev, params object[] args)
  22. {
  23. if (args.Length == 0)
  24. {
  25. Debug.Log("进入 AINormalStateEnum.AiAstonished 状态必传入下一个状态做完参数!");
  26. ChangeState(prev);
  27. return;
  28. }
  29.  
  30. NextState = (AIAdvancedStateEnum)args[0];
  31. _args = args;
  32. _timer = 0.6f;
  33.  
  34. if (NextState == AIAdvancedStateEnum.AiLeaveFor)
  35. {
  36. var target = (ActivityObject)args[1];
  37. Master.LookTargetPosition(target.GetCenterPosition());
  38. }
  39. //播放惊讶表情
  40. Master.AnimationPlayer.Play(AnimatorNames.Astonished);
  41. }
  42.  
  43. public override void Process(float delta)
  44. {
  45. Master.DoIdle();
  46. _timer -= delta;
  47. if (_timer <= 0)
  48. {
  49. if (_args.Length == 1)
  50. {
  51. ChangeState(NextState);
  52. }
  53. else if (_args.Length == 2)
  54. {
  55. ChangeState(NextState, _args[1]);
  56. }
  57. else if (_args.Length == 3)
  58. {
  59. ChangeState(NextState, _args[1], _args[2]);
  60. }
  61. }
  62. }
  63. }