AI_XunLuo.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Unity.Mathematics;
  2. namespace ET.Client
  3. {
  4. public class AI_XunLuo: AAIHandler
  5. {
  6. public override int Check(AIComponent aiComponent, AIConfig aiConfig)
  7. {
  8. long sec = TimeHelper.ClientNow() / 1000 % 15;
  9. if (sec < 10)
  10. {
  11. return 0;
  12. }
  13. return 1;
  14. }
  15. public override async ETTask Execute(AIComponent aiComponent, AIConfig aiConfig, ETCancellationToken cancellationToken)
  16. {
  17. Scene clientScene = aiComponent.DomainScene();
  18. Unit myUnit = UnitHelper.GetMyUnitFromClientScene(clientScene);
  19. if (myUnit == null)
  20. {
  21. return;
  22. }
  23. Log.Debug("开始巡逻");
  24. while (true)
  25. {
  26. XunLuoPathComponent xunLuoPathComponent = myUnit.GetComponent<XunLuoPathComponent>();
  27. float3 nextTarget = xunLuoPathComponent.GetCurrent();
  28. await myUnit.MoveToAsync(nextTarget, cancellationToken);
  29. if (cancellationToken.IsCancel())
  30. {
  31. return;
  32. }
  33. xunLuoPathComponent.MoveNext();
  34. }
  35. }
  36. }
  37. }