public static void SafeInvoke <T, U>(this MyUnityEvent <T, U> action, T param1, U param2)
 {
     if (action != null)
     {
         action.Invoke(param1, param2);
     }
 }
Beispiel #2
0
    protected override void OnEvent(bool paramBool)
    {
        base.OnEvent(paramBool);
        MyUnityEvent e = new MyUnityEvent();

        onEvent.Invoke(e);
    }
 public static void SafeInvoke(this MyUnityEvent action)
 {
     if (action != null)
     {
         action.Invoke();
     }
 }
 public static void SafeInvoke <T>(this MyUnityEvent <T> action, T param)
 {
     if (action != null)
     {
         action.Invoke(param);
     }
 }
Beispiel #5
0
    public void Retry()
    {
        var callback = new MyUnityEvent();

        callback.AddListener(() => ChangeLevel(CurrentLevel));
        MyAdManager.Instance.ShowStageClearInterstitial(callback);
    }
Beispiel #6
0
    void ShowInterstitial(string key, MyUnityEvent callback)
    {
        if (!IsAvailable)
        {
            callback.SafeInvoke();
            return;
        }

#if IMPORT_HYPERCOMMON
        AudioManager.Instance.SetMute(true);
        AdManager.Instance.ShowInterstitialWithKey(key, () =>
        {
            AudioManager.Instance.SetMute(false);
            callback.SafeInvoke();
        }
                                                   , (error) =>
        {
            AudioManager.Instance.SetMute(false);
            callback.SafeInvoke();
            Debug.Log(error);
        });
#else
        callback.SafeInvoke();
#endif
    }
Beispiel #7
0
 public void ShowStageClearInterstitial(MyUnityEvent callback = null)
 {
     if (MyGameManager.Instance.Stage.CurrentStageData.IsSkipAd)
     {
         return;
     }
     ShowInterstitial(StageClearKey, callback);
 }
    public static void TriggerEvent(string eventName, string value)
    {
        MyUnityEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(value);
        }
    }
Beispiel #9
0
    public static void TriggerEvent(TypeOfEvent theType, EventInfo triggerInfo)
    {
        MyUnityEvent thisEvent = null;

        if (eventManager.eventDictionary.TryGetValue(theType, out thisEvent))
        {
            thisEvent.Invoke(triggerInfo);
        }
    }
    public static void StopListening(string eventName, UnityAction <string> listener)
    {
        if (eventManager == null)
        {
            return;
        }
        MyUnityEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Beispiel #11
0
    public static void StopListening(TypeOfEvent theType, UnityAction <EventInfo> listener)
    {
        if (_eventManager == null)
        {
            return;
        }
        MyUnityEvent thisEvent = null;

        if (eventManager.eventDictionary.TryGetValue(theType, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
Beispiel #12
0
        public static void StartListening(string eventName, UnityAction <object[]> listener)
        {
            MyUnityEvent thisEvent;

            if (Instance._eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.AddListener(listener);
            }
            else
            {
                thisEvent = new MyUnityEvent();
                thisEvent.AddListener(listener);
                Instance._eventDictionary.Add(eventName, thisEvent);
            }
        }
Beispiel #13
0
    public static void startListen(TypeOfEvent theType, UnityAction <EventInfo> listener)
    {
        MyUnityEvent thisevent = null;

        if (eventManager.eventDictionary.TryGetValue(theType, out thisevent))
        {
            thisevent.AddListener(listener);
        }
        else
        {
            thisevent = new MyUnityEvent();
            thisevent.AddListener(listener);
            eventManager.eventDictionary.Add(theType, thisevent);
        }
    }
Beispiel #14
0
        /// <summary>
        /// アクションが呼ばれるまで待機する
        /// </summary>
        public static IEnumerator WaitAction <T1, T2>(MyUnityEvent <T1, T2> action, Action callback = null)
        {
            bool isCalled            = false;
            UnityAction <T1, T2> act = ((arg1, arg2) => isCalled = true);

            action.AddListener(act);

            yield return(new WaitUntil(() => isCalled));

            action.RemoveListener(act);
            if (callback != null)
            {
                callback.Invoke();
            }
        }
Beispiel #15
0
    public void SubscribeEvent <T>(string _eventName, UnityAction <T> _functionCall)
    {
        UnityEventBase eventListener;

        if (m_FunctionWithNoParamDictionary.TryGetValue(_eventName, out eventListener))
        {
            UnityEvent <T> unityEvent = eventListener as UnityEvent <T>;
            unityEvent.AddListener(_functionCall);
        }
        else
        {
            UnityEvent <T> unityEvent = new MyUnityEvent <T>();
            unityEvent.AddListener(_functionCall);
            m_FunctionWithNoParamDictionary.Add(_eventName, unityEvent);
        }
    }
Beispiel #16
0
    public static void AddEventListener(string eventName, UnityAction <object> callBackFunction)
    {
        MyUnityEvent _unityEvent;

        if (_eventDictionary.TryGetValue(eventName, out _unityEvent))
        {
            _unityEvent.AddListener(callBackFunction);
        }
        else
        {
            _unityEvent = new MyUnityEvent();
            _unityEvent.AddListener(callBackFunction);
            _eventDictionary.Add(eventName, _unityEvent);
        }

        Log.L("[EventManager] Add Listener : event = " + eventName + ", callback = " + callBackFunction.Target.ToString() + '.' + callBackFunction.Method.ToString());
    }
Beispiel #17
0
 public void ShowGameOverInterstitial(MyUnityEvent callback = null)
 {
     ShowInterstitial(GameOverKey, callback);
 }
Beispiel #18
0
 /// <summary>
 /// アクションが呼ばれるまで待機する
 /// </summary>
 public static Coroutine WaitAction <T1, T2>(this MonoBehaviour mono, MyUnityEvent <T1, T2> action, Action callback = null)
 {
     return(mono.StartCoroutine(KKUtilities.WaitAction(action, callback)));
 }