Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / role / enemy / state / AiNotifyState.cs
@小李xl 小李xl on 22 Nov 2023 882 bytes 完善ai状态机
  1. using System;
  2.  
  3. namespace EnemyState;
  4.  
  5. /// <summary>
  6. /// 发现目标, 通知其它敌人
  7. /// </summary>
  8. public class AiNotifyState : StateBase<Enemy, 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. throw new Exception("进入 AIAdvancedStateEnum.AiNotify 没有攻击目标!");
  20. }
  21. _timer = 1.2f;
  22. //通知其它角色
  23. Master.World.NotifyEnemyTarget(Master, Master.LookTarget);
  24. Master.AnimationPlayer.Play(AnimatorNames.Notify);
  25. }
  26.  
  27. public override void Process(float delta)
  28. {
  29. Master.DoIdle();
  30. _timer -= delta;
  31. if (_timer <= 0)
  32. {
  33. ChangeState(AIStateEnum.AiTailAfter);
  34. }
  35. }
  36. }