Esempio n. 1
0
 // When transition starts, the animator that rotates the POIs need to be deactivated as it changes their position
 private void SetActivePOIRotationAnimator(bool isActive, SceneTransition previousTransition, SceneTransition nextTransition)
 {
     if (previousTransition && previousTransition.gameObject.scene.name == "galaxy_view_scene")
     {
         Animator[] allAnimators = previousTransition.GetComponentsInChildren <Animator>();
         foreach (var animator in allAnimators)
         {
             if (animator.runtimeAnimatorController && animator.runtimeAnimatorController.name.Contains("pois_root_rotation_animator"))
             {
                 animator.enabled = isActive;
                 //Debug.Log("Change activation of POIRotation animation to " + isActive);
                 break;
             }
         }
     }
     else if (nextTransition && nextTransition.gameObject.scene.name == "galaxy_view_scene")
     {
         Animator[] allAnimators = nextTransition.GetComponentsInChildren <Animator>();
         foreach (var animator in allAnimators)
         {
             if (animator.runtimeAnimatorController && animator.runtimeAnimatorController.name.Contains("pois_root_rotation_animator"))
             {
                 animator.enabled = isActive;
                 //Debug.Log("Change activation of POIRotation animation to " + isActive);
                 break;
             }
         }
     }
 }
Esempio n. 2
0
        private void DeactivateOrbitUpdater(SceneTransition newTransition, SceneTransition previousTransition, bool isActive)
        {
            // If going into a single planet then deactivate the previous scene's planet rotation script
            // in order to stop the previous planet moving
            if (newTransition && newTransition.IsSinglePlanetTransition)
            {
                GameObject singlePlanet  = null;
                GameObject relatedPlanet = null;
                GetRelatedPlanets(out relatedPlanet, out singlePlanet);

                if (relatedPlanet && relatedPlanet.GetComponentInChildren <OrbitUpdater>())
                {
                    relatedPlanet.GetComponentInChildren <OrbitUpdater>().enabled = isActive;
                }
                else if (relatedPlanet && relatedPlanet.transform.parent.GetComponent <OrbitUpdater>())
                {
                    relatedPlanet.transform.parent.GetComponent <OrbitUpdater>().enabled = isActive;
                }
            }
            else if (previousTransition && previousTransition.IsSinglePlanetTransition)
            {
                GameObject singlePlanet  = null;
                GameObject relatedPlanet = null;
                GetRelatedPlanets(out relatedPlanet, out singlePlanet);

                if (relatedPlanet && relatedPlanet.GetComponentInChildren <OrbitUpdater>())
                {
                    relatedPlanet.GetComponentInChildren <OrbitUpdater>().enabled = isActive;
                }
                else if (relatedPlanet && relatedPlanet.transform.parent.GetComponent <OrbitUpdater>())
                {
                    relatedPlanet.transform.parent.GetComponent <OrbitUpdater>().enabled = isActive;
                }
            }
        }
Esempio n. 3
0
 private void UpdateActivationOfPOIs(SceneTransition scene, bool isEnabled)
 {
     if (scene)
     {
         PointOfInterest[] allPOIS = scene.GetComponentsInChildren <PointOfInterest>();
         foreach (var item in allPOIS)
         {
             item.enabled = isEnabled;
         }
     }
 }
        private void UpdateShaderProperties()
        {
            GameObject currentContent = GalaxyExplorerManager.Instance.TransitionManager.CurrentActiveScene;

            if (currentContent)
            {
                SceneTransition sceneSizer = currentContent.GetComponent <SceneTransition>();
                if (sceneSizer)
                {
                    float    scalar    = sceneSizer.GetScalar();
                    Vector3  contentWP = currentContent.transform.position;
                    Renderer renderer  = GetComponentInChildren <Renderer>();
                    if (renderer)
                    {
                        Material mat = renderer.sharedMaterial;
                        if (mat)
                        {
                            mat.SetFloat("_ContentRadius", scalar);
                            mat.SetVector("_ContentWorldPos", contentWP);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        public IEnumerator ZoomInOutInitialization(GameObject newScene, GameObject prevSceneLoaded)
        {
            if (prevSceneLoaded == null)
            {
                yield break;
            }
            else
            {
                SceneTransition previousTransition = prevSceneLoaded.GetComponentInChildren <SceneTransition>();
                PreviousScene = previousTransition.ThisSceneObject.transform;
                PreviousSceneFocusCollider = previousTransition.ThisSceneFocusCollider;

                SceneTransition newTransition = newScene.GetComponentInChildren <SceneTransition>();
                NextScene = newTransition.ThisSceneObject.transform;
                NextSceneFocusCollider = newTransition.ThisSceneFocusCollider;

                // if new scene is a single planet, select the planet in previous scene that loaded the next scene
                if (newTransition.IsSinglePlanetTransition)
                {
                    GameObject singlePlanet  = null;
                    GameObject relatedPlanet = null;
                    GetRelatedPlanets(out relatedPlanet, out singlePlanet);

                    PreviousSceneFocusCollider = relatedPlanet.GetComponentInChildren <SphereCollider>();
                }
                // if previous scene is a single planet then select the planet in next scene that loades this single planet scene
                else if (previousTransition.IsSinglePlanetTransition)
                {
                    GameObject singlePlanet  = null;
                    GameObject relatedPlanet = null;
                    GetRelatedPlanets(out relatedPlanet, out singlePlanet);

                    NextSceneFocusCollider = relatedPlanet.GetComponentInChildren <SphereCollider>();
                }
                // if transition is from galaxy to solar system, galaxy to galactiv center and back
                else
                {
                    GameObject previousPlanetPOI = null;
                    GameObject nextPlanetPOI     = null;
                    GetRelatedScenes(out previousPlanetPOI, out nextPlanetPOI, previousTransition, newTransition);

                    PreviousSceneFocusCollider = (previousPlanetPOI) ? previousPlanetPOI.GetComponentInChildren <SphereCollider>() : PreviousSceneFocusCollider;
                    NextSceneFocusCollider     = (nextPlanetPOI) ? nextPlanetPOI.GetComponentInChildren <SphereCollider>() : NextSceneFocusCollider;
                }

                previousFocusInitialScale = PreviousSceneFocusCollider.radius * PreviousSceneFocusCollider.transform.lossyScale.x;
                previousSceneInitialScale = PreviousScene.localScale.x;
                nextFocusInitialScale     = NextSceneFocusCollider.radius * NextSceneFocusCollider.transform.lossyScale.x;
                nextSceneInitialScale     = NextScene.localScale.x;

                nextSceneInitialPosition     = PreviousSceneFocusCollider.transform.position;
                previousSceneInitialPosition = PreviousScene.transform.position;

                previousSceneRotation    = PreviousScene.transform.rotation;
                nextSceneInitialRotation = NextScene.rotation;

                // Should take into account any other parent with rotation
                // previous scene final rotation should be equal to x, and that x makes the previous focus collider rotatio ssame as the initial next focus collider rotation
                // so from the rotation of next focus collider need to remove the rotation of the previous focus collider but without taking nto accont the top parent that we manipulate
                previousSceneDiffRotation = NextSceneFocusCollider.transform.rotation * Quaternion.Inverse(GetRotation(PreviousSceneFocusCollider.gameObject, PreviousScene.gameObject));

                // we want the previous focus collider rotation to much the next focus collider rotation
                // the parent of the next scene should have a rotation that results to the desired next focus collider rotation
                // the next scene's rotations that matter are all parents and focus except the top parent which is the one that we manipulate.
                nextInitQuaternion = PreviousSceneFocusCollider.transform.rotation * Quaternion.Inverse(GetRotation(NextSceneFocusCollider.gameObject, NextScene.gameObject));

                // next scene focus displacement
                nextSceneDisplacement = NextSceneFocusCollider.transform.position - NextScene.position;
                nextSceneDisplacement = Quaternion.Inverse(NextSceneFocusCollider.transform.parent.rotation) * nextSceneDisplacement;

                scalar = nextFocusInitialScale / previousFocusInitialScale;
            }

            yield return(null);
        }
Esempio n. 6
0
        // During transition that doesnt involve single planet so during transition from galaxy to solar or to galactic center
        // we need to identify the poi that spawned the next scene or if going backwards the poi that we are going into
        private void GetRelatedScenes(out GameObject previousRelatedPlanetObjectt, out GameObject nextRelatedPlanetObjectt, SceneTransition previousScene, SceneTransition newScene)
        {
            previousRelatedPlanetObjectt = null;
            nextRelatedPlanetObjectt     = null;

            // If a planet of the previous scene loads the new scene then this is the previous focus collider
            PlanetPOI[] allPreviousPlanets = previousScene.GetComponentsInChildren <PlanetPOI>();
            foreach (var planet in allPreviousPlanets)
            {
                if (planet && planet.GetSceneToLoad == newScene.gameObject.scene.name)
                {
                    previousRelatedPlanetObjectt = planet.PlanetObject;
                    break;
                }
            }

            // If a planet of the previous scene loads the new scene then this is the previous focus collider
            PlanetPOI[] allNewPlanets = newScene.GetComponentsInChildren <PlanetPOI>();
            foreach (var planet in allNewPlanets)
            {
                if (planet && planet.GetSceneToLoad == previousScene.gameObject.scene.name)
                {
                    nextRelatedPlanetObjectt = planet.PlanetObject;
                    break;
                }
            }
        }
Esempio n. 7
0
        // Light transition is necessary in case of Simultaneous transitions in order for sun light position to be the same and transition to look good
        private IEnumerator LightTransitions(SceneTransition previousTransition, SceneTransition newTransition)
        {
            if (previousTransition == null || newTransition == null)
            {
                yield break;
            }

            GameObject singlePlanet  = null;
            GameObject relatedPlanet = null;

            GetRelatedPlanets(out relatedPlanet, out singlePlanet);

            // if next scene is a planet then position its light to where sun of previous scene is and move it towards its initial position
            if (newTransition && newTransition.IsSinglePlanetTransition)
            {
                SunLightReceiver sunLight    = newTransition.GetComponentInChildren <SunLightReceiver>();
                Transform        previousSun = FindByName(previousTransition.transform, "Sun");
                //previousTransition.transform.Find("Sun");
                Vector3 initialSunPosition = Vector3.zero;
                if (sunLight && sunLight.Sun && previousSun)
                {
                    initialSunPosition = sunLight.Sun.transform.localPosition;
                    sunLight.Sun.transform.position = singlePlanet.transform.position - (relatedPlanet.transform.position - previousSun.position);

                    float delta = 0.0f;
                    do
                    {
                        delta += Time.deltaTime / TransitionTimeOpeningScene;
                        delta  = Mathf.Clamp(delta, 0.0f, 1.0f);
                        sunLight.Sun.transform.localPosition = Vector3.Lerp(sunLight.Sun.transform.localPosition, initialSunPosition, delta);
                        yield return(null);
                    } while (delta < 1.0f);
                }
            }
            // in case of previous scene is a single planet scene, find the new scene related planet's SunLightReceivers
            // and replace their sun to a new gameobject pretending to be a sun. This sun;s starting position is
            // same as the old scene's sun position and transition to new sun's position
            else if (previousTransition && previousTransition.IsSinglePlanetTransition)
            {
                SunLightReceiver[] allLightReceivers = relatedPlanet.GetComponentsInChildren <SunLightReceiver>();
                Transform          newSun            = FindByName(newTransition.transform, "Sun");
                if (allLightReceivers.Length > 0 && newSun)
                {
                    GameObject lightPlaceholder = new GameObject();
                    lightPlaceholder.transform.parent = newTransition.ThisSceneObject.transform;

                    // Old scene's light position
                    SunLightReceiver oldLight = previousTransition.GetComponentInChildren <SunLightReceiver>();
                    lightPlaceholder.transform.position = (oldLight && oldLight.Sun) ? oldLight.Sun.transform.position : Vector3.zero;

                    // Replace sun to the placeholder object
                    foreach (var light in allLightReceivers)
                    {
                        light.Sun = lightPlaceholder.transform;
                    }

                    // Move placeholder light position towards sun's position
                    float delta = 0.0f;
                    do
                    {
                        delta += Time.deltaTime / TransitionTimeOpeningScene;
                        delta  = Mathf.Clamp(delta, 0.0f, 1.0f);
                        lightPlaceholder.transform.position = Vector3.Lerp(lightPlaceholder.transform.position, newSun.transform.position, delta);
                        yield return(null);
                    } while (delta < 1.0f);

                    Destroy(lightPlaceholder);
                }
            }
        }
Esempio n. 8
0
        // Flow of transition when previous and new scenes zoom in and out at the same time e.g when going to a planet or when leaving a planet
        private IEnumerator ZoomInOutSimultaneouslyFlow(SceneTransition previousTransition, SceneTransition newTransition)
        {
            GameObject singlePlanet  = null;
            GameObject relatedPlanet = null;

            GetRelatedPlanets(out relatedPlanet, out singlePlanet);

            // In previous scene, fade out pois and then fade the rest of the scene
            if (previousTransition)
            {
                if (introStage == IntroStage.kInactiveIntro)
                {
                    isFading = true;
                    GalaxyExplorerManager.Instance.GeFadeManager.Fade(previousTransition.GetComponentInChildren <POIMaterialsFader>(), GEFadeManager.FadeType.FadeOut, PoiFadeOutDuration, POIOpacityCurveStartTransition);
                    while (isFading)
                    {
                        yield return(null);
                    }
                }

                isFading = true;
                float fadeTime = GetClosingSceneVisibilityTime();
                GalaxyExplorerManager.Instance.GeFadeManager.FadeExcept(previousTransition.GetComponentsInChildren <Fader>(), typeof(POIMaterialsFader), null, GEFadeManager.FadeType.FadeOut, fadeTime, OpacityCurveClosingScene);
            }

            PlayTransitionAudio(newTransition.transform, inForwardTransition);

            // Make invisible one of the two planets that represent the same entity in both scenes
            if (relatedPlanet && singlePlanet)
            {
                SetRenderersVisibility(newTransition.IsSinglePlanetTransition ? relatedPlanet.transform.parent.gameObject : singlePlanet.transform.parent.gameObject, false);
            }

            // make alpha of pois of next scene equal to zero so they arent visible
            GalaxyExplorerManager.Instance.GeFadeManager.SetAlphaOnFader(newTransition.GetComponentInChildren <POIMaterialsFader>(), 0.0f);
            var faderToExclude = default(Fader);

            // if going back to solar system from a planet then fade in solar system
            // Dont fade the material of the selected/related planet in the next scene or any poi
            if (previousTransition && previousTransition.IsSinglePlanetTransition)
            {
                Fader[] allFaders = newTransition.GetComponentsInChildren <Fader>();
                GalaxyExplorerManager.Instance.GeFadeManager.SetAlphaOnFaderExcept(allFaders, typeof(POIMaterialsFader), 0.0f);

                if (relatedPlanet)
                {
                    GalaxyExplorerManager.Instance.GeFadeManager.SetAlphaOnFader(relatedPlanet.GetComponent <Fader>(), 1.0f);
                }

                isFading = true;
                AnimationCurve opacityCurve = newTransition.gameObject.name.Contains("solar_system") ? PlanetToSSTransitionOpacityCurveContentChange : OpacityCurveEnteringScene;
                GalaxyExplorerManager.Instance.GeFadeManager.FadeExcept(allFaders, typeof(POIMaterialsFader), relatedPlanet, GEFadeManager.FadeType.FadeIn, TransitionTimeOpeningScene, opacityCurve);
            }
            else if ((previousTransition && !previousTransition.IsSinglePlanetTransition && newTransition && !newTransition.IsSinglePlanetTransition))
            {
                if (newTransition.gameObject.name.Contains("SolarSystem"))
                {
                    var sun      = GameObject.Find("poi_sun_prefab");
                    var sunFader = sun.GetComponentInChildren <Fader>(true);
                    faderToExclude = sunFader;
                }
                Fader[] allFaders = newTransition.GetComponentsInChildren <Fader>();
                GalaxyExplorerManager.Instance.GeFadeManager.SetAlphaOnFaderExcept(allFaders, typeof(POIMaterialsFader), 0.0f);
                allFaders = allFaders.Where(f => f != faderToExclude).ToArray();

                isFading = true;
                GalaxyExplorerManager.Instance.GeFadeManager.FadeExcept(allFaders, typeof(POIMaterialsFader), null, GEFadeManager.FadeType.FadeIn, TransitionTimeOpeningScene, OpacityCurveEnteringScene);
                GalaxyExplorerManager.Instance.GeFadeManager.Fade(faderToExclude, GEFadeManager.FadeType.FadeIn, 1, POIOpacityCurveStartTransition, 3f);
            }

            if (newTransition.gameObject.scene.name.Contains("galaxy_view_scene"))
            {
                StartCoroutine(ZoomInOutBehaviour.ZoomInOutCoroutine(TransitionTimeOpeningScene, GetContentTransitionCurve(newTransition.gameObject.scene.name), GetContentRotationCurve(newTransition.gameObject.scene.name), GetContentTransitionCurve(newTransition.gameObject.scene.name), BackToGalaxyPositionTransitionCurveContentChange, offset: newTransition.scenePositionOffset));
            }
            else if (previousTransition && previousTransition.IsSinglePlanetTransition)
            {
                StartCoroutine(ZoomInOutBehaviour.ZoomInOutCoroutine(TransitionTimeOpeningScene, GetContentTransitionCurve(newTransition.gameObject.scene.name), GetContentRotationCurve(newTransition.gameObject.scene.name), PlanetToSSScaleCurveContentChange, offset: newTransition.scenePositionOffset));
            }
            else
            {
                StartCoroutine(ZoomInOutBehaviour.ZoomInOutCoroutine(TransitionTimeOpeningScene, GetContentTransitionCurve(newTransition.gameObject.scene.name), GetContentRotationCurve(newTransition.gameObject.scene.name), GetContentTransitionCurve(newTransition.gameObject.scene.name), offset: newTransition.scenePositionOffset));
            }

            StartCoroutine(LightTransitions(previousTransition, newTransition));

            yield return(null);
        }
Esempio n. 9
0
        /// <summary>
        /// Callback when next scene is loaded
        /// Has the logic of the flow related to previous and next scene
        /// </summary>
        private IEnumerator NextSceneLoadedCoroutine()
        {
            GameObject nextSceneContent = FindContent();

            ZoomInOutBehaviour.ZoomInIsDone  = false;
            ZoomInOutBehaviour.ZoomOutIsDone = false;

            SceneTransition previousTransition = (prevSceneLoaded) ? prevSceneLoaded.GetComponentInChildren <SceneTransition>() : null;
            SceneTransition newTransition      = nextSceneContent.GetComponentInChildren <SceneTransition>();

            CurrentActiveScene = nextSceneContent;

            SetActivationOfTouchscript(false);
            DeactivateOrbitUpdater(newTransition, previousTransition, false);
            SetActivePOIRotationAnimator(false, previousTransition, newTransition);
            UpdateActivationOfPOIs(newTransition, false);
            UpdateActivationOfPOIs(previousTransition, false);

            // Scale new scene to fit inside the volume
            float scaleToFill = transformSource.transform.lossyScale.x;
            float targetSize  = newTransition.GetScalar(scaleToFill);

            newTransition.transform.GetChild(0).localScale = Vector3.one * targetSize;

            // Initialize zoom in and out transition properties
            StartCoroutine(ZoomInOutBehaviour.ZoomInOutInitialization(nextSceneContent, prevSceneLoaded));

            // In order for the next scene not being visible while the previous is fading, set scale to zero and deactivate all its colliders
            if (ZoomInOutBehaviour.GetNextScene)
            {
                ZoomInOutBehaviour.GetNextScene.transform.localScale = Vector3.zero;
                SetCollidersActivation(ZoomInOutBehaviour.GetNextScene.GetComponentsInChildren <Collider>(), false);
            }

            // Deactivate previous scene's colliders
            if (previousTransition)
            {
                SetCollidersActivation(previousTransition.GetComponentsInChildren <Collider>(), false);
            }

            yield return(new WaitForEndOfFrame());

            StartCoroutine(ZoomInOutSimultaneouslyFlow(previousTransition, newTransition));

            // wait until prev scene transition finishes
            while (!ZoomInOutBehaviour.ZoomOutIsDone)
            {
                yield return(null);
            }

            DeactivateOrbitUpdater(newTransition, previousTransition, true);
            UpdateActivationOfPOIs(newTransition, true);

            // Unload previous scene
            if (prevSceneLoaded != null)
            {
                UnloadScene(prevSceneLoaded.scene.name, true);
            }

            // Wait until next scene transition is done
            while (!ZoomInOutBehaviour.ZoomInIsDone)
            {
                yield return(null);
            }

            SetActivePOIRotationAnimator(true, previousTransition, newTransition);

            // Fade in pois of next scene
            if (introStage != IntroStage.kActiveIntro)
            {
                isFading = true;
                GalaxyExplorerManager.Instance.GeFadeManager.Fade(newTransition.GetComponentInChildren <POIMaterialsFader>(), GEFadeManager.FadeType.FadeIn, PoiFadeInDuration, POIOpacityCurveEndTransition);
            }

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

            yield return(new WaitForEndOfFrame());

            while (GalaxyExplorerManager.Instance.VoManager.ShouldAudioBlockProgress)
            {
                yield return(null);
            }

            // Activate colliders of next scene
            if (ZoomInOutBehaviour.GetNextScene && introStage != IntroStage.kActiveIntro)
            {
                SetCollidersActivation(ZoomInOutBehaviour.GetNextScene.GetComponentsInChildren <Collider>(), true);
            }

            SetActivationOfTouchscript(true);

            inTransition = false;
            introStage   = (introStage == IntroStage.kLastStageIntro) ? IntroStage.kInactiveIntro : introStage;

            yield return(null);
        }