internal void DispatchEvent(string _eventName, params object[] _objs)
        {
            if (dicWithEvent.ContainsKey(_eventName))
            {
                Dictionary <Action <SuperEvent>, SuperEventListenerUnit> dic = dicWithEvent[_eventName];

                KeyValuePair <Action <SuperEvent>, SuperEvent>[] arr = new KeyValuePair <Action <SuperEvent>, SuperEvent> [dic.Count];

                Dictionary <Action <SuperEvent>, SuperEventListenerUnit> .Enumerator enumerator = dic.GetEnumerator();

                int i = 0;

                while (enumerator.MoveNext())
                {
                    KeyValuePair <Action <SuperEvent>, SuperEventListenerUnit> pair = enumerator.Current;

                    SuperEvent ev = new SuperEvent(pair.Value.index, _objs);

                    arr[i] = new KeyValuePair <Action <SuperEvent>, SuperEvent>(pair.Key, ev);

                    i++;
                }

                for (i = 0; i < arr.Length; i++)
                {
                    KeyValuePair <Action <SuperEvent>, SuperEvent> pair = arr[i];

                    pair.Key(pair.Value);
                }
            }
        }
Beispiel #2
0
        internal void DispatchEvent <T>(string _eventName, ref T _value, params object[] _objs) where T : struct
        {
            if (dicWithEvent.ContainsKey(_eventName))
            {
                Dictionary <Delegate, SuperEventListenerUnitBase> dic = dicWithEvent[_eventName];

                KeyValuePair <Delegate, SuperEvent>[] arr = new KeyValuePair <Delegate, SuperEvent> [dic.Count];

                Dictionary <Delegate, SuperEventListenerUnitBase> .Enumerator enumerator = dic.GetEnumerator();

                int i = 0;

                while (enumerator.MoveNext())
                {
                    KeyValuePair <Delegate, SuperEventListenerUnitBase> pair = enumerator.Current;

                    SuperEvent ev = new SuperEvent(pair.Value.index, _objs);

                    arr[i] = new KeyValuePair <Delegate, SuperEvent>(pair.Key, ev);

                    i++;
                }

                for (i = 0; i < arr.Length; i++)
                {
                    KeyValuePair <Delegate, SuperEvent> pair = arr[i];

                    if (pair.Key is EventCallBack <T> )
                    {
                        EventCallBack <T> callBack = pair.Key as EventCallBack <T>;

                        callBack(pair.Value, ref _value);
                    }
                }
            }
        }