123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- using System;
- using System.Collections.Generic;
- using CommonAI.Zone.Instance;
- using XmdsCommon.Plugin;
- using CommonAI.Zone;
- using CommonLang.Log;
- using CommonLang;
- using CommonLang.Property;
- using XmdsCommon.Message;
- using XmdsCommonZone.Zones;
- namespace XmdsServerNode.Node.R2bNotify
- {
- public class R2bNotifyManager
- {
- private static Logger log = LoggerFactory.GetLogger("R2bNotifyManager");
- private static HashMap<string, Type> mMessageTypeMap = new HashMap<string, Type>();
- private static void LoadR2BNotifyMessage()
- {
- try
- {
- Type base_type = typeof(R2BNotifyMessage);
- foreach (Type sub_type in ReflectionUtil.GetNoneVirtualSubTypes(base_type))
- {
- if (sub_type.IsSubclassOf(base_type))
- {
- mMessageTypeMap.Add(sub_type.Name, sub_type);
- }
- }
- }
- catch (Exception err)
- {
- log.Error("LoadS2bNotifyMessage : " + err.ToString());
- throw;
- }
- }
- static R2bNotifyManager()
- {
-
- }
- public static void Init()
- {
- LoadR2BNotifyMessage();
- }
- public static R2BNotifyMessage GetR2bNotifyMessage(string eventName)
- {
- Type stype;
- if (mMessageTypeMap.TryGetValue(eventName, out stype))
- {
- R2BNotifyMessage ret = ReflectionUtil.CreateInstance(stype) as R2BNotifyMessage;
- return ret;
- }
- else
- {
- return null;
- }
- }
- }
- public abstract class R2BNotifyMessage
- {
- public string MessageName
- {
- get
- {
- return GetType().Name;
- }
- }
- public virtual void OnHandle(InstanceZone zone) { }
- }
- public delegate void OnGameServerMessageHandler(InstanceZone zone, R2BNotifyMessage act);
- public class QuestAcceptedR2B : R2BNotifyMessage
- {
- public string playerUUID;
- public string questID;
- public override void OnHandle(InstanceZone zone)
- {
- zone.QuestAdapter.OnQuestAcceptedHandler(playerUUID, questID);
- }
- }
- public class QuestCommittedR2B : R2BNotifyMessage
- {
- public string playerUUID;
- public string questID;
- public override void OnHandle(InstanceZone zone)
- {
- zone.QuestAdapter.OnQuestCommittedHandler(playerUUID, questID);
- }
- }
- public class QuestDroppedR2B : R2BNotifyMessage
- {
- public string playerUUID;
- public string questID;
- public override void OnHandle(InstanceZone zone)
- {
- zone.QuestAdapter.OnQuestDroppedHandler(playerUUID, questID);
- }
- }
- public class QuestStatusChangedR2B : R2BNotifyMessage
- {
- public string playerUUID;
- public string questID;
- public bool initStatus;
- public struct KeyValue
- {
- public string key;
- public string value;
- }
- public List<KeyValue> status;
- public override void OnHandle(InstanceZone zone)
- {
- //QuestAcceptedR2B合并到initStatus为true的QuestStatusChangedR2B消息中
- if (initStatus)
- {
- zone.QuestAdapter.OnQuestAcceptedHandler(playerUUID, questID);
- }
- if (status != null)
- {
- foreach (var item in status)
- {
- zone.QuestAdapter.OnQuestStatusChangedHandler(playerUUID, questID, item.key, item.value);
- }
- }
- if (initStatus)
- {
- // INIT_OK 表示已全部加载完毕
- zone.QuestAdapter.OnQuestStatusChangedHandler(playerUUID, questID, XmdsQuestData.Attribute_InitOK, "1");
- }
- }
- }
- public class LaunchPlayerEffectR2B : R2BNotifyMessage
- {
- public string playerUUID;
- public string Name;
- public bool BindBody;
- public string BindPartName;
- public float ScaleToBodySize;
- public string SoundName;
- public int EarthQuakeMS;
- public float EarthQuakeXYZ;
- public string CameraAnimation;
- public int EffectTimeMS = 0;
- public LaunchEffect launchEffect;
- public override void OnHandle(InstanceZone zone)
- {
- zone.queueTask((InstanceZone z) =>
- {
- DynamicUnitEffectB2C e = new DynamicUnitEffectB2C();
- e.Name = Name;
- e.BindBody = BindBody;
- e.BindPartName = BindPartName;
- e.ScaleToBodySize = ScaleToBodySize;
- e.SoundName = SoundName;
- e.EarthQuakeMS = EarthQuakeMS;
- e.EarthQuakeXYZ = EarthQuakeXYZ;
- e.CameraAnimation = CameraAnimation;
- e.EffectTimeMS = EffectTimeMS;
- InstancePlayer p = z.getPlayerByUUID(playerUUID);
- if (p != null)
- {
- p.queueEvent(e);
- }
- });
- }
- }
- public class TreasureActivityInfoR2B : R2BNotifyMessage
- {
- public int[] timeOpenCloseList;
- public int[] monsterIdProbabilityList;
- public int createBossIntervalMS;
- public int maxMonsterCount;
- public override void OnHandle(InstanceZone zone)
- {
- zone.queueTask((InstanceZone z) =>
- {
- try
- {
- //TreasureActivityInfoR2B e = new TreasureActivityInfoR2B();
- //e.timeOpenCloseList = timeOpenCloseList;
- //e.monsterIdProbabilityList = monsterIdProbabilityList;
- //e.createBossIntervalMS = createBossIntervalMS;
- //e.maxMonsterCount = maxMonsterCount;
- ZoneIntervalRebirthMonster zz = z as ZoneIntervalRebirthMonster;
- zz.InitSceneDataFromGameServer(timeOpenCloseList, monsterIdProbabilityList, createBossIntervalMS, maxMonsterCount);
- }
- catch (Exception error)
- {
- throw new Exception("TreasureActivityInfoR2B Error" + error.ToString());
- }
- });
- }
- }
- //场景通知事件
- public class ZoneFlagNotifyR2B : R2BNotifyMessage
- {
- public int value1;
- public override void OnHandle(InstanceZone zone)
- {
- zone.GSZoneFlagNotifyMsg(value1);
- }
- }
- }
|