Beispiel #1
0
        public static void RemoveEventListener(GameObject _target, string _eventName)
        {
            if (dispatchEventIndex > 0)
            {
                superFunctionDelegate del = delegate() {
                    RemoveEventListener(_target, _eventName);
                };

                delegateList.Add(del);

                return;
            }

            if (dic.ContainsKey(_target))
            {
                Dictionary <string, Dictionary <object, Dictionary <MethodInfo, object[]> > > tmpDic = dic[_target];

                if (tmpDic.ContainsKey(_eventName))
                {
                    tmpDic.Remove(_eventName);

                    if (tmpDic.Count == 0)
                    {
                        dic.Remove(_target);
                    }
                }
            }
        }
Beispiel #2
0
        public static void RemoveEventListener(GameObject _target, string _eventName, object _callBackObj, string _callBackName)
        {
            if (dispatchEventIndex > 0)
            {
                superFunctionDelegate del = delegate() {
                    RemoveEventListener(_target, _eventName, _callBackObj, _callBackName);
                };

                delegateList.Add(del);

                return;
            }

            MethodInfo method = _callBackObj.GetType().GetMethod(_callBackName);

            if (dic.ContainsKey(_target))
            {
                Dictionary <string, Dictionary <object, Dictionary <MethodInfo, object[]> > > tmpDic = dic[_target];

                if (tmpDic.ContainsKey(_eventName))
                {
                    Dictionary <object, Dictionary <MethodInfo, object[]> > tmpDic2 = tmpDic[_eventName];

                    if (tmpDic2.ContainsKey(_callBackObj))
                    {
                        Dictionary <MethodInfo, object[]> tmpDic3 = tmpDic2[_callBackObj];

                        if (tmpDic3.ContainsKey(method))
                        {
                            tmpDic3.Remove(method);

                            if (tmpDic3.Count == 0)
                            {
                                tmpDic2.Remove(_callBackObj);

                                if (tmpDic2.Count == 0)
                                {
                                    tmpDic.Remove(_eventName);

                                    if (tmpDic.Count == 0)
                                    {
                                        dic.Remove(_target);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public static void RemoveEventListener(GameObject _target)
        {
            if (dispatchEventIndex > 0)
            {
                superFunctionDelegate del = delegate() {
                    RemoveEventListener(_target);
                };

                delegateList.Add(del);

                return;
            }

            if (dic.ContainsKey(_target))
            {
                dic.Remove(_target);
            }
        }
Beispiel #4
0
        public static void AddEventListener(GameObject _target, string _event, object _callBackObj, string _callBackName, params object[] _args)
        {
            if (dispatchEventIndex > 0)
            {
                superFunctionDelegate del = delegate() {
                    AddEventListener(_target, _event, _callBackObj, _callBackName, _args);
                };

                delegateList.Add(del);

                return;
            }

            MethodInfo method = _callBackObj.GetType().GetMethod(_callBackName);

            if (!dic.ContainsKey(_target))
            {
                Dictionary <string, Dictionary <object, Dictionary <MethodInfo, object[]> > > tmpDic = new Dictionary <string, Dictionary <object, Dictionary <MethodInfo, object[]> > >();

                Dictionary <object, Dictionary <MethodInfo, object[]> > tmpDic2 = new Dictionary <object, Dictionary <MethodInfo, object[]> > ();

                Dictionary <MethodInfo, object[]> tmpDic3 = new Dictionary <MethodInfo, object[]>();

                tmpDic3.Add(method, _args);

                tmpDic2.Add(_callBackObj, tmpDic3);

                tmpDic.Add(_event, tmpDic2);

                dic.Add(_target, tmpDic);
            }
            else
            {
                Dictionary <string, Dictionary <object, Dictionary <MethodInfo, object[]> > > tmpDic = dic[_target];

                if (!tmpDic.ContainsKey(_event))
                {
                    Dictionary <object, Dictionary <MethodInfo, object[]> > tmpDic2 = new Dictionary <object, Dictionary <MethodInfo, object[]> >();

                    Dictionary <MethodInfo, object[]> tmpDic3 = new Dictionary <MethodInfo, object[]>();

                    tmpDic3.Add(method, _args);

                    tmpDic2.Add(_callBackObj, tmpDic3);

                    tmpDic.Add(_event, tmpDic2);
                }
                else
                {
                    Dictionary <object, Dictionary <MethodInfo, object[]> > tmpDic2 = tmpDic[_event];

                    if (!tmpDic2.ContainsKey(_callBackObj))
                    {
                        Dictionary <MethodInfo, object[]> tmpDic3 = new Dictionary <MethodInfo, object[]>();

                        tmpDic3.Add(method, _args);

                        tmpDic2.Add(_callBackObj, tmpDic3);
                    }
                    else
                    {
                        Dictionary <MethodInfo, object[]> tmpDic3 = tmpDic2[_callBackObj];

                        if (!tmpDic3.ContainsKey(method))
                        {
                            tmpDic3.Add(method, _args);
                        }
                    }
                }
            }
        }