Ejemplo n.º 1
0
    public void RegBroadcastEvent(int eventID, int targetObjID, IBroadcastEventListener eventObj)
    {
        int mapID = GetMapIDByMsgIDAndTargetID(eventID, targetObjID);
        List <IBroadcastEventListener> msgList = null;

        if (mListenerDict.TryGetValue(mapID, out msgList))
        {
            msgList.Add(eventObj);
        }
        else
        {
            msgList = new List <IBroadcastEventListener>();
            msgList.Add(eventObj);
            mListenerDict[mapID] = msgList;
        }
    }
Ejemplo n.º 2
0
    public void UnRegBrodcastEvent(int eventID, int targetObjID, IBroadcastEventListener eventObj)
    {
        int mapID = GetMapIDByMsgIDAndTargetID(eventID, targetObjID);
        List <IBroadcastEventListener> msgList = null;

        if (mListenerDict.TryGetValue(mapID, out msgList))
        {
            for (int i = 0; i < msgList.Count; i++)
            {
                if (msgList[i] == eventObj)
                {
                    msgList.Remove(eventObj);
                    if (msgList.Count == 0)
                    {
                        mListenerDict.Remove(mapID);
                    }
                    return;
                }
            }
        }
    }