BattleMgr_Cmd.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using CommonAI.Zone;
  2. using ET.Client;
  3. using ET.EventType;
  4. namespace ET
  5. {
  6. [Event(SceneType.None)]
  7. public class BattleFuncHandler : BEvent<BattleFunc>
  8. {
  9. public override void OnEvent(BattleFunc a)
  10. {
  11. Log.Debug($"Battle Func:{a.FuncIndex}");
  12. asyncHandler(a.FuncIndex).Coroutine();
  13. }
  14. private async ETTask asyncHandler(BattleFunc.Index index)
  15. {
  16. var session = PlayerComponent.Instance.ClientScene().GetComponent<SessionComponent>().Session;
  17. switch (index)
  18. {
  19. case BattleFunc.Index.Func2:
  20. var ret = await session.Call(new C2G_AddUnitsToMap()
  21. {
  22. UnitId = 102,
  23. Force = 1,
  24. X = 2,
  25. Y = 30
  26. });
  27. if (ret.Error != 0)
  28. {
  29. Log.Error(ret.Message);
  30. }
  31. break;
  32. default:
  33. break;
  34. }
  35. }
  36. }
  37. //发送战斗服指令相关
  38. public partial class BattleMgr
  39. {
  40. private bool autoFight;
  41. public bool AutoFight
  42. {
  43. get
  44. {
  45. return autoFight;
  46. }
  47. set
  48. {
  49. if(value == autoFight) return;
  50. else
  51. {
  52. autoFight = value;
  53. }
  54. }
  55. }
  56. public CommonAI.Zone.Action SetAutoFight(bool flag)
  57. {
  58. return new UnitGuardAction(UnitMgr.Instance.ActorId, flag, CommonAI.XmdsConstConfig.AUTO_GUARD_MODE_POINT);
  59. }
  60. }
  61. }