Пример #1
0
        public static void DispatchEvent(GameObject _target, SuperEvent _event)
        {
            dispatchEventIndex++;

            _event.target = _target;

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

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

                    foreach (KeyValuePair <object, Dictionary <MethodInfo, object[]> > pair in tmpDic2)
                    {
                        object obj = pair.Key;

                        foreach (KeyValuePair <MethodInfo, object[]> pair2 in pair.Value)
                        {
                            object[] arr = new object[pair2.Value.Length + 1];

                            arr[0] = _event;

                            Array.Copy(pair2.Value, 0, arr, 1, pair2.Value.Length);


                            pair2.Key.Invoke(obj, arr);
                        }
                    }
                }
            }

            dispatchEventIndex--;

            if (dispatchEventIndex == 0 && delegateList.Count > 0)
            {
                foreach (superFunctionDelegate del in delegateList)
                {
                    del();
                }

                delegateList.Clear();
            }
        }
Пример #2
0
        public void DispatchEvent(GameObject _target, SuperEvent _event)
        {
            dispatchEventIndex++;

//			_event.target = _target;

            if (dic2.ContainsKey(_target))
            {
                Dictionary <string, List <SuperFunctionUnit> > tmpDic = dic2[_target];

                if (tmpDic.ContainsKey(_event.eventName))
                {
                    List <SuperFunctionUnit> tmpList = tmpDic[_event.eventName];

                    foreach (SuperFunctionUnit unit in tmpList)
                    {
//						_event.index = unit.index;

                        SuperEvent tmpEvent = new SuperEvent(_event.eventName);

                        tmpEvent.target = _target;

                        tmpEvent.data = _event.data;

                        tmpEvent.index = unit.index;

                        unit.callBack(tmpEvent);
                    }
                }
            }

            dispatchEventIndex--;

            if (dispatchEventIndex == 0 && delegateList.Count > 0)
            {
                foreach (Action del in delegateList)
                {
                    del();
                }

                delegateList.Clear();
            }
        }
Пример #3
0
        public void DispatchEvent(GameObject _target, SuperEvent _event)
        {
            if (dic2.ContainsKey(_target))
            {
                Dictionary <string, List <SuperFunctionUnit> > tmpDic = dic2[_target];

                if (tmpDic.ContainsKey(_event.eventName))
                {
                    List <SuperFunctionUnit> tmpList = tmpDic[_event.eventName];

                    SuperEvent[] eventList = new SuperEvent[tmpList.Count];

                    SuperFunctionUnit[] unitList = new SuperFunctionUnit[tmpList.Count];

                    for (int i = 0; i < tmpList.Count; i++)
                    {
                        SuperFunctionUnit unit = tmpList[i];

                        SuperEvent tmpEvent = new SuperEvent(_event.eventName);

                        tmpEvent.target = _target;

                        tmpEvent.data = _event.data;

                        tmpEvent.index = unit.index;

                        eventList[i] = tmpEvent;

                        unitList[i] = unit;
                    }

                    for (int i = 0; i < eventList.Length; i++)
                    {
                        unitList[i].callBack(eventList[i]);
                    }
                }
            }
        }