Exemple #1
0
        public void InitFade(FadeStyle style)
        {
            switch (style)
            {
            case FadeStyle.FADEIN_FROM_BLACK:
                _currFade = _black;
                _tgtFade  = _fg;
                break;

            case FadeStyle.FADEIN_FROM_BACKGROUND:
                _currFade = _bg;
                _tgtFade  = _fg;
                break;

            case FadeStyle.FADEOUT_TO_BLACK:
                _currFade = _bg;
                _tgtFade  = _black;
                break;

            case FadeStyle.FADEOUT_TO_BACKGROUND:
            default:
                _currFade = null;
                _tgtFade  = null;
                break;
            }
        }
    /// <summary>
    /// Animate the gameobject
    /// </summary>
    public override void Animate()
    {
        switch (initialFillStyle)
        {
        case FadeStyle.FadeIn:
            if (loop)
            {
                LeanTween.value(gameObject, img.fillAmount, 1, duration).setOnUpdate((float val) => { img.fillAmount = val; }).setEase(easingStyle).setDelay(delay).setLoopPingPong();
            }
            else
            {
                LeanTween.value(gameObject, img.fillAmount, 1, duration).setOnUpdate((float val) => { img.fillAmount = val; }).setEase(easingStyle).setDelay(delay);
            }
            initialFillStyle = FadeStyle.FadeOut;
            break;

        case FadeStyle.FadeOut:
            if (loop)
            {
                LeanTween.value(gameObject, img.fillAmount, 0, duration).setOnUpdate((float val) => { img.fillAmount = val; }).setEase(easingStyle).setDelay(delay).setLoopPingPong();
            }
            else
            {
                LeanTween.value(gameObject, img.fillAmount, 0, duration).setOnUpdate((float val) => { img.fillAmount = val; }).setEase(easingStyle).setDelay(delay);
            }
            initialFillStyle = FadeStyle.FadeIn;
            break;
        }
    }
 /// <summary>
 /// Stop all animations on disable to prevent weird animations on next enable
 /// </summary>
 private new void OnDisable()
 {
     base.OnDisable();
     if (repeatOnDisable)
     {
         img.color = initialColor;
         fadeStyle = initialFadeStyle;
     }
 }
 public void Fade(float delay, FadeStyle style = FadeStyle.In)
 {
     if (style == FadeStyle.In)
     {
         Fader.DOColor(new Color(0f, 0f, 0f, 1f), delay);
     }
     else
     {
         Fader.DOColor(new Color(0f, 0f, 0f, 0f), delay);
     }
 }
Exemple #5
0
 /// <summary>
 /// Fade image specified in class
 /// </summary>
 /// <param name="style">Type of fade to initiate</param>
 /// <param name="seconds">Seconds the whole fading procces takes (excluding halfway pause time)</param>
 /// <param name="pauseSeconds">Seconds of pause at halfway point, can be null</param>
 /// <returns></returns>
 public void Fade(FadeStyle style, float seconds, float pauseSeconds = 0, Action action = null)
 {
     // half seconds when fading in and out
     if (style == FadeStyle.InAndOut || style == FadeStyle.OutAndIn)
     {
         seconds *= .5f;
     }
     // prevent multiple coroutines running simultaniously
     if (fadeRoutine != null)
     {
         StopCoroutine(fadeRoutine);
     }
     fadeRoutine = StartCoroutine(FadeImage(style, seconds, pauseSeconds, action));
 }
    public FadeEventArgs(FadeStyle fadeStyle = FadeStyle.none)
    {
        this.fadeTarget = fadeStyle;

        switch (fadeTarget)
        {
        case FadeStyle.fadeIn:
            targetOpacity = 0;
            break;

        case FadeStyle.fadeOut:
            targetOpacity = 1;
            break;
        }
    }
    /// <summary>
    /// Start fading the gameobject's recttransform
    /// </summary>
    public override void Animate()
    {
        switch (fadeStyle)
        {
        case FadeStyle.FadeIn:
            if (loop)
            {
                if (!randomizeDelay)
                {
                    LeanTween.alpha((RectTransform)gameObject.transform, 1, duration).setEase(easingStyle).setOnComplete(() => Animate());
                }
                else
                {
                    LeanTween.alpha((RectTransform)gameObject.transform, 1, duration).setEase(easingStyle).setOnComplete(() => StartCoroutine(AnimateAfterDelay()));
                }
            }
            else
            {
                LeanTween.alpha((RectTransform)gameObject.transform, 1, duration).setEase(easingStyle).setDelay(delay);
            }
            fadeStyle = FadeStyle.FadeOut;
            break;

        case FadeStyle.FadeOut:
            if (loop)
            {
                if (!randomizeDelay)
                {
                    LeanTween.alpha((RectTransform)gameObject.transform, 0, duration).setEase(easingStyle).setOnComplete(() => Animate());
                }
                else
                {
                    LeanTween.alpha((RectTransform)gameObject.transform, 0, duration).setEase(easingStyle).setOnComplete(() => StartCoroutine(AnimateAfterDelay()));
                }
            }
            else
            {
                LeanTween.alpha((RectTransform)gameObject.transform, 0, duration).setEase(easingStyle).setOnComplete(() => gameObject.SetActive(!inactiveOnTransparent)).setDelay(delay);
            }
            fadeStyle = FadeStyle.FadeIn;
            break;

        default:
            break;
        }
    }
Exemple #8
0
        // Token: 0x0600CE9A RID: 52890 RVA: 0x0038D154 File Offset: 0x0038B354
        private void GetPathUIController_OnGotoButtonClick(GetPathData getPathInfo)
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_GetPathUIController_OnGotoButtonClickGetPathData_hotfix != null)
            {
                this.m_GetPathUIController_OnGotoButtonClickGetPathData_hotfix.call(new object[]
                {
                    this,
                    getPathInfo2
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            GetPathData   getPathInfo = getPathInfo2;
            GetPathUITask $this       = this;
            int?          num         = new int?(0);
            FadeStyle     style       = FadeStyle.Black;
            int           num2        = WorldUITask.CanGotoGetPath(getPathInfo, ref style);

            if (num2 <= 0)
            {
                num = new int?(num2);
                if (num == 0 || num == -402)
                {
                    CommonUIController.Instance.StartFadeOut(delegate
                    {
                        $this.Pause();
                        if ($this.m_onGotoGetPathAction != null)
                        {
                            NeedGoods arg = null;
                            if ($this.m_goodsNeedCount > 0)
                            {
                                arg = new NeedGoods($this.m_goodsType, $this.m_goodsID, $this.m_goodsNeedCount);
                            }
                            $this.m_onGotoGetPathAction(getPathInfo, arg);
                        }
                    }, style, -1f);
                }
                else
                {
                    CommonUIController.Instance.ShowErrorMessage(num.Value, 2f, null, true);
                }
                return;
            }
        }
    public void Fade(float duration, FadeStyle fadeStyle, Color color)
    {
        float targetOpacity = 0;

        switch (fadeStyle)
        {
        case FadeStyle.fadeIn:
            targetOpacity = 0;
            break;

        case FadeStyle.fadeOut:
            targetOpacity = 1;
            break;

        default:
            throw new System.NotImplementedException("Fade style " + fadeStyle + "none is invalid.");
        }

        Fade(duration, targetOpacity, color);
    }
Exemple #10
0
 /// <summary>
 /// Fades Image to Opaque/Transparent
 /// </summary>
 /// <param name="style">FadeStyle to Fade to</param>
 /// <param name="seconds">Duration of Fade</param>
 /// <param name="pauseSeconds">Amount of time to Pause for when doing In-Out or Out-In</param>
 private IEnumerator FadeImage(FadeStyle style, float seconds, float pauseSeconds = 0, Action action = null)
 {
     fadingImg.enabled = true;
     // loop over specified seconds
     for (float i = 0; i <= 1; i += UnityEngine.Time.deltaTime / seconds)
     {
         float val = i;
         if (style == FadeStyle.In || style == FadeStyle.InAndOut)
         {
             val = 1 - i;
         }
         if (EnableSmoothFade) // set color with val as alpha along fading curve (making fading in and out smoother)
         {
             fadingImg.color = new Color(fadingImg.color.r, fadingImg.color.g, fadingImg.color.b, FadeCurve.Evaluate(val));
         }
         else // set color with val as alpha in a linear fashion
         {
             fadingImg.color = new Color(fadingImg.color.r, fadingImg.color.g, fadingImg.color.b, val);
         }
         yield return(null);
     }
     if (style == FadeStyle.InAndOut || style == FadeStyle.OutAndIn) // Fading twice
     {
         if (action != null)
         {
             action.Invoke();
         }
         // hold current screen for specified seconds
         if (pauseSeconds > 0)
         {
             yield return(new WaitForSecondsRealtime(pauseSeconds));
         }
         // Fade to Result
         fadeRoutine = StartCoroutine(FadeImage(style.Equals(FadeStyle.OutAndIn) ? FadeStyle.In : FadeStyle.Out, seconds, pauseSeconds));
     }
     fadingImg.color   = new Color(fadingImg.color.r, fadingImg.color.g, fadingImg.color.b, style.Equals(FadeStyle.In) ? 0 : 1);
     fadingImg.enabled = fadingImg.color.a != 0;
 }
Exemple #11
0
        public void SetFade(int steps = 5, FadeStyle style = FadeStyle.NOFADE)
        {
            if (IsDisposed)
            {
                return;
            }
            if (style == FadeStyle.NOFADE)
            {
                return;
            }
            if (steps <= 0)
            {
                return;
            }

            InitFade(style);

            _fadeSteps      = steps;
            _fadeTotalSteps = steps;
            BackgroundImage = _currFade;
            Visible         = true;
            tmFade.Enabled  = true;
        }
        // Token: 0x0600905F RID: 36959 RVA: 0x0029F4CC File Offset: 0x0029D6CC
        private void OpenServiceActivityUIController_OnMissionGoto(GetPathData getPathInfo)
        {
            if (!BJLuaObjHelper.IsSkipLuaHotfix && this.TryInitHotFix("") && this.m_OpenServiceActivityUIController_OnMissionGotoGetPathData_hotfix != null)
            {
                this.m_OpenServiceActivityUIController_OnMissionGotoGetPathData_hotfix.call(new object[]
                {
                    this,
                    getPathInfo2
                });
                return;
            }
            BJLuaObjHelper.IsSkipLuaHotfix = false;
            GetPathData getPathInfo         = getPathInfo2;
            OpenServiceActivityUITask $this = this;
            int?      num   = new int?(0);
            FadeStyle style = FadeStyle.Black;
            int       num2  = WorldUITask.CanGotoGetPath(getPathInfo, ref style);

            if (num2 <= 0)
            {
                num = new int?(num2);
                if (num == 0)
                {
                    CommonUIController.Instance.StartFadeOut(delegate
                    {
                        $this.Pause();
                        WorldUITask.StartGetPathTargetUITask(getPathInfo, $this.m_currIntent, null);
                    }, style, -1f);
                }
                else
                {
                    CommonUIController.Instance.ShowErrorMessage(num.Value, 2f, null, true);
                }
                return;
            }
        }
Exemple #13
0
        /// <summary>
        /// Start fading the gameobject's recttransform
        /// </summary>
        public void FadeGroup(bool fadeIn)
        {
            FadeStyle fade = fadeIn ? FadeStyle.FadeIn : FadeStyle.FadeOut;

            switch (fade)
            {
            case FadeStyle.FadeIn:
                if (loop)
                {
                    LeanTween.value(gameObject, minMaxAlpha.x, minMaxAlpha.y, duration).setOnUpdate((float val) => { group.alpha = val; }).setEase(easingStyle).setLoopPingPong();
                }
                else
                {
                    LeanTween.value(gameObject, minMaxAlpha.x, minMaxAlpha.y, duration).setOnUpdate((float val) => { group.alpha = val; }).setEase(easingStyle);
                }
                break;

            case FadeStyle.FadeOut:
                if (loop)
                {
                    LeanTween.value(gameObject, minMaxAlpha.y, minMaxAlpha.x, duration).setOnUpdate((float val) => { group.alpha = val; }).setEase(easingStyle).setLoopPingPong();
                }
                else
                {
                    if (gameObject.activeInHierarchy)
                    {
                        LeanTween.value(gameObject, minMaxAlpha.y, minMaxAlpha.x, duration).setOnUpdate((float val) => { group.alpha = val; }).setEase(easingStyle).setOnComplete(() => { if (inactiveOnTransparent)
                                                                                                                                                                                          {
                                                                                                                                                                                              gameObject.SetActive(false);
                                                                                                                                                                                          }
                                                                                                                                                                                  });
                    }
                }
                break;
            }
        }
 /// <summary>
 /// Transiton that fades to black between scenes.
 /// </summary>
 /// <param name="fadeDuration">Duration of each fade in milliseconds.</param>
 /// <param name="halfwayDuration">Duration to wait before starting to fade out in milliseconds. Only relevant if fadeStyle is set to 'FadeInOut', otherwise set to 0.</param>
 /// <param name="fadeStyle">How to fade the scene.</param>
 public TransitionFade( int fadeDuration = 1000, int halfwayDuration = 500, FadeStyle fadeStyle = FadeStyle.FadeInOut )
 {
     this.fadeDuration = fadeDuration;
     this.halfwayDuration = halfwayDuration;
     this.style = fadeStyle;
 }
 new void Awake()
 {
     base.Awake();
     initialFadeStyle = fadeStyle;
 }
 public void ResetFader()
 {
     LeanTween.cancel(gameObject);
     img.color = initialColor;
     fadeStyle = FadeStyle.FadeOut;
 }
Exemple #17
0
 /// <summary>
 /// Transiton that fades to black between scenes.
 /// </summary>
 /// <param name="fadeDuration">Duration of each fade in milliseconds.</param>
 /// <param name="halfwayDuration">Duration to wait before starting to fade out in milliseconds. Only relevant if fadeStyle is set to 'FadeInOut', otherwise set to 0.</param>
 /// <param name="fadeStyle">How to fade the scene.</param>
 public TransitionFade(int fadeDuration = 1000, int halfwayDuration = 500, FadeStyle fadeStyle = FadeStyle.FadeInOut)
 {
     this.fadeDuration    = fadeDuration;
     this.halfwayDuration = halfwayDuration;
     this.style           = fadeStyle;
 }