public void AnasysisMsg(MessageBase tempMsg) { ManagerID tempId = tempMsg.GetManager(); switch (tempId) { case ManagerID.GameManager: break; case ManagerID.UIManager: break; case ManagerID.AudioManager: break; case ManagerID.NPCManager: break; case ManagerID.CharactorManager: break; case ManagerID.AssetManager: break; case ManagerID.NetManager: break; default: break; } }
/// <summary> /// 发送消息 /// </summary> /// <param name="message"></param> public void SendMessage(MessageBase message) { ManagerBase manager = managers.Find(m => m.Id == message.GetManager()); if (manager != null) { manager.ProcessEvent(message); } }
public void SendMsg(MessageBase msg) { if (msg.GetManager() == ManagerID.NPCManager)//是本模块的,自己处理 { ProcessEvent(msg); } else//如果不是本模块的,那就交给Msg { MsgCenter.Instance.SendToMsg(msg); } }
public override void ProcessEvent(MessageBase tempMsg) { if (!eventTree.ContainsKey(tempMsg.msgId)) { Debug.LogError("msg not contain msgid == " + tempMsg.msgId); Debug.LogError("msg Manager == " + tempMsg.GetManager()); } else { EventNode temp = eventTree[tempMsg.msgId]; do { temp.data.ProcessEvent(tempMsg); temp = temp.NextNode; } while (temp != null); } }
/// <summary> /// 处理消息 /// </summary> /// <param name="message"></param> public void ProcessEvent(MessageBase message) { if (!nodeList.ContainKey(message.MessageId)) { Debug.LogError("Key not exist! MessageId: " + message.MessageId + ", ManagerId: " + message.GetManager()); } else { Node <IMessageProcess> temp = nodeList[message.MessageId]; while (temp != null) { temp.data.ProcessEvent(message); temp = temp.next; } } }