Пример #1
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;
                }
            }
        }
Пример #2
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;
             }
         }
     }
 }
Пример #3
0
 private void UpdateActivationOfPOIs(SceneTransition scene, bool isEnabled)
 {
     if (scene)
     {
         PointOfInterest[] allPOIS = scene.GetComponentsInChildren <PointOfInterest>();
         foreach (var item in allPOIS)
         {
             item.enabled = isEnabled;
         }
     }
 }
Пример #4
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);
        }
Пример #5
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);
        }