Example #1
0
    public static void AddListener(RedpointType type, string nodeName, OnRedpointBroadcast callback)
    {
        var          nodeList = nodeName.Split('.');
        RedpointNode node;

        if (s_instance._rootNodeDic.TryGetValue(type, out node))
        {
            if (nodeList.Length == 1 && node.nodeName == nodeList[0])
            {
                node.numChangeFunc = callback;
                return;
            }
            else if (nodeList[0] != node.nodeName)
            {
                throw new Exception(string.Format("RedpointType和NodeName不对应,RedpointType:{0},NodeName:{1}", type, nodeName));
            }

            for (int i = 1; i < nodeList.Length; i++)
            {
                var subNodeName = nodeList[i];
                if (!node.dicChilds.ContainsKey(subNodeName))
                {
                    Debug.Log("Does Not Contains Child Node :" + nodeList[i]);
                    return;
                }
                node = node.dicChilds[subNodeName];
                if (i == nodeList.Length - 1)
                {
                    node.numChangeFunc = callback;
                }
            }
        }
    }
Example #2
0
    public static void SetRpNum(RedpointType type, string nodeName, int rpNum)
    {
        var nodeList = nodeName.Split('.');

        RedpointNode node;

        if (s_instance._rootNodeDic.TryGetValue(type, out node))
        {
            if (nodeList[0] != node.nodeName)
            {
                throw new Exception(string.Format("RedpointType和NodeName不对应,RedpointType:{0},NodeName:{1}", type, node.nodeName));
            }

            for (int i = 1; i < nodeList.Length; i++)
            {
                var subNodeName = nodeList[i];
                if (!node.dicChilds.ContainsKey(subNodeName))
                {
                    Debug.Log("Does Not Contains Child Node :" + nodeList[i]);
                    return;
                }
                node = node.dicChilds[subNodeName];
                if (i == nodeList.Length - 1)
                {
                    node.SetRedpointNum(rpNum);
                }
            }
        }
    }