Exemplo n.º 1
0
    IEnumerator Transition(string sceneName, DestinationTag destinationTag)
    {
        FadeUI fadeUI = Instantiate(fadeCanvasPrefabs);

        SaveManager.Instance.SavePlayerData();
        yield return(StartCoroutine(fadeUI.FadeOutScene(2f)));

        if (!SceneManager.GetActiveScene().name.Equals(sceneName))
        {
            yield return(SceneManager.LoadSceneAsync(sceneName));

            yield return(Instantiate(playerPrefabs, GetDestination(destinationTag).transform.position,
                                     GetDestination(destinationTag).transform.rotation));

            SaveManager.Instance.LoadPlayerData();
        }
        else
        {
            GameObject player = GameManager.Instance.playerStats.gameObject;
            player.GetComponent <NavMeshAgent>().enabled = false;
            player.transform.SetPositionAndRotation(GetDestination(destinationTag).transform.position, GetDestination(destinationTag).transform.rotation);
            player.GetComponent <NavMeshAgent>().enabled = true;
        }
        yield return(StartCoroutine(fadeUI.FadeInScene(2f)));
    }
Exemplo n.º 2
0
    private IEnumerator TransitionToStartScene()
    {
        FadeUI fadeUI = Instantiate(fadeCanvasPrefabs);

        yield return(StartCoroutine(fadeUI.FadeOutScene(2f)));

        yield return(SceneManager.LoadSceneAsync("StartScene"));

        PlayerPrefs.DeleteAll();
        yield return(StartCoroutine(fadeUI.FadeInScene(2f)));
    }
Exemplo n.º 3
0
    private IEnumerator TransitionToGameScene(string sceneName)
    {
        FadeUI fadeUI = Instantiate(fadeCanvasPrefabs);

        if (sceneName != "")
        {
            yield return(StartCoroutine(fadeUI.FadeOutScene(2f)));

            yield return(SceneManager.LoadSceneAsync(sceneName));

            foreach (var VARIABLE in FindObjectsOfType <TransitionDestination>())
            {
                if (VARIABLE.destinationTag == DestinationTag.ENTER)
                {
                    yield return(Instantiate(playerPrefabs, VARIABLE.transform.position,
                                             VARIABLE.transform.rotation));

                    break;
                }
            }
            yield return(StartCoroutine(fadeUI.FadeInScene(2f)));
        }
    }