BattleServerEventHelper.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 "Dead":
  33. {
  34. map.GetComponent<MapEventComponent>().OnDead(msg);
  35. return;
  36. }
  37. case "message":
  38. {
  39. map.GetComponent<MapEventComponent>().OnMessageEvent(msg);
  40. return;
  41. }
  42. case "gameOver":
  43. {
  44. map.GetComponent<MapEventComponent>().OnGameOver();
  45. return;
  46. }
  47. case "pickItem":
  48. {
  49. map.GetComponent<MapEventComponent>().OnPickItem(msg);
  50. return;
  51. }
  52. case "KillBossEventB2R":
  53. {
  54. map.GetComponent<MapEventComponent>().OnKillBoss(msg);
  55. return;
  56. }
  57. case "BattleReportEventB2R":
  58. {
  59. map.GetComponent<MapEventComponent>().OnBattleReport(msg);
  60. return;
  61. }
  62. default:
  63. {
  64. Log.Error($"unknown area event: {msg}");
  65. return;
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// player related battleServerEvent
  71. /// </summary>
  72. /// <param name="msg"></param>
  73. public static void PlayerBattleServerEvent(JObject msg)
  74. {
  75. Log.Debug($"PlayerBattleServerEvent msg: {JsonConvert.SerializeObject(msg, Formatting.Indented)}");
  76. switch (Convert.ToString(msg.SelectToken("eventName")))
  77. {
  78. case "ConsumeItemEventB2R":
  79. {
  80. return;
  81. }
  82. case "interActiveItem":
  83. {
  84. return;
  85. }
  86. case "changeSceneProgress":
  87. {
  88. return;
  89. }
  90. case "TransUnitEventB2R":
  91. {
  92. return;
  93. }
  94. case "SummonMountEventB2R":
  95. {
  96. return;
  97. }
  98. case "ShowRebirthDialogueB2R":
  99. {
  100. return;
  101. }
  102. case "TriggerSceneEventB2R":
  103. {
  104. return;
  105. }
  106. case "PlayerExceptionEventB2R":
  107. {
  108. return;
  109. }
  110. }
  111. }
  112. /// <summary>
  113. /// task related battleServerEvent
  114. /// </summary>
  115. /// <param name="msg"></param>
  116. public static void TaskBattleServerEvent(JObject msg)
  117. {
  118. Log.Debug($"TaskBattleServerEvent msg: {JsonConvert.SerializeObject(msg, Formatting.Indented)}");
  119. }
  120. public static void MapNotifyEvent(JObject msg)
  121. {
  122. Log.Debug($"MapNotifyEvent msg: {JsonConvert.SerializeObject(msg, Formatting.Indented)}");
  123. }
  124. }
  125. }