Ejemplo n.º 1
0
        private IEnumerator Transition()
        {
            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(fadeOutTime));

            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            ControlEnabled(false);

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneIndexToLoad));

            // disable control from new player loaded in scene
            ControlEnabled(false);

            savingWrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();

            yield return(new WaitForSeconds(fadeOutWait));

            yield return(fader.FadeIn(fadeInTime));

            ControlEnabled(true);

            Destroy(gameObject);
        }
Ejemplo n.º 2
0
        private IEnumerator Transition()
        {
            DontDestroyOnLoad(gameObject);

            Fader            fader            = FindObjectOfType <Fader>();
            SavingWrapper    savingWrapper    = FindObjectOfType <SavingWrapper>();
            PlayerController playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            playerController.enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            PlayerController newPlayerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            newPlayerController.enabled = false;

            savingWrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            fader.FadeIn(fadeInTime);

            newPlayerController.enabled = true;
            Destroy(gameObject);
        }
Ejemplo n.º 3
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set."); // if the portal doesnt have a scene assigned to it this message pops up
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(fadeOutTime)); // fade out over a series of frames

            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();                                         // save current level

            yield return(SceneManager.LoadSceneAsync(sceneToLoad)); // load over a series of frames

            wrapper.Load();                                         // load current level

            Portal otherPortal = GetOtherPortal();                  // update the player

            UpdatePlayer(otherPortal);

            wrapper.Save();                                 // save the current level after you load in so when you restart the game you are right where you left off

            yield return(new WaitForSeconds(fadeWaitTime)); // wait for a series of frames for the camera to stablelize

            yield return(fader.FadeIn(fadeInTime));         // fade in over a series of frames

            Destroy(gameObject);
        }
Ejemplo n.º 4
0
        IEnumerator StartTransitioning()
        {
            if (sceneToLoadIndex < 0)
            {
                Debug.LogError("Scene To Load is not set correctly.");
                yield break;
            }
            DontDestroyOnLoad(gameObject);

            Fader         fader         = FindObjectOfType <Fader>();
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            // Fade Out
            yield return(fader.FadeOut(fadeOutTime));

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoadIndex));

            savingWrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayerTransform(otherPortal);

            savingWrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));


            Destroy(gameObject);
        }
Ejemplo n.º 5
0
        private IEnumerator Transition()
        {
            if (1 < 0)
            {
                Debug.LogError("Scene to load not set.");
                yield break;
            }

            Fader fader = FindObjectOfType <Fader>();

            DontDestroyOnLoad(gameObject);

            //yield return fader.FadeOut(100);

            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();

            yield return(SceneManager.LoadSceneAsync(1));

            wrapper.Load();

            //Portal otherPortal = GetOtherPortal();
            //UpdatePlayer(otherPortal);

            wrapper.Save();

            //yield return new WaitForSeconds(100);
            //yield return fader.FadeIn(fadeInTime);

            Destroy(gameObject);
        }
Ejemplo n.º 6
0
        private IEnumerator SceneTransition()
        {
            DontDestroyOnLoad(gameObject);
            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(fadeOutTime));

            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();

            yield return(SceneManager.LoadSceneAsync(targetScene));

            wrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            wrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            Destroy(gameObject);
        }
Ejemplo n.º 7
0
        IEnumerator TransitionRoutine()
        {
            yield return(_fader.FadeOutRoutine(_fadeOutTime));

            _savingWrapper.Save();
            yield return(SceneManager.LoadSceneAsync(_sceneToLoad));

            Portal[] portals = FindObjectsOfType <Portal>();
            foreach (Portal portal in portals)
            {
                if (portal == this)
                {
                    continue;
                }

                if (portal.GetIdentifier() == _identifier)
                {
                    _savingWrapper.Load();
                    HandlePlayer(portal);

                    yield return(null);

                    _savingWrapper.Save();
                }
            }

            yield return(new WaitForSeconds(_fadeWaitTime));

            yield return(_fader.FadeInRoutine(_fadeInTime));

            Destroy(gameObject);
        }
Ejemplo n.º 8
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set.");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            Fader         fader         = FindObjectOfType <Fader>();
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            yield return(fader.FadeOut(fadeOutTime));

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            savingWrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            Destroy(gameObject);
        }
Ejemplo n.º 9
0
        private IEnumerator LoadNextScene()
        {
            Fader         fader         = FindObjectOfType <Fader>();
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            DontDestroyOnLoad(gameObject);

            yield return(fader.Fade2White(fadeTime));

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            savingWrapper.Load();
            if (!target)
            {
                target = SetTarget();
            }

            GameObject player = GameObject.FindGameObjectWithTag("Player");

            player.GetComponent <Mover>().UpdatePlayer(target);

            savingWrapper.Save();
            yield return(new WaitForSeconds(fadeTime));

            yield return(fader.FadeIn(fadeTime));

            Destroy(gameObject);
        }
Ejemplo n.º 10
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load is not set, use the Editor to set it.");
            }

            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();

            yield return(StartCoroutine(fader.FadeOut(fadeOutTime)));

            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            savingWrapper.Load();

            Portal targetPortal = GetOtherPortal();

            UpdatePlayer(targetPortal);

            savingWrapper.Save();                           // save again once player is positioned at the right spot to avoid backloading through portal

            yield return(new WaitForSeconds(fadeWaitTime)); // wait to make sure everything loads (and saves)

            yield return(StartCoroutine(fader.FadeIn(fadeInTime)));

            Destroy(gameObject);
        }
Ejemplo n.º 11
0
        private IEnumerator Transition()
        {
            Fader            fader            = FindObjectOfType <Fader>();
            SavingWrapper    wrapper          = FindObjectOfType <SavingWrapper>();
            PlayerController playerController = FindObjectOfType <PlayerController>();

            playerController.enabled = false;
            DontDestroyOnLoad(this.gameObject);
            yield return(fader.FadeOut(fadeInTime));

            wrapper.Save();


            yield return(SceneManager.LoadSceneAsync(sceneIndex));

            PlayerController newplayerController = FindObjectOfType <PlayerController>();

            newplayerController.enabled = false;
            wrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);
            wrapper.Save();

            yield return(new WaitForSeconds(blackscreenTime));

            fader.FadeIn(fadeInTime);
            newplayerController.enabled = true;

            Destroy(this.gameObject);
        }
Ejemplo n.º 12
0
        private IEnumerator Transition()
        {
            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();


            yield return(fader.FadeOut(fadeOutTime));

            //save current level state
            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));


            // load current level state
            wrapper.Load();


            Portal otherPortal = GetOtherportal();

            UpdatePlayer(otherPortal);

            //wrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            Destroy(gameObject);
        }
Ejemplo n.º 13
0
        private IEnumerator Transition()
        {
            // Invalid scene index, cannot load new scene
            if (sceneToLoadIndex < 0)
            {
                Debug.LogError("Scene to load is not set");
                yield break;
            }

            // Preserve this portal until new scene finishes loading
            DontDestroyOnLoad(gameObject);

            // Remove player control
            PlayerController playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            playerController.enabled = false;

            // Fade out of scene
            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(fadeOutTime));

            // Save current level
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            savingWrapper.Save();

            // Load new scene
            yield return(SceneManager.LoadSceneAsync(sceneToLoadIndex));

            // Remove player control
            PlayerController newPlayerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            newPlayerController.enabled = false;

            // Load current level
            savingWrapper.Load();

            // Destination portal in new scene where the player will spawn
            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            // Save in the new scene
            savingWrapper.Save();

            // Wait before fading in
            yield return(new WaitForSeconds(fadeWaitTime));

            fader.FadeIn(fadeInTime);

            // Restore player control
            newPlayerController.enabled = true;

            // Scene loaded successfully, destroy previous portal
            print("Scene loaded");
            Destroy(gameObject);
        }
Ejemplo n.º 14
0
        // should not have to call StartCoroutine() inside a coroutine
        IEnumerator Transition()
        {
            DontDestroyOnLoad(gameObject.transform.parent);
            Fader fader = FindObjectOfType <Fader>();

            // remove old player controller to avoid glitches
            playerController.enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            // save the current state of the world you are leaving
            savingWrapper.Save();
            // transition to the scene with 'sceneIndex' index
            yield return(SceneManager.LoadSceneAsync(sceneIndex));

            // theoretically removes new player controller to avoid glitches
            // TODO may need to call gameobject.find again for the new player
            // if this doesn't work (UPDATE: SO IT ACTUALLY DOESN'T WORK)
            // playerController.enabled = false;

            // find the playercontroller in the newly loaded scene
            playerController         = GameObject.Find("Player").GetComponent <PlayerController>();
            playerController.enabled = false;



            // load the the last state of the other world you are going to transition to
            savingWrapper.Load();

            print("scene loaded");

            Portal otherPortal = GetOtherPortal();

            UpdatePlayerToSpawnPoint(otherPortal);

            // do another save here so that the next time we load the game up
            // the player will appear by the portal where it last spawned from
            savingWrapper.Save();

            // stall for .5 seconds
            yield return(new WaitForSeconds(waitTime));

            // runs in the background as a coroutine
            // so that the player controls can be re-enabled
            // asynchronously
            fader.FadeIn(fadeInTime);


            // theoretically restores new player player controller
            playerController.enabled = true;

            // destroys the parent gameobject
            // s.toToggleInPortalClass = true;
            // DestroyParentGameObj();
        }
Ejemplo n.º 15
0
        //Transition to the next scene
        private IEnumerator SceneTransition()
        {
            if (m_SceneToLoad < 0)
            {
                Debug.Log(gameObject.name + " Has no destination scene set");
                yield break;
            }

            //Ensure Portal continues to exist until all actions are completed
            DontDestroyOnLoad(gameObject);

            SceneFader    sceneFade     = FindObjectOfType <SceneFader>();
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            //Get the player controller and disable
            PlayerController oldPlayerControlComp = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            oldPlayerControlComp.enabled = false;

            //Fade out the scene
            yield return(sceneFade.SceneFadeOut(m_FadeOutTime));

            //Save game state old scene
            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(m_SceneToLoad));

            //Get the player controller and disable
            PlayerController newPlayerControlComp = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            newPlayerControlComp.enabled = false;

            //Load game state after new scene is loaded.
            savingWrapper.Load();

            Portal destinationPortal = GetDestinationPortal();

            UpdatePlayerPosition(destinationPortal);

            //Save game state new scene
            savingWrapper.Save();

            yield return(new WaitForSeconds(m_FadeWaitTime));

            yield return(sceneFade.SceneFadeIn(m_FadeInTime));

            //Enable player control
            newPlayerControlComp.enabled = true;

            //Debug.Log("SCENE LOADED");
            //Destroy old Portal after all transistions are completed.
            Destroy(gameObject);
        }
Ejemplo n.º 16
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set.");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();

            PlayerController playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            playerController.enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            //Save current level
            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            PlayerController newPlayerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            newPlayerController.enabled = false;
            //Load current level
            wrapper.Load();

            player = GameObject.FindWithTag("Player");
            player.GetComponent <PlayerController>().enabled = false;

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            wrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            newPlayerController         = GameObject.FindWithTag("Player").GetComponent <PlayerController>();
            newPlayerController.enabled = true;
            Destroy(gameObject);
        }
Ejemplo n.º 17
0
        IEnumerator Transition(GameObject player)
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("PORTAL - Transition: SceneToLoad has not been set!");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            Fader         fader         = FindObjectOfType <Fader> ();
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper> ();

            Time.timeScale = portalSpeedEffect;

            player.GetComponent <PlayerController> ().enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            Time.timeScale = 1f;

            savingWrapper.Save();
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            PlayerController controller =
                GameObject.FindWithTag("Player").GetComponent <PlayerController> ();

            controller.enabled = false;

            savingWrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            fader.FadeIn(fadeInTime);

            controller.enabled = true;

            Destroy(gameObject);
        }
Ejemplo n.º 18
0
        private IEnumerator Transition()
        {
            DontDestroyOnLoad(gameObject);

            // Player from the previous scene
            PlayerController player = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            player.enabled = false;

            // Start fading out the new scene
            yield return(fader.FadeOut(fadeOutTime));

            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            savingWrapper.Save();

            // Load asynchronously the new scene
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            // Player from the new scene
            PlayerController newPlayer = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            newPlayer.enabled = false;

            savingWrapper.Load();

            // Find the destination portal
            Portal destinationPortal = GetDestinationPortal();

            UpdatePlayer(destinationPortal);

            savingWrapper.Save();

            // Keep the new scene faded out for some time
            yield return(new WaitForSeconds(fadeWaitTime));

            // Start fading in the new scene
            fader.FadeIn(fadeInTime);

            // Restore control to the new player
            newPlayer.enabled = true;

            // Destroy the portal
            Destroy(gameObject);
        }
Ejemplo n.º 19
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load is not set, check the field on " + gameObject);
                yield break;
            }
            DontDestroyOnLoad(gameObject);

            Fader         fader         = FindObjectOfType <Fader>();
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            // remove control
            PlayerController playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            playerController.enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            // remove control
            playerController = GameObject.FindWithTag("Player").GetComponent <PlayerController>();
            playerController.GetComponent <PlayerController>().enabled = false;

            savingWrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();

            yield return(new WaitForSeconds(timeBetweenFade));

            fader.FadeIn(fadeInTime);

            // restore control
            playerController.GetComponent <PlayerController>().enabled = true;

            Destroy(gameObject);
        }
Ejemplo n.º 20
0
        private IEnumerator Transition()
        {
            //daha sonrada silinecek
            if (sceneToLoad < 0)
            {
                Debug.LogError("Yükelecek bir Scene yok");
                yield break;
            }


            //yükleme anında yoketme
            DontDestroyOnLoad(gameObject);
            //Fader ncomponentini aldık
            Fader fader = FindObjectOfType <Fader>();

            //sahneyi yavaşça kararıyor
            yield return(fader.FadeOut(fadeOutTime));

            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();

            //sahneyi yükledik
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            wrapper.Load();

            //doğru portal bulundu
            Portal otherPortal = GetOtherPortal();

            //player portala göre konumlandırıldı
            UpdatePlayer(otherPortal);

            wrapper.Save();

            //sahne karanlık bekliyor
            yield return(new WaitForSeconds(fadeWaitTime));

            //sahne yavaşça aydınlanıyor
            yield return(fader.FadeIn(fadeInTime));

            //objeyi(portal) yok et
            Destroy(gameObject);
        }
Ejemplo n.º 21
0
        /**
         * 切换scene的函数
         * "协程系统"不断的循环调用这个函数,直至没有函数体为止
         * 但也有一个问题:拥有这个函数的gameObject因为切换场景而销毁时,这个协程也会停止, 英文原文
         * But there is somthing tha is going to stop this from happening
         * that's the fact that as soon as we load this new scene
         * at portal game object the one which has the coroutine gets destroyed and so does the coroutine itself
         *
         * 1、调用切换scene的函数
         * 2、调用切换场景之后的一些函数,比如保存一些数据
         */

        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set.");
                yield break;
            }

            DontDestroyOnLoad(this.gameObject);

            Fader         fade             = GameObject.FindObjectOfType <Fader>();
            SavingWrapper wrapper          = GameObject.FindObjectOfType <SavingWrapper>();
            var           playerController = GameObject.FindObjectOfType <PlayerController>();

            playerController.enabled = false;

            yield return(fade.FadeOut(fadeOutTime));

            wrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            var newPlayerController = GameObject.FindObjectOfType <PlayerController>();

            newPlayerController.enabled = false;

            wrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            // another save for reload scene
            wrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            fade.FadeIn(fadeInTime);

            newPlayerController.enabled = true;
            Destroy(this.gameObject);
        }
Ejemplo n.º 22
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set.");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();

            // Fade out
            yield return(StartCoroutine(fader.FadeOut(fadeOutTime)));

            // Save current
            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();

            // Load new Scene
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            // Load current level
            wrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            wrapper.Save();

            // Wait for a few seconds
            // load?
            yield return(new WaitForSeconds(fadeWaitTime));

            // Fade In
            yield return(StartCoroutine(fader.FadeIn(fadeInTime)));

            Destroy(gameObject);
        }
Ejemplo n.º 23
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set.");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(fadeOutTime));

            // save current level
            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            // a solution designed by Will Norton to solve
            // an error regarding a MissingReferenceException for SavingWrapper
            wrapper = FindObjectOfType <SavingWrapper>();

            // load current level
            wrapper.Load();

            // move the player
            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            wrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            Destroy(gameObject);
        }
Ejemplo n.º 24
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load is not set!");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            //star fade out
            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(fadeOutTime));

            //save current level (when exiting level through portal)
            SavingWrapper save_wrap = FindObjectOfType <SavingWrapper>();

            save_wrap.Save();

            //load async next scene
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            //load current level save
            save_wrap.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            //resave the checkpoint after new scene was loaded
            save_wrap.Save();

            //wait betwen fade out and fade in
            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            Destroy(gameObject);
        }
Ejemplo n.º 25
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set!");
                yield break;
            }

            DontDestroyOnLoad(this.gameObject);

            //Fade out
            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(FadeOutTime));

            //Save current level
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            savingWrapper.Save();

            //Load new scene
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            //Load current level
            savingWrapper.Load();

            //Set player position
            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();

            //Fade In
            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(FadeInTime));

            Destroy(this.gameObject);
        }
Ejemplo n.º 26
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load not set");
                yield break; // rather than return null for IEnum
            }


            DontDestroyOnLoad(gameObject); // keeps portal gameObject, assuming portal is at root of scene

            Fader fader = FindObjectOfType <Fader>();

            // Save current level
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            yield return(fader.FadeOut(fadeOutTime)); //yields take turns within the method each frame

            //yield and call again when scene is finished loading

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad)); //allows us to transfer info into new scene

            // Load current level
            savingWrapper.Load();

            //after scene load..
            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save(); // save again after loading the players location so that we have correct state when returning to game, player should be at the protal spawn point

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            Destroy(gameObject); // this script is attached to portal, so will destroy portal
        }
Ejemplo n.º 27
0
        private IEnumerator Transition()
        {
            if (nextScene < 0)
            {
                Debug.Log("scene not found!");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            PlayerController player  = GameObject.FindWithTag("Player").GetComponent <PlayerController>();
            SavingWrapper    wrapper = FindObjectOfType <SavingWrapper>();
            Fader            fader   = FindObjectOfType <Fader>();

            player.enabled = false;

            yield return(fader.FadeOut(fadeOutTime));

            wrapper.Save();

            yield return(SceneManager.LoadSceneAsync(nextScene));

            PlayerController newPlayer = GameObject.FindWithTag("Player").GetComponent <PlayerController>();

            newPlayer.enabled = false;
            wrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayerLocation(otherPortal);
            wrapper.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeInTime));

            newPlayer.enabled = true;
            Destroy(gameObject);
        }
Ejemplo n.º 28
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("SceneToLoad not initialized");
                yield break;
            }

            Fader         fader         = FindObjectOfType <Fader>();
            SavingWrapper savingWrapper = FindObjectOfType <SavingWrapper>();

            DontDestroyOnLoad(this.gameObject);

            DisableControl(GameObject.FindWithTag("Player"));

            yield return(fader.FadeOut(fadeOutTime));

            savingWrapper.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad));

            DisableControl(GameObject.FindWithTag("Player"));

            savingWrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            savingWrapper.Save();


            yield return(new WaitForSeconds(waitTime));

            EnableControl(GameObject.FindWithTag("Player"));
            yield return(fader.FadeIn(fadeInTime));

            Destroy(this.gameObject);
        }
Ejemplo n.º 29
0
        private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("Scene to load is not set");
                yield break;
            }

            DontDestroyOnLoad(gameObject);
            // launch Fade out effect
            Fader fader = FindObjectOfType <Fader>();

            yield return(fader.FadeOut(fadeOutTime));

            // save current level
            SavingWrapper wrapper = FindObjectOfType <SavingWrapper>();

            wrapper.Save();


            // load the scene
            yield return(SceneManager.LoadSceneAsync(sceneToLoad));


            // Load current level
            wrapper.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            wrapper.Save();
            // launch Fade in effect
            yield return(new WaitForSeconds(fadeWaitTime));

            yield return(fader.FadeIn(fadeOutTime));

            Destroy(gameObject);
        }
Ejemplo n.º 30
0
        private IEnumerator Transition()
        {
            if (sceneToLoad == null)
            {
                Debug.LogError("Scene does not exist!");
                yield break;
            }
            DontDestroyOnLoad(gameObject);

            Fader fader = FindObjectOfType <Fader>();

            GetPlayerControllerComponent();
            playerController.enabled = false;
            yield return(fader.FadeOut(fadeOutTime));

            SavingWrapper saveWrap = FindObjectOfType <SavingWrapper>();

            saveWrap.Save();

            yield return(SceneManager.LoadSceneAsync(sceneToLoad.name));

            GetPlayerControllerComponent();
            playerController.enabled = false;

            saveWrap.Load();

            Portal otherPortal = GetOtherPortal();

            UpdatePlayer(otherPortal);

            saveWrap.Save();

            yield return(new WaitForSeconds(fadeWaitTime));

            fader.FadeIn(fadeInTime);

            playerController.enabled = true;
            Destroy(gameObject);
        }