public static void TransitionToScene(int sceneIndex, float duration = 0.7f)
    {
//        if (AudioControl.Instance != null)
//        {
//            AudioControl.Instance.PlaySound("change_scene");
//            Object value;
//            if (AudioControl.Instance.SoundClips.TryGetValue("change_scene", out value))
//            {
//                var audioLength = ((AudioClip) value).length;
//                duration = Math.Max(duration, audioLength);
//            }
//        }

        if (sceneIndex < 0)
        {
            Debug.LogError("Scene unknown!");
            return;
        }

        var transition = new Prime31.TransitionKit.FadeTransition()
        {
            nextScene   = sceneIndex,
            duration    = duration,
            fadeToColor = Color.black,
        };

        TransitionKit.instance.transitionWithDelegate(transition);
    }
Exemplo n.º 2
0
        /// <summary>
        /// World takes background action to change the background effects, the background is a child GameObject below the World GameObject
        /// </summary>
        /// <param name="backgroundAction">Action tagged as background, which contains the parameters for background setting</param>
        public void takeBackgroundAction(Action backgroundAction)
        {
            worldData.backgroundSrc = backgroundAction.parameters[ScriptKeyword.SRC];

            this.worldControl.GetComponent<WorldControl> ().DisablePlayerInput ();
            this.worldControl.GetComponent<WorldControl> ().hideInPlayUI ();

            string transitionValue;
            if (backgroundAction.parameters.TryGetValue (ScriptKeyword.TRANSITION, out transitionValue)) {
                string transitionTimeString;
                float transitionTime = 1f;
                if (backgroundAction.parameters.TryGetValue (ScriptKeyword.TIME, out transitionTimeString)) {
                    transitionTime = float.Parse (transitionTimeString);
                }
                //Debug.Log ("transitionTime="+transitionTime);
                switch(transitionValue){
                case ScriptKeyword.TRANSITION_INSTANT:
                    {
                        this.BackgroundTransitionOnScreenObscured ();
                        this.BackgroundTransitionComplete ();
                        break;
                    }
                case ScriptKeyword.TRANSITION_FADE:
                    {
                        var fader = new FadeTransition()
                        {
                            nextScene = -1,
                            fadedDelay = transitionTime,
                            fadeToColor = Color.black
                        };
                        TransitionKit.instance.transitionWithDelegate( fader );
                        break;
                    }
                }
            } else {
                var fader = new FadeTransition()
                {
                    nextScene = -1,
                    fadedDelay = 1f,
                    fadeToColor = Color.black
                };
                TransitionKit.instance.transitionWithDelegate( fader );
            }
        }