R2NotifyMessageDefined.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections.Generic;
  3. using CommonAI.Zone.Instance;
  4. using XmdsCommon.Plugin;
  5. using CommonAI.Zone;
  6. using CommonLang.Log;
  7. using CommonLang;
  8. using CommonLang.Property;
  9. using XmdsCommon.Message;
  10. using XmdsCommonZone.Zones;
  11. namespace XmdsServerNode.Node.R2bNotify
  12. {
  13. public class R2bNotifyManager
  14. {
  15. private static Logger log = LoggerFactory.GetLogger("R2bNotifyManager");
  16. private static HashMap<string, Type> mMessageTypeMap = new HashMap<string, Type>();
  17. private static void LoadR2BNotifyMessage()
  18. {
  19. try
  20. {
  21. Type base_type = typeof(R2BNotifyMessage);
  22. foreach (Type sub_type in ReflectionUtil.GetNoneVirtualSubTypes(base_type))
  23. {
  24. if (sub_type.IsSubclassOf(base_type))
  25. {
  26. mMessageTypeMap.Add(sub_type.Name, sub_type);
  27. }
  28. }
  29. }
  30. catch (Exception err)
  31. {
  32. log.Error("LoadS2bNotifyMessage : " + err.ToString());
  33. throw;
  34. }
  35. }
  36. static R2bNotifyManager()
  37. {
  38. }
  39. public static void Init()
  40. {
  41. LoadR2BNotifyMessage();
  42. }
  43. public static R2BNotifyMessage GetR2bNotifyMessage(string eventName)
  44. {
  45. Type stype;
  46. if (mMessageTypeMap.TryGetValue(eventName, out stype))
  47. {
  48. R2BNotifyMessage ret = ReflectionUtil.CreateInstance(stype) as R2BNotifyMessage;
  49. return ret;
  50. }
  51. else
  52. {
  53. return null;
  54. }
  55. }
  56. }
  57. public abstract class R2BNotifyMessage
  58. {
  59. public string MessageName
  60. {
  61. get
  62. {
  63. return GetType().Name;
  64. }
  65. }
  66. public virtual void OnHandle(InstanceZone zone) { }
  67. }
  68. public delegate void OnGameServerMessageHandler(InstanceZone zone, R2BNotifyMessage act);
  69. public class QuestAcceptedR2B : R2BNotifyMessage
  70. {
  71. public string playerUUID;
  72. public string questID;
  73. public override void OnHandle(InstanceZone zone)
  74. {
  75. zone.QuestAdapter.OnQuestAcceptedHandler(playerUUID, questID);
  76. }
  77. }
  78. public class QuestCommittedR2B : R2BNotifyMessage
  79. {
  80. public string playerUUID;
  81. public string questID;
  82. public override void OnHandle(InstanceZone zone)
  83. {
  84. zone.QuestAdapter.OnQuestCommittedHandler(playerUUID, questID);
  85. }
  86. }
  87. public class QuestDroppedR2B : R2BNotifyMessage
  88. {
  89. public string playerUUID;
  90. public string questID;
  91. public override void OnHandle(InstanceZone zone)
  92. {
  93. zone.QuestAdapter.OnQuestDroppedHandler(playerUUID, questID);
  94. }
  95. }
  96. public class QuestStatusChangedR2B : R2BNotifyMessage
  97. {
  98. public string playerUUID;
  99. public string questID;
  100. public bool initStatus;
  101. public struct KeyValue
  102. {
  103. public string key;
  104. public string value;
  105. }
  106. public List<KeyValue> status;
  107. public override void OnHandle(InstanceZone zone)
  108. {
  109. //QuestAcceptedR2B合并到initStatus为true的QuestStatusChangedR2B消息中
  110. if (initStatus)
  111. {
  112. zone.QuestAdapter.OnQuestAcceptedHandler(playerUUID, questID);
  113. }
  114. if (status != null)
  115. {
  116. foreach (var item in status)
  117. {
  118. zone.QuestAdapter.OnQuestStatusChangedHandler(playerUUID, questID, item.key, item.value);
  119. }
  120. }
  121. if (initStatus)
  122. {
  123. // INIT_OK 表示已全部加载完毕
  124. zone.QuestAdapter.OnQuestStatusChangedHandler(playerUUID, questID, XmdsQuestData.Attribute_InitOK, "1");
  125. }
  126. }
  127. }
  128. public class LaunchPlayerEffectR2B : R2BNotifyMessage
  129. {
  130. public string playerUUID;
  131. public string Name;
  132. public bool BindBody;
  133. public string BindPartName;
  134. public float ScaleToBodySize;
  135. public string SoundName;
  136. public int EarthQuakeMS;
  137. public float EarthQuakeXYZ;
  138. public string CameraAnimation;
  139. public int EffectTimeMS = 0;
  140. public LaunchEffect launchEffect;
  141. public override void OnHandle(InstanceZone zone)
  142. {
  143. zone.queueTask((InstanceZone z) =>
  144. {
  145. DynamicUnitEffectB2C e = new DynamicUnitEffectB2C();
  146. e.Name = Name;
  147. e.BindBody = BindBody;
  148. e.BindPartName = BindPartName;
  149. e.ScaleToBodySize = ScaleToBodySize;
  150. e.SoundName = SoundName;
  151. e.EarthQuakeMS = EarthQuakeMS;
  152. e.EarthQuakeXYZ = EarthQuakeXYZ;
  153. e.CameraAnimation = CameraAnimation;
  154. e.EffectTimeMS = EffectTimeMS;
  155. InstancePlayer p = z.getPlayerByUUID(playerUUID);
  156. if (p != null)
  157. {
  158. p.queueEvent(e);
  159. }
  160. });
  161. }
  162. }
  163. public class TreasureActivityInfoR2B : R2BNotifyMessage
  164. {
  165. public int[] timeOpenCloseList;
  166. public int[] monsterIdProbabilityList;
  167. public int createBossIntervalMS;
  168. public int maxMonsterCount;
  169. public override void OnHandle(InstanceZone zone)
  170. {
  171. zone.queueTask((InstanceZone z) =>
  172. {
  173. try
  174. {
  175. //TreasureActivityInfoR2B e = new TreasureActivityInfoR2B();
  176. //e.timeOpenCloseList = timeOpenCloseList;
  177. //e.monsterIdProbabilityList = monsterIdProbabilityList;
  178. //e.createBossIntervalMS = createBossIntervalMS;
  179. //e.maxMonsterCount = maxMonsterCount;
  180. ZoneIntervalRebirthMonster zz = z as ZoneIntervalRebirthMonster;
  181. zz.InitSceneDataFromGameServer(timeOpenCloseList, monsterIdProbabilityList, createBossIntervalMS, maxMonsterCount);
  182. }
  183. catch (Exception error)
  184. {
  185. throw new Exception("TreasureActivityInfoR2B Error" + error.ToString());
  186. }
  187. });
  188. }
  189. }
  190. //场景通知事件
  191. public class ZoneFlagNotifyR2B : R2BNotifyMessage
  192. {
  193. public int value1;
  194. public override void OnHandle(InstanceZone zone)
  195. {
  196. zone.GSZoneFlagNotifyMsg(value1);
  197. }
  198. }
  199. }