IllsionFunc.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 XmdsBattleClientBot;
  10. using CommonLang;
  11. namespace XmdsBotTest.Runner
  12. {
  13. public class IllsionFunc : BotRunner.RunnerModule
  14. {
  15. private int lv;
  16. public IllsionFunc() {
  17. module_name = "幻境";
  18. }
  19. public IllsionFunc(BotRunner r) : base(r)
  20. {
  21. }
  22. protected internal override void OnGateBindPlayer(BindPlayerResponse e)
  23. {
  24. base.OnGateBindPlayer(e);
  25. lv = e.s2c_player.level;
  26. }
  27. protected internal override void OnBattleActorReady(CommonAI.ZoneClient.ZoneLayer layer, CommonAI.ZoneClient.ZoneActor actor)
  28. {
  29. layer.AddTimePeriodicMS(Config.CheckIntervalMS, (t) =>
  30. {
  31. if (IsCanJoin)
  32. {
  33. enterLllsionRequest();
  34. }
  35. });
  36. }
  37. private void enterLllsionRequest()
  38. {
  39. HashMap<int, Dictionary<string, object>> sect = BotClientManager.GetLuaData("Section.lua");
  40. if (sect == null) return;
  41. int id = 0;
  42. foreach (var elem in sect) {
  43. object minLv = null;
  44. object maxLv = null;
  45. elem.Value.TryGetValue("MinLv", out minLv);
  46. elem.Value.TryGetValue("MaxLv",out maxLv);
  47. if (lv >= Convert.ToInt32(minLv) && lv <= Convert.ToInt32(maxLv)) {
  48. id = elem.Key;
  49. break;
  50. }
  51. }
  52. if (id > 0)
  53. {
  54. client.GameSocket.fightLevelHandler.enterLllsionRequest(id,
  55. (err, rsp) =>
  56. { });
  57. }
  58. else {
  59. //Console.WriteLine("can not find the satisfied id:{0} playerLv;{1}",id,lv);
  60. }
  61. }
  62. protected override int rand()
  63. {
  64. return Config.RandNum;
  65. }
  66. [Desc("幻境配置")]
  67. [Expandable]
  68. public class Config : ConfigBase
  69. {
  70. [Desc("幻境检测间隔")]
  71. public static int CheckIntervalMS = 5000;
  72. [Desc("幻境随机数")]
  73. public static int RandNum = 15;
  74. public override string ToString()
  75. {
  76. return "幻境配置";
  77. }
  78. public override void popG2DPropertyDialog()
  79. {
  80. CommonFroms.G2D.G2DPropertyDialog<IllsionFunc.Config>.Show("修改配置", this);
  81. }
  82. }
  83. }
  84. }