Exemplo n.º 1
0
 private void ScreenFaderFadeIn(float time, SimpleTween.Callback onCompletedCB)
 {
     // fade the screen to white
     screenFade.gameObject.SetActive(true);
     screenFade.alpha = 0.0f;
     SimpleTweener.AddTween(() => screenFade.alpha, x => screenFade.alpha = x, 1.0f, time).OnCompleted(onCompletedCB);
 }
Exemplo n.º 2
0
    public override void Show(float fade, TransitionDirection direction, SimpleTween.Callback callback)
    {
        // don't animate the elements if we're returning to this screen from a submenu.
        if (direction == TransitionDirection.Forward)
        {
            // get the distance and credits values.
            float distance    = GameManager.LevelManager.TotalDistance;
            float record      = GameManager.RecordDistance;
            int   creditScore = GameManager.CreditsThisRace;

            if (distance == record)
            {
                // this is a new record, so show the newRecordScreen elements
                normalScreen.alpha    = 0.0f;
                newRecordScreen.alpha = 1.0f;

                // animate the distance text up from 0, then kick the scale at the end for effect.
                SimpleTweener.AddTween(() => 0, x => newRecordText.text = Mathf.CeilToInt(x).ToString() + "m", record, 0.5f).Delay(0.2f).OnCompleted(() => {
                    KickItem(newRecordText.transform, 1.5f, 0.5f);
                });
                SimpleTweener.AddTween(() => 0, x => creditScoreText.text = "+" + x, creditScore, 0.5f).Delay(0.7f).OnCompleted(() => {
                    KickItem(creditScoreText.transform, 1.5f, 0.3f);
                });
            }
            else
            {
                // no new record, so show the normalScreen elements
                normalScreen.alpha    = 1.0f;
                newRecordScreen.alpha = 0.0f;

                // animate the text up from 0, then kick the scale at the end for effect.
                SimpleTweener.AddTween(() => 0, x => distanceText.text = Mathf.CeilToInt(x).ToString() + "m", distance, 0.5f).Delay(0.2f).OnCompleted(() => {
                    KickItem(distanceText.transform, 1.5f, 0.3f);
                });
                SimpleTweener.AddTween(() => 0, x => oldRecordText.text = Mathf.CeilToInt(x).ToString() + "m", record, 0.5f).Delay(0.5f).OnCompleted(() => {
                    KickItem(oldRecordText.transform, 1.5f, 0.3f);
                });
                SimpleTweener.AddTween(() => 0, x => creditScoreText.text = "+" + x, creditScore, 0.5f).Delay(1.0f).OnCompleted(() => {
                    KickItem(creditScoreText.transform, 1.5f, 0.3f);
                });
            }
        }

        base.Show(fade, direction, callback);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Hide this menu screen
    /// </summary>
    public virtual void Hide(float fade, TransitionDirection direction = TransitionDirection.Back, SimpleTween.Callback callback = null)
    {
        // cancel any running tweens in case we are leaving this menu immediately after having opened it.
        SimpleTweener.RemoveTween(alphaTween);
        SimpleTweener.RemoveTween(posTween);

        if (fade == 0.0f)
        {
            canvasGroup.alpha = 0.0f;

            // deactivate this gameobject when the screen is not visible
            gameObject.SetActive(false);

            if (callback != null)
            {
                callback();
            }
        }
        else
        {
            // fade out the canvas group, then disable the gameobject once it's invisible
            alphaTween = SimpleTweener.AddTween(() => CanvasGroup.alpha, x => CanvasGroup.alpha = x, 0.0f, fade).UseRealTime(true).OnCompleted(() => {
                gameObject.SetActive(false);
                if (callback != null)
                {
                    callback();
                }
            });
            posTween = SimpleTweener.AddTween(() => Vector2.zero, x => rectXfm.anchoredPosition = x, new Vector2(0, -30), fade).UseRealTime(true);
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Show this menu screen.
    /// </summary>
    /// <param name="fade">Transition time</param>
    /// <param name="direction">Direction - Back if we are returning from a sub-menu, Forward otherwise</param>
    /// <param name="callback">Callback to call once the transition is finished</param>
    public virtual void Show(float fade, TransitionDirection direction = TransitionDirection.Forward, SimpleTween.Callback callback = null)
    {
        gameObject.SetActive(true);

        // cancel any running tweens in case we are returning to this menu immediately after having left it.
        SimpleTweener.RemoveTween(alphaTween);
        SimpleTweener.RemoveTween(posTween);

        if (fade == 0.0f)
        {
            canvasGroup.alpha = 1.0f;
            if (callback != null)
            {
                callback();
            }
        }
        else
        {
            // animate the position and alpha of the screen
            alphaTween = SimpleTweener.AddTween(() => CanvasGroup.alpha, x => CanvasGroup.alpha = x, 1.0f, fade).OnCompleted(callback).UseRealTime(true);
            posTween   = SimpleTweener.AddTween(() => new Vector2(0, -30), x => rectXfm.anchoredPosition = x, Vector2.zero, fade).UseRealTime(true);
        }

        // set our default UI item so it has focus.
        EventSystem.current.SetSelectedGameObject(defaultUIItem);
    }