Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / role / ai / state / AiNotifyState.cs
  1. using System;
  2.  
  3. namespace AiState;
  4.  
  5. /// <summary>
  6. /// 发现目标, 通知其它敌人
  7. /// </summary>
  8. public class AiNotifyState : StateBase<AiRole, AIStateEnum>
  9. {
  10. private float _timer;
  11. public AiNotifyState() : base(AIStateEnum.AiNotify)
  12. {
  13. }
  14.  
  15. public override void Enter(AIStateEnum prev, params object[] args)
  16. {
  17. if (Master.LookTarget == null)
  18. {
  19. ChangeState(AIStateEnum.AiNormal);
  20. return;
  21. //throw new Exception("进入 AIAdvancedStateEnum.AiNotify 没有攻击目标!");
  22. }
  23. _timer = 1.2f;
  24. //通知其它角色
  25. Master.World.NotifyEnemyTarget(Master, Master.LookTarget);
  26. if (Master.AnimationPlayer.HasAnimation(AnimatorNames.Notify))
  27. {
  28. Master.AnimationPlayer.Play(AnimatorNames.Notify);
  29. }
  30. }
  31.  
  32. public override void Process(float delta)
  33. {
  34. Master.DoIdle();
  35. _timer -= delta;
  36. if (_timer <= 0)
  37. {
  38. ChangeState(AIStateEnum.AiTailAfter);
  39. }
  40. }
  41. }