Exemplo n.º 1
0
        /// <summary>
        /// Retrieves the first scene that is considered a valid transition
        /// </summary>
        /// <param name="sceneManager">The collection of variables and scenes to be processed</param>
        /// <returns>The scene model of the first passing transition, or null if none pass</returns>
        public SceneModel GetFirstPassingTransition(SceneManagerController sceneManager)
        {
            foreach (SceneTransition transition in Transitions)
            {
                if (transition.IsMuted)
                {
                    continue;
                }

                SceneModel destScene = sceneManager.GetSceneById(transition.DestinationSceneId);

                if (destScene == null)
                {
                    Debug.LogError("Scene Index of " + transition.DestinationSceneId + " not found. Skipping transition");
                    continue;
                }

                if (!destScene.IsUnlocked)
                {
                    continue;
                }

                if (transition.CanTransition(sceneManager))
                {
                    return(destScene);
                }
            }

            return(null);
        }
        public void PopulateSceneInfos()
        {
            if (sceneNodes == null)
            {
                return;
            }

            foreach (SceneNode node in sceneNodes)
            {
                if (node.SceneId == SceneManagerController.ANY_SCENE_ID)
                {
                    node.SceneInfo = SceneManager.AnyScene;
                }
                else
                {
                    node.SceneInfo = SceneManager.GetSceneById(node.SceneId);
                }
            }
        }
        /// <summary>
        /// Determines if the transition to the destination scene is valid
        /// </summary>
        /// <param name="manager">The manager containing all of the variables to be evaluated</param>
        /// <returns>True if a transition can be performed, false if not
        /// Also returns false if DestinationScene is null</returns>
        public bool CanTransition(SceneManagerController manager)
        {
            SceneModel destinationScene = manager.GetSceneById(destinationSceneId);

            if (destinationScene == null)
            {
                return(false);
            }

            bool evaluation = true;

            foreach (SceneCondition condition in Conditions)
            {
                evaluation = condition.IsMet(manager);

                if (!evaluation)
                {
                    break;
                }
            }

            return(evaluation);
        }