Example #1
0
        /// <summary>
        /// Changes the current screen to the provided.
        /// </summary>
        /// <param name="screen">Screen to change to.</param>
        public void ChangeScreen(UI_Screen_Mk2 screen)
        {
            prevScreen = currScreen;
            currScreen = screen;

            // Scale animate if previous screen was an overlay
            if (prevScreen.ScreenType == UI_Screen_Mk2.Screen.SCREEN_OVERLAY)
            {
                StartCoroutine("PopOut", prevScreen);
            }

            // Current screen is an overlay
            if (currScreen.ScreenType == UI_Screen_Mk2.Screen.SCREEN_OVERLAY)
            {
                StartCoroutine("PopIn", currScreen);
            }
            // Current screen is fullscreen
            else
            {
                // Previous screen was not an overlay
                if (prevScreen.ScreenType != UI_Screen_Mk2.Screen.SCREEN_OVERLAY)
                {
                    // Play shader animation
                    StartCoroutine("TransitionOut", prevScreen);
                }
                // Previous screen was an overlay
                else
                {
                    currScreen.ScreenElements.SetActive(true);
                    currScreen.gameObject.SetActive(true);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Changes the current screen to the one provided, if the Object provided is of type UI_Screen_Mk2.
        /// </summary>
        /// <param name="screenObject">Screen to change to.</param>
        public void ChangeScreen(Object screenObject)
        {
            UI_Screen_Mk2 screen = screenObject as UI_Screen_Mk2;

            if (screen != null)
            {
                ChangeScreen(screen);
            }
        }
Example #3
0
        /// <summary>
        /// Coroutine to shader-animate the provided Full screen.
        /// </summary>
        /// <param name="screen">Screen to animate.</param>
        private IEnumerator TransitionIn(UI_Screen_Mk2 screen)
        {
            if (screen == null)
            {
                yield break;
            }
            if (screen.ScreenImage.sprite == null)
            {
                screen.ScreenImage.material.SetFloat("_Cutoff", 0f);
                screen.ScreenImage.material.SetFloat("_Fade", 1f);

                screen.gameObject.SetActive(true);
                screen.ScreenElements.SetActive(false);

                if (screen.IsAnimated)
                {
                    yield return(new WaitForSeconds(screen.gameObject.GetComponent <DelayedAnim>().DelayTime));
                }

                screen.ScreenElements.SetActive(true);

                yield break;
            }

            screen.ScreenElements.SetActive(false);
            screen.gameObject.SetActive(true);

            screen.ScreenImage.material.SetTexture("_MaskTex", screen.ScreenTransitionTexture);
            screen.ScreenImage.material.SetInt("_Distort", System.Convert.ToInt32(screen.ScreenTransition.Equals(UI_Screen_Mk2.Transition.TRANSITION_DISTORT)));

            screen.ScreenImage.material.SetFloat("_Cutoff", 1f);
            screen.ScreenImage.material.SetFloat("_Fade", 1f);

            float i = 1f;

            while (i >= 0f - Time.unscaledDeltaTime)
            {
                if (screen.ScreenTransition == UI_Screen_Mk2.Transition.TRANSITION_FADE)
                {
                    screen.ScreenImage.material.SetFloat("_Fade", i);
                }
                else
                {
                    screen.ScreenImage.material.SetFloat("_Cutoff", i);
                }

                i -= Time.unscaledDeltaTime * transitSpeed;
                yield return(new WaitForEndOfFrame());
            }

            screen.ScreenImage.material.SetFloat("_Cutoff", 0f);
            screen.ScreenImage.material.SetFloat("_Fade", 1f);

            screen.ScreenElements.SetActive(true);
        }
Example #4
0
        /// <summary>
        /// Called when this object first becomes enabled.
        /// </summary>
        private void Start()
        {
            if (PlayerPrefs.GetInt("FirstLaunch") == 0 && splashScreen != null)
            {
                currScreen = splashScreen;
                PlayerPrefs.SetInt("FirstLaunch", 1);
            }
            else
            {
                currScreen = startScreen;
            }

            prevScreen = currScreen;

            if (currScreen.StartOnAwake)
            {
                StartCoroutine("TransitionIn", currScreen);
            }
        }
Example #5
0
        /// <summary>
        /// Coroutine to shader-animate the provided Full screen.
        /// </summary>
        /// <param name="screen">Screen to animate.</param>
        private IEnumerator TransitionOut(UI_Screen_Mk2 screen)
        {
            if (screen == null)
            {
                yield break;
            }

            screen.ScreenElements.SetActive(false);
            screen.gameObject.SetActive(true);

            screen.ScreenImage.material.SetTexture("_MaskTex", screen.ScreenTransitionTexture);
            screen.ScreenImage.material.SetInt("_Distort", System.Convert.ToInt32(screen.ScreenTransition.Equals(UI_Screen_Mk2.Transition.TRANSITION_DISTORT)));

            screen.ScreenImage.material.SetFloat("_Cutoff", 1f);
            screen.ScreenImage.material.SetFloat("_Fade", 1f);

            float i = 0f;

            while (i <= 1f + Time.unscaledDeltaTime)
            {
                if (screen.ScreenTransition == UI_Screen_Mk2.Transition.TRANSITION_FADE)
                {
                    screen.ScreenImage.material.SetFloat("_Fade", i);
                }
                else
                {
                    screen.ScreenImage.material.SetFloat("_Cutoff", i);
                }

                i += Time.unscaledDeltaTime * transitSpeed;
                yield return(new WaitForEndOfFrame());
            }

            screen.ScreenImage.material.SetFloat("_Cutoff", 1f);
            screen.ScreenImage.material.SetFloat("_Fade", 1f);

            screen.gameObject.SetActive(false);

            StartCoroutine("TransitionIn", currScreen);
        }
Example #6
0
        /// <summary>
        /// Coroutine to scale-animate the provided Overlay screen.
        /// </summary>
        /// <param name="screen">Screen to animate.</param>
        private IEnumerator PopOut(UI_Screen_Mk2 screen)
        {
            if (screen == null)
            {
                yield break;
            }

            screen.ScreenImage.rectTransform.localScale = Vector3.one;

            float index = 1f;

            while (index > 0f)
            {
                screen.ScreenImage.rectTransform.localScale -= Vector3.Lerp(Vector3.zero, Vector3.one, Time.unscaledDeltaTime * popSpeed);
                index -= Time.unscaledDeltaTime * popSpeed;

                yield return(new WaitForEndOfFrame());
            }

            screen.ScreenImage.rectTransform.localScale = Vector3.zero;

            screen.gameObject.SetActive(false);
            screen.ScreenElements.SetActive(false);
        }