示例#1
0
    IEnumerator ScreenTransition_ToNextLevel(GameState currentGS, GameState nextGS, ScreenTransitionType type)
    {
        Time.timeScale = 0.0f;
        // Start Animate the Screen Transition
        if (currentGS == GameState.MAIN_MENU)
        {
            UIManager.Instance.Start_Menu_Transition(type);
        }
        else if (currentGS == GameState.GAMEPLAY)
        {
            UIManager.Instance.Start_Gameplay_Transition(type);
        }

        // Delay for 1.5seconds
        yield return(new WaitForSecondsRealtime(1.5f));

        Time.timeScale = 1.0f;
        // Go to next State after 1.5seconds
        if (nextGS == GameState.MAIN_MENU)
        {
            SceneManager.LoadScene("MainMenu");
        }
        else if (nextGS == GameState.GAMEPLAY || nextGS == GameState.RESTART)
        {
            SceneManager.LoadScene("Gameplay");
        }
    }
示例#2
0
    /**
        Plays the transition which corresponds with ScreenTransitionType type.
    */
    public void PlayTransition(ScreenTransitionType type)
    {
        string suffix = "";

        _type = type;

        switch(type)
        {
            case ScreenTransitionType.Open:
                suffix = " Open";
                _open.enabled = true;
                _close.enabled = false;
                if(!_collapse || !_expand) break;
                _collapse.enabled = false;
                _expand.enabled = false;

            break;

            case ScreenTransitionType.Close:
                suffix = " Close";
                _close.enabled = true;
                _open.enabled = false;
                if(!_collapse || !_expand) break;
                _collapse.enabled = false;
                _expand.enabled = false;
            break;

            default: return;
        }

        Play(gameObject.name + suffix);
    }
示例#3
0
    IEnumerator ScreenTransition_LoadIntoNewLevel(GameState currentGS, ScreenTransitionType type)
    {
        Time.timeScale = 0.0f;
        // Start Animate the Screen Transition
        if (currentGS == GameState.MAIN_MENU)
        {
            UIManager.Instance.Start_Menu_Transition(type);
        }
        else if (currentGS == GameState.GAMEPLAY)
        {
            UIManager.Instance.Start_Gameplay_Transition(type);
        }

        // Delay for 1.5seconds
        yield return(new WaitForSecondsRealtime(1.5f));

        Time.timeScale = 1.0f;
    }
示例#4
0
    public void Start_Menu_Transition(ScreenTransitionType type)
    {
        GO_Menu_ScreenTransition.SetActive(true);

        Animator anim = GO_Menu_ScreenTransition.GetComponent <Animator>();

        if (anim)
        {
            if (type == ScreenTransitionType.CENTER_TO_RIGHT)
            {
                anim.SetTrigger("Trigger_CenterToRight");
            }
            else if (type == ScreenTransitionType.RIGHT_TO_CENTER)
            {
                anim.SetTrigger("Trigger_RightToCenter");
            }
        }
    }
示例#5
0
    IEnumerator LoadSceneCoroutine(string sceneName, LoadSceneMode mode, ScreenTransitionType fadeIn, ScreenTransitionType fadeOut)
    {
        isTransitioning = true;
        switch (fadeIn)
        {
        case ScreenTransitionType.fade:
            yield return(StartCoroutine(FadeCoroutine(true)));

            break;
        }

        isWaitingOnLoad = true;

        SceneManager.LoadSceneAsync("LoadingScene");   // loads the loading scene

        while (isWaitingOnLoad)
        {
            yield return(null);
        }

        switch (fadeOut)
        {
        case ScreenTransitionType.fade:
            yield return(StartCoroutine(FadeCoroutine(false)));

            break;
        }
        float startTime = Time.time;

        isWaitingOnLoad = true;

        LoadingSceneManager loading = FindObjectOfType <LoadingSceneManager>();

        AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); // Loads the current scene

        yield return(operation);

        float timeRemaining = timeLoadingMin - (Time.time - startTime);

        if (timeRemaining > 0)
        {
            yield return(new WaitForSeconds(timeRemaining));
        }

        if (loading != null)
        {
            loading.TrackProgress(operation);
        }
        else
        {
            Debug.LogError("No loading scene manager was found. Progress bar will not increase.");
        }

        switch (fadeIn)
        {
        case ScreenTransitionType.fade:
            yield return(StartCoroutine(FadeCoroutine(true)));

            break;
        }

        SceneManager.UnloadSceneAsync("LoadingScene");

        while (isWaitingOnLoad)
        {
            yield return(null);
        }

        switch (fadeOut)
        {
        case ScreenTransitionType.fade:
            yield return(StartCoroutine(FadeCoroutine(false)));

            break;
        }

        isTransitioning = false;
    }
示例#6
0
 /// <summary>
 /// Attempts to load a scene. If the scene is already transitioning it returns false.
 /// </summary>
 /// <param name="sceneName">The name of the scene to load.</param>
 /// <param name="mode">The mode that the scene should be loaded in.</param>
 /// <param name="fadeIn">The transition type of the fading in function.</param>
 /// <param name="fadeOut">The transition type of the fading out function.</param>
 /// <returns>Returns false if the scene does not attempt to load.</returns>
 public bool LoadScene(string sceneName, LoadSceneMode mode = LoadSceneMode.Single, ScreenTransitionType fadeIn = ScreenTransitionType.NONE, ScreenTransitionType fadeOut = ScreenTransitionType.NONE)
 {
     if (isTransitioning)
     {
         if (DebugManager.instance.enableDebug && DebugManager.instance.debugSceneNameWhenCalled)
         {
             Debug.Log("Already transitioning to " + sceneName + ". Cannot transition.");
         }
         return(false);
     }
     else
     {
         if (fadeIn == ScreenTransitionType.NONE)
         {
             fadeIn = type;
         }
         if (fadeOut == ScreenTransitionType.NONE)
         {
             fadeOut = type;
         }
         if (DebugManager.instance.enableDebug && DebugManager.instance.debugSceneNameWhenCalled)
         {
             Debug.Log("Loading scene: " + sceneName);
         }
         StartCoroutine(LoadSceneCoroutine(sceneName, mode, fadeIn, fadeOut));
         return(true);
     }
 }
示例#7
0
 /**
     Hook called from TransitionCompleted(ScreenTransitionType type). Place code here to execute when a transition finishes.
 */
 protected virtual void OnTransitionComplete(ScreenTransitionType type)
 {
 }
示例#8
0
 /**
     Hook called from PlayTransition(ScreenTransitionType type). Place code here to execute when a transition begins.
 */
 protected virtual void OnTransitionBegin(ScreenTransitionType type)
 {
 }
示例#9
0
    /**
        This is called from the attached Screen2DTransition upon completion of a transition, there really isn't a reason to call it explicitly.

        The hook OnTransitionComplete(ScreenTransitionType type) is called here.
    */
    public void TransitionCompleted(ScreenTransitionType type)
    {
        //depending on what transition we just finished performing, change our state to the appropriate one.
        switch(type)
        {
            case ScreenTransitionType.Open:
                state = ScreenState.Open;
                if(manager)
                {
                    manager.openScreen = this;
                    manager.ScreenDidOpen(this);
                }
                DispatchEvent(new ScreenEvent(ScreenEvent.OPEN, this));
            break;

            case ScreenTransitionType.Close:
                state = ScreenState.Closed;
                if(manager)
                {
                    manager.openScreen = null;
                    manager.ScreenDidClose(this);
                }
                DispatchEvent(new ScreenEvent(ScreenEvent.CLOSE, this));
            break;

            case ScreenTransitionType.Collapse:
                state = ScreenState.Collapsed;
                if(manager) manager.ScreenDidCollapse(this);
                DispatchEvent(new ScreenEvent(ScreenEvent.COLLAPSE, this));
            break;

            case ScreenTransitionType.Expand:
                state = ScreenState.Expanded;
                if(manager) manager.ScreenDidExpand(this);
                DispatchEvent(new ScreenEvent(ScreenEvent.EXPAND, this));
            break;
        }

        DispatchEvent(new ScreenEvent(ScreenEvent.TRANSITION_COMPLETE, this));
        if(manager) manager.TransitionDidEnd(); //notify manager we completed transition
        OnTransitionComplete(type); //handle all the stuff relative to the screen when the transition completes
        transition.Clear(); //clear our cached transition data we no longer need
    }
示例#10
0
    /**
        Plays the animation associated with the provided ScreenTransitionType. If you are conforming to the framework, this is for communication between the Screen2DManager and the Screen2D and there is no real reason to call this method explicitly.

        The hook OnTransitionBegin(ScreenTransitionType type) is called here.
    */
    public void PlayTransition(ScreenTransitionType type)
    {
        state = ScreenState.InTransition; //set the screens state to in transition

        if(manager) manager.TransitionDidBegin(); //notify manager we are beginning a transition

        OnTransitionBegin(type); //handle all screen-relative stuff when a transition begins
        transition.PlayTransition(type); //play our transition
    }
示例#11
0
 public void Clear()
 {
     animation.Stop();
     _accumulatedTime = 0F;
     _type = ScreenTransitionType.None;
 }