void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
 {
     if (onHovered.GetInvocationList().Length > 0)
     {
         onHovered.Invoke();
     }
 }
Exemple #2
0
 protected virtual void CallSingleShotEventHandlers <T>(string p_eventName, T p_args, ref System.Action <T> p_event)
 {
     if (p_event != null && m_singleShotEventHandlers.ContainsKey(p_eventName))
     {
         int singleShotCount        = m_singleShotEventHandlers[p_eventName].Count;
         System.Delegate[] handlers = p_event.GetInvocationList();
         foreach (System.Delegate handler in handlers)
         {
             if (m_singleShotEventHandlers[p_eventName].Contains(handler.Target))
             {
                 p_event -= (System.Action <T>)handler;
                 m_singleShotEventHandlers[p_eventName].Remove(handler.Target);
                 try
                 {
                     handler.DynamicInvoke(p_args);
                 }
                 catch (System.Exception ex)
                 {
                     Debug.LogError(typeof(SteamMainT).Name + ": your event handler ('" + handler.Target + "' - System.Action<" + typeof(T) + ">) has thrown an excepotion!\n" + ex);
                 }
             }
         }
         if (IsDebugLogEnabled)
         {
             Debug.Log(typeof(SteamMainT).Name + ": CallSingleShotEventHandlers '" + p_eventName + "' left handlers: " + (p_event != null ? p_event.GetInvocationList().Length : 0) + "/" + handlers.Length + " left single shots: " + m_singleShotEventHandlers[p_eventName].Count + "/" + singleShotCount);
         }
     }
 }
 public static void ClearUI()
 {
     foreach (System.Action item in UI.GetInvocationList())
     {
         UI -= item;
     }
 }
 public void ClearListeners()
 {
     try {
         foreach (System.Delegate d in AchievementUnlocked.GetInvocationList())
         {
             AchievementUnlocked -= (System.Action <int>)d;
         }
     }
     catch {
         // Nothing to do
     }
 }
Exemple #5
0
 public void ClearListeners()
 {
     try {
         foreach (System.Delegate d in NewEvent.GetInvocationList())
         {
             NewEvent -= (System.Action <EventManager.GameEvent>)d;
         }
     }
     catch {
         // Nothing to do
     }
 }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     System.Action action = Test1;
     print(action.Method.Name);
     action += Test2;
     print(action.Method.Name);
     action();
     foreach (var d in action.GetInvocationList())
     {
         print(d.Method.Name);
     }
 }
Exemple #7
0
 public void ClearListeners()
 {
     try {
         foreach (System.Delegate d in CitizenArrival.GetInvocationList())
         {
             CitizenArrival -= (System.Action <int, Population>)d;
         }
     }
     catch {
         // Nothing to do
     }
 }
 /// <summary>
 /// 移除Complete事件所有注册方法
 /// </summary>
 public void RemoveAllCompleteEvts()
 {
     if (Complete != null)
     {
         System.Delegate[] complevts = Complete.GetInvocationList();
         for (int i = 0; i < complevts.Length; i++)
         {
             System.Action delegateComplevt = complevts[i] as System.Action;
             Complete -= delegateComplevt;
         }
     }
 }
Exemple #9
0
        public static void RemoveAllListeners <T>(this System.Action <T> action)
        {
            if (action == null)
            {
                return;
            }

            foreach (System.Delegate del in action.GetInvocationList())
            {
                action -= (System.Action <T>)del;
            }
        }
Exemple #10
0
 System.Action ClearDelegate(System.Action delegateHandler)
 {
     if (delegateHandler == null)
     {
         return(delegate {
         });
     }
     System.Delegate[] list = delegateHandler.GetInvocationList();
     foreach (System.Delegate del in list)
     {
         delegateHandler -= (System.Action)del;
     }
     return(delegateHandler);
 }
    static int set_completed(IntPtr L)
    {
        try
        {
            UnityEngine.AsyncOperation obj = (UnityEngine.AsyncOperation)ToLua.CheckObject(L, 1, typeof(UnityEngine.AsyncOperation));
            EventObject arg0 = null;

            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                arg0 = (EventObject)ToLua.ToObject(L, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "The event 'UnityEngine.AsyncOperation.completed' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.AsyncOperation'"));
            }

            if (arg0.op == EventOp.Add)
            {
                System.Action <UnityEngine.AsyncOperation> ev = (System.Action <UnityEngine.AsyncOperation>)DelegateFactory.CreateDelegate(typeof(System.Action <UnityEngine.AsyncOperation>), arg0.func);
                obj.completed += ev;
            }
            else if (arg0.op == EventOp.Sub)
            {
                System.Action <UnityEngine.AsyncOperation> ev = (System.Action <UnityEngine.AsyncOperation>)LuaMisc.GetEventHandler(obj, typeof(UnityEngine.AsyncOperation), "completed");
                Delegate[] ds    = ev.GetInvocationList();
                LuaState   state = LuaState.Get(L);

                for (int i = 0; i < ds.Length; i++)
                {
                    ev = (System.Action <UnityEngine.AsyncOperation>)ds[i];
                    LuaDelegate ld = ev.Target as LuaDelegate;

                    if (ld != null && ld.func == arg0.func)
                    {
                        obj.completed -= ev;
                        state.DelayDispose(ld.func);
                        break;
                    }
                }

                arg0.func.Dispose();
            }

            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int set_OnJoystick(IntPtr L)
    {
        try
        {
            EventObject arg0 = null;

            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                arg0 = (EventObject)ToLua.ToObject(L, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "The event 'JoystickLogic.OnJoystick' can only appear on the left hand side of += or -= when used outside of the type 'JoystickLogic'"));
            }

            if (arg0.op == EventOp.Add)
            {
                System.Action <UnityEngine.Vector2> ev = (System.Action <UnityEngine.Vector2>)DelegateFactory.CreateDelegate(typeof(System.Action <UnityEngine.Vector2>), arg0.func);
                JoystickLogic.OnJoystick += ev;
            }
            else if (arg0.op == EventOp.Sub)
            {
                System.Action <UnityEngine.Vector2> ev = (System.Action <UnityEngine.Vector2>)LuaMisc.GetEventHandler(null, typeof(JoystickLogic), "OnJoystick");
                Delegate[] ds    = ev.GetInvocationList();
                LuaState   state = LuaState.Get(L);

                for (int i = 0; i < ds.Length; i++)
                {
                    ev = (System.Action <UnityEngine.Vector2>)ds[i];
                    LuaDelegate ld = ev.Target as LuaDelegate;

                    if (ld != null && ld.func == arg0.func)
                    {
                        JoystickLogic.OnJoystick -= ev;
                        state.DelayDispose(ld.func);
                        break;
                    }
                }

                arg0.func.Dispose();
            }

            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemple #13
0
    private void OnCollisionEnter(Collision collision)
    {
        if (onHit == null)
        {
            return;
        }

        if ((IsGrounded() || collision.collider.name == "Ground") && onHit.GetInvocationList().Length > 0)
        {
            if (activated)
            {
                onHit.Invoke(collision);
            }
        }
    }
Exemple #14
0
    private void OnEnable()
    {
        _shooting = false;

        DelegateUtils.ClearDelegate(OnBulletDestroy);

        // Clear all delegates in OnBulletDestroy
        if (OnBulletDestroy != null)
        {
            var del = OnBulletDestroy.GetInvocationList();

            for (int i = 0; i < del.Length; i++)
            {
                OnBulletDestroy -= del[i] as System.Action <JIBulletController>;
            }
        }
    }
Exemple #15
0
        public void GetEvents(out List <string> listStrActions, out List <string> listStrListener)
        {
            listStrActions = new List <string>();
            if (_eventScriptListeners != null)
            {
                var data = _eventScriptListeners.GetInvocationList();
                for (var i = 0; i < data.Length; i++)
                {
                    listStrActions.Add("T:" + data[i].Target + "|M:" + data[i].Method.Name);
                }
            }
            listStrListener = new List <string>();

            for (var i = 0; i < _eventListeners.Count; i++)
            {
                listStrListener.Add("T:" + _eventListeners[i].name);
            }
        }
    IEnumerator DoSwapGUI(System.Action nextScreen)
    {
        //turn off user control:
        UserControl(false);

        //remove previous screen (if we have any):
        if (MainGUI != null)
        {
            //fade out:
            while (guiAlpha > 0)
            {
                guiAlpha -= fadeSpeed * Time.deltaTime;
                yield return(null);
            }

            //clamp alpha:
            guiAlpha = 0;

            //clear the gui's invocation list:
            System.Delegate[] invocationList = MainGUI.GetInvocationList();
            foreach (System.Delegate item in invocationList)
            {
                MainGUI -= (System.Action)item;
            }
        }

        //add new screen:
        MainGUI += nextScreen;

        //fade in:
        while (guiAlpha < 1)
        {
            guiAlpha += fadeSpeed * Time.deltaTime;
            yield return(null);
        }

        //clamp alpha:
        guiAlpha = 1;

        //return user control:
        UserControl(true);
    }
Exemple #17
0
 protected virtual void ClearSingleShotEventHandlers <T>(string p_eventName, ref System.Action <T> p_event)
 {
     if (p_event != null && m_singleShotEventHandlers.ContainsKey(p_eventName))
     {
         int singleShotCount        = m_singleShotEventHandlers[p_eventName].Count;
         System.Delegate[] handlers = p_event.GetInvocationList();
         foreach (System.Delegate handler in handlers)
         {
             if (m_singleShotEventHandlers[p_eventName].Contains(handler.Target))
             {
                 p_event -= (System.Action <T>)handler;
                 m_singleShotEventHandlers[p_eventName].Remove(handler.Target);
             }
         }
         if (IsDebugLogEnabled)
         {
             Debug.Log(typeof(SteamMainT).Name + ": ClearSingleShotEventHandler '" + p_eventName + "' left handlers: " + (p_event != null ? p_event.GetInvocationList().Length : 0) + "/" + handlers.Length + " left single shots: " + m_singleShotEventHandlers[p_eventName].Count + "/" + singleShotCount);
         }
     }
 }
Exemple #18
0
    public LevelMaster()
    {
        SoundPlayer.StopEverySound();
        SoundPlayer.Play("amb_suburbs_cars", 0.8f);
        SoundPlayer.Play("mus_funkstyle_04", 0.1f);

        foreach (var prop in Object.FindObjectsOfType <Grabbable>())
        {
            maximumScore += prop.racoonValue;
            prop.GetProp().onHit += (x) => {
                SoundPlayer.PlayWithRandomPitch("fb_raccoon_bumping", 0.1f);
                GameObject.Instantiate(Library.instance.hitFX, x.GetContact(0).point, Library.instance.hitFX.transform.rotation);
                try {
                    if (soundAt.GetInvocationList().Length > 0)
                    {
                        soundAt.Invoke(x.GetContact(0).point);
                    }
                }
                catch { }
            };
        }
    }
    IEnumerator OnTransition(Transition transition)
    {
        yield return(new WaitForEndOfFrame());

        if (transition != null)
        {
            List <float> tempValue = new List <float>();
            for (int i = 0; i < transition.ValueField.Count; i++)
            {
                var value = transition.ValueField[i];
                Stage.SetFloat(value.fieldName, value.StartValue);
                tempValue.Add(0f);
            }

            for (int i = 0; i < transition.TextureField.Count; i++)
            {
                Stage.SetTexture(transition.TextureField[i].fieldName, transition.TextureField[i].EndValue);
            }

            if (OnTransitionStart.GetInvocationList().Length > 0)
            {
                OnTransitionStart(Stage);
            }

            while (true)
            {
                yield return(new WaitForEndOfFrame());

                count += Time.deltaTime;
                if (count > transition.duration)
                {
                    break;
                }

                for (int i = 0; i < transition.ValueField.Count; i++)
                {
                    Transition.ShaderParams <float> value = transition.ValueField[i];
                    tempValue[i] += value.Step * Time.deltaTime;
                    Stage.SetFloat(value.fieldName, tempValue[i]);
                    Debug.Log(value.fieldName);
                    Debug.Log(tempValue[i]);
                }
            }

            for (int i = 0; i < transition.ValueField.Count; i++)
            {
                var value = transition.ValueField[i];
                Stage.SetFloat(value.fieldName, value.EndValue);
            }
        }
        else
        {
            if (OnTransitionStart.GetInvocationList().Length > 0)
            {
                OnTransitionStart(null);
            }
        }

        if (OnTransitionEnd.GetInvocationList().Length > 0)
        {
            OnTransitionEnd();
        }
    }