MapEventComponentSystem.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using Newtonsoft.Json;
  6. using Newtonsoft.Json.Linq;
  7. namespace ET.Server
  8. {
  9. [FriendOf(typeof (MapEventComponent))]
  10. [FriendOf(typeof (Map))]
  11. public static class MapEventComponentSystem
  12. {
  13. public class MapEventComponentAwakeSystem: AwakeSystem<MapEventComponent>
  14. {
  15. /// <summary>
  16. /// 场景事件组件创建
  17. /// </summary>
  18. /// <param name="self"></param>
  19. protected override void Awake(MapEventComponent self)
  20. {
  21. Log.Info($"创建战斗服事件组件...");
  22. }
  23. }
  24. public class MapEventComponentDestroySystem: DestroySystem<MapEventComponent>
  25. {
  26. /// <summary>
  27. /// 场景事件组件销毁
  28. /// </summary>
  29. /// <param name="self"></param>
  30. protected override void Destroy(MapEventComponent self)
  31. {
  32. Log.Info($"销毁战斗服事件组件...");
  33. }
  34. }
  35. /// <summary>
  36. /// 副本消息
  37. /// </summary>
  38. /// <param name="self"></param>
  39. /// <param name="msg"></param>
  40. public static void OnMessage(this MapEventComponent self, JObject msg)
  41. {
  42. string str = Convert.ToString(msg.SelectToken("msg"));
  43. string[] parames = str.Split(":");
  44. switch (parames[0])
  45. {
  46. case "Dead":
  47. {
  48. if ("Tower1".Equals(parames[1]))
  49. {
  50. Log.Debug($"塔1死亡事件...");
  51. }
  52. else if ("Tower2".Equals(parames[1]))
  53. {
  54. Log.Debug($"塔2死亡事件...");
  55. }
  56. else if ("Tower3".Equals(parames[1]))
  57. {
  58. Log.Debug($"塔3死亡事件...");
  59. }
  60. else
  61. {
  62. int objId = int.Parse(parames[1]);
  63. Log.Debug($"场景单位死亡...objId:{objId}");
  64. }
  65. break;
  66. }
  67. case "Revive":
  68. {
  69. int objId = int.Parse(parames[1]);
  70. if (objId > 0)
  71. {
  72. Log.Debug($"场景单位复活...objId:{objId}");
  73. }
  74. break;
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// 场景结算事件
  80. /// </summary>
  81. /// <param name="self"></param>
  82. public static void OnGameOver(this MapEventComponent self)
  83. {
  84. Map map = self.GetParent<Map>();
  85. if (map == null)
  86. {
  87. return;
  88. }
  89. Log.Debug($"场景结算事件...");
  90. }
  91. /// <summary>
  92. /// 拾取道具
  93. /// </summary>
  94. /// <param name="self"></param>
  95. /// <param name="msg"></param>
  96. public static void OnPickItem(this MapEventComponent self, JObject msg)
  97. {
  98. }
  99. /// <summary>
  100. /// 击杀boss
  101. /// </summary>
  102. /// <param name="self"></param>
  103. /// <param name="msg"></param>
  104. public static void OnKillBoss(this MapEventComponent self, JObject msg)
  105. {
  106. }
  107. /// <summary>
  108. /// 战报统计
  109. /// </summary>
  110. /// <param name="self"></param>
  111. /// <param name="msg"></param>
  112. public static void OnBattleReport(this MapEventComponent self, JObject msg)
  113. {
  114. }
  115. }
  116. }