Esempio n. 1
0
        public bool DispatchEvent <T1, T2>(GameObject _target, string _eventName, T1 t1, T2 t2)
        {
            List <SuperFunctionUnit> unitList = DispatchEventReal <SuperFunctionCallBack2 <T1, T2> >(_target, _eventName);

            if (unitList != null)
            {
                for (int i = 0; i < unitList.Count; i++)
                {
                    SuperFunctionUnit unit = unitList[i];

                    if (unit.isOnce)
                    {
                        RemoveEventListener(unit.index);
                    }

                    SuperFunctionCallBack2 <T1, T2> cb = unit.callBack as SuperFunctionCallBack2 <T1, T2>;

                    cb(unit.index, t1, t2);
                }

                unitList.Clear();

                ReleaseList(unitList);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        internal bool DispatchEvent <T1, T2>(string _eventName, T1 t1, T2 t2)
        {
            LinkedList <SuperEventListenerUnit> linkedList = DispatchEventReal <SuperFunctionCallBack2 <T1, T2> >(_eventName);

            if (linkedList != null)
            {
                while (linkedList.First != null)
                {
                    LinkedListNode <SuperEventListenerUnit> node = linkedList.First;

                    SuperEventListenerUnit unit = node.Value;

                    SuperFunctionCallBack2 <T1, T2> cb = unit.callBack as SuperFunctionCallBack2 <T1, T2>;

                    cb(unit.index, t1, t2);

                    ReleaseLinkedListNode(node);

                    linkedList.RemoveFirst();
                }

                ReleaseLinkedList(linkedList);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public void DispatchEvent <T1, T2>(GameObject _target, string _eventName, T1 t1, T2 t2)
        {
            if (dic2.ContainsKey(_target))
            {
                Dictionary <string, List <SuperFunctionUnit> > tmpDic = dic2[_target];

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

                    LinkedList <SuperFunctionUnit> unitList = null;

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

                        if (unit.callBack is SuperFunctionCallBack2 <T1, T2> )
                        {
                            if (unitList == null)
                            {
                                unitList = new LinkedList <SuperFunctionUnit>();
                            }

                            unitList.AddLast(unit);
                        }
                    }

                    if (unitList != null)
                    {
                        LinkedList <SuperFunctionUnit> .Enumerator enumerator = unitList.GetEnumerator();

                        while (enumerator.MoveNext())
                        {
                            if (enumerator.Current.isOnce)
                            {
                                RemoveEventListener(enumerator.Current.index);
                            }

                            SuperFunctionCallBack2 <T1, T2> cb = enumerator.Current.callBack as SuperFunctionCallBack2 <T1, T2>;

                            cb(enumerator.Current.index, t1, t2);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 public int AddEventListener <T1, T2>(GameObject _target, string _eventName, SuperFunctionCallBack2 <T1, T2> _callBack)
 {
     return(AddEventListener(_target, _eventName, _callBack, false));
 }
Esempio n. 5
0
 public void RemoveEventListener <T1, T2>(GameObject _target, string _eventName, SuperFunctionCallBack2 <T1, T2> _callBack)
 {
     RemoveEventListenerReal(_target, _eventName, _callBack);
 }
Esempio n. 6
0
 internal int AddListener <T1, T2>(string _eventName, SuperFunctionCallBack2 <T1, T2> _callBack, int _priority)
 {
     return(AddListenerReal(_eventName, _callBack, _priority));
 }
Esempio n. 7
0
 internal void RemoveListener <T1, T2>(string _eventName, SuperFunctionCallBack2 <T1, T2> _callBack)
 {
     RemoveListenerReal(_eventName, _callBack);
 }