Esempio n. 1
0
    public void SetGlobalVolume(float volume, float tweenDuration = 0.0f)
    {
        if (m_gTweener != null)
        {
            m_gTweener.Kill();
        }
        m_gTweener = null;

        if (tweenDuration == 0)
        {
            m_globalVolume = volume;
            UpdateRealVolume();
            onGlobalVolumeChanged?.Invoke();
        }
        else
        {
            var duration = tweenDuration > 0 ? tweenDuration : volume < globalVolume ? fadeOutDuration : fadeInDuration;
            m_gTweener = DOTween.To(() => globalVolume, v => globalVolume = v, volume, duration).OnComplete(() => m_gTweener = null);
        }
    }
Esempio n. 2
0
    public bool Invoke(Event_ e)
    {
        if (voidHandler != null)
        {
            voidHandler.Invoke();
        }
        else if (normalHandler != null)
        {
            normalHandler.Invoke(e);
        }
        else
        {
            if (moduleHandler != null)
            {
                var me = e as ModuleEvent;
                if (me == null || !me.baseModule)
                {
                    Logger.LogError("Module Event invalid! [handler:{0}, event:{1}, targetModule:{2}, evenModule:{3}]", handler.Method, me != null ? me.moduleEvent : e.name, paramType.Name, me != null && me.baseModule ? me.baseModule.GetType().Name : "null");
                    return(false);
                }
                if (extendInfo != ModuleEvent.GLOBAL && me.moduleEvent != extendInfo || me.GetType() != paramType)
                {
                    return(false);
                }
                handler.DynamicInvoke(e);
            }
            else
            {
                if (paramType != e.GetType())
                {
                    Logger.LogError("Event handler [{0}] has wrong param type, ignore. [event:{3}, targetType:{1}, eventType:{2}]", handler.Method, paramType.Name, e.GetType().Name, e.name);
                    return(false);
                }
                handler.DynamicInvoke(e);
            }
        }

        return(true);
    }