BattleServerEventHelper.cs 3.7 KB

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