Five2FiveFunc.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using pomelo.connector;
  7. using CommonLang.Property;
  8. using pomelo.area;
  9. using pomelo.five2five;
  10. namespace XmdsBotTest.Runner
  11. {
  12. public class Five2FiveFunc : BotRunner.RunnerModule
  13. {
  14. public Five2FiveFunc() {
  15. module_name = "试炼大赛";
  16. }
  17. public Five2FiveFunc(BotRunner r) : base(r)
  18. {
  19. bot.Client.GameSocket.listen<Five2FiveMatchMemberInfoPush>(on_five2FiveMatchMemberInfoPush);
  20. }
  21. protected internal override void OnGateBindPlayer(BindPlayerResponse e)
  22. {
  23. base.OnGateBindPlayer(e);
  24. }
  25. protected internal override void OnBattleActorReady(CommonAI.ZoneClient.ZoneLayer layer, CommonAI.ZoneClient.ZoneActor actor)
  26. {
  27. layer.AddTimePeriodicMS(Config.CheckIntervalMS, (t) =>
  28. {
  29. if (IsCanJoin)
  30. {
  31. Five2FiveMatchRequest();
  32. }
  33. });
  34. }
  35. private void Five2FiveMatchRequest()
  36. {
  37. client.GameSocket.five2FiveHandler.five2FiveMatchRequest(1,
  38. (err, rsp) =>
  39. { });
  40. }
  41. private void on_five2FiveMatchMemberInfoPush(Five2FiveMatchMemberInfoPush e)
  42. {
  43. client.GameSocket.five2FiveHandler.five2FiveReadyRequest(e.tempTeamId,
  44. (err, rsp) =>
  45. { });
  46. }
  47. protected override int rand()
  48. {
  49. return Config.RandNum;
  50. }
  51. [Desc("试炼大赛配置")]
  52. [Expandable]
  53. public class Config : ConfigBase
  54. {
  55. [Desc("试炼大赛检测间隔")]
  56. public static int CheckIntervalMS = 5000;
  57. [Desc("试炼大赛随机数")]
  58. public static int RandNum = 8;
  59. public override string ToString()
  60. {
  61. return "试炼大赛";
  62. }
  63. public override void popG2DPropertyDialog()
  64. {
  65. CommonFroms.G2D.G2DPropertyDialog<Five2FiveFunc.Config>.Show("修改配置", this);
  66. }
  67. }
  68. }
  69. }