BattleServerEventHelper.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using System;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. namespace ET.Server
  5. {
  6. /// <summary>
  7. /// 战斗服事件工具类
  8. /// </summary>
  9. public static class BattleServerEventHelper
  10. {
  11. /// <summary>
  12. /// area related battleServerEvent
  13. /// </summary>
  14. /// <param name="msg"></param>
  15. public static void AreaBattleServerEvent(JObject msg)
  16. {
  17. // Log.Debug($"AreaBattleServerEvent msg: {JsonConvert.SerializeObject(msg, Formatting.Indented)}");
  18. long instanceId = Convert.ToInt64(msg.SelectToken("instanceId"));
  19. Map map = GameMapComponent.Instance.Get(instanceId);
  20. if (map == null)
  21. {
  22. Log.Warning($"areaBattleServerEvent no area: {msg}");
  23. return;
  24. }
  25. switch (Convert.ToString(msg.SelectToken("eventName")))
  26. {
  27. case "unitDead":
  28. {
  29. map.GetComponent<MapEventComponent>().OnUnitDead(msg);
  30. return;
  31. }
  32. case "message":
  33. {
  34. map.GetComponent<MapEventComponent>().OnMessageEvent(msg);
  35. return;
  36. }
  37. case "gameOver":
  38. {
  39. map.GetComponent<MapEventComponent>().OnGameOver();
  40. return;
  41. }
  42. case "pickItem":
  43. {
  44. map.GetComponent<MapEventComponent>().OnPickItem(msg);
  45. return;
  46. }
  47. case "KillBossEventB2R":
  48. {
  49. map.GetComponent<MapEventComponent>().OnKillBoss(msg);
  50. return;
  51. }
  52. case "BattleReportEventB2R":
  53. {
  54. map.GetComponent<MapEventComponent>().OnBattleReport(msg);
  55. return;
  56. }
  57. default:
  58. {
  59. Log.Error($"unknown area event: {msg}");
  60. return;
  61. }
  62. }
  63. }
  64. /// <summary>
  65. /// player related battleServerEvent
  66. /// </summary>
  67. /// <param name="msg"></param>
  68. public static void PlayerBattleServerEvent(JObject msg)
  69. {
  70. Log.Debug($"PlayerBattleServerEvent msg: {JsonConvert.SerializeObject(msg, Formatting.Indented)}");
  71. switch (Convert.ToString(msg.SelectToken("eventName")))
  72. {
  73. case "ConsumeItemEventB2R":
  74. {
  75. return;
  76. }
  77. case "interActiveItem":
  78. {
  79. return;
  80. }
  81. case "changeSceneProgress":
  82. {
  83. return;
  84. }
  85. case "TransUnitEventB2R":
  86. {
  87. return;
  88. }
  89. case "SummonMountEventB2R":
  90. {
  91. return;
  92. }
  93. case "ShowRebirthDialogueB2R":
  94. {
  95. return;
  96. }
  97. case "TriggerSceneEventB2R":
  98. {
  99. return;
  100. }
  101. case "PlayerExceptionEventB2R":
  102. {
  103. return;
  104. }
  105. }
  106. }
  107. /// <summary>
  108. /// task related battleServerEvent
  109. /// </summary>
  110. /// <param name="msg"></param>
  111. public static void TaskBattleServerEvent(JObject msg)
  112. {
  113. Log.Debug($"TaskBattleServerEvent msg: {JsonConvert.SerializeObject(msg, Formatting.Indented)}");
  114. }
  115. public static void MapNotifyEvent(JObject msg)
  116. {
  117. Log.Debug($"MapNotifyEvent msg: {JsonConvert.SerializeObject(msg, Formatting.Indented)}");
  118. }
  119. }
  120. }