Ejemplo n.º 1
0
 void Awake()
 {
     instance     = this;
     currentState = splashScene;
     currentState.EnterState(this);
     Blackout.Instance.TargetBlackoutValue = 0;
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Transition to another state.  Re-entry IS permitted to allow for resetting state. Takes a transition color to control the fade color.  Optional parameter IDX allows for some flags to be passed to the state from the UI (for example entering a specific section of a state)
    /// </summary>
    public void StateTransition(DemoSceneState targetState, Color c, int idx = 0)
    {
        ///Make sure we aren't mid-transition - primarily because of graphical glitches
        if (!pendingTransition)
        {
            ///First we begein exiting the current state.
            currentState.BeginExitState(this);

            ///Update the target indices
            transitionIdx = idx;
            nextState     = targetState;

            ///we are transitioning, so yeah, flag that, too
            pendingTransition = true;

            ///start our fade to (color c)
            Blackout.Instance.SetColor(c);
            Blackout.Instance.TargetBlackoutValue = 1;

            ///start a timer to end the transition.  This used to wait on blackout, but that actually caused a seriously scary bug when there was a feature request to fade to black at other times.  You were able to start a transition, and get stuck - so instead we maintain our own separate timer.
            ///if the blackout speed changes later, this time will need to be adjusted.  Ideally, it should read from a public blackout time, or better yet - blackout could accept a transition speed variable - but that still can be risky for multiple entry on the blackout side
            transitionTimer = transitionTime;
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Transition to another state.  Re-entry IS permitted to allow for resetting state.  Optional parameter IDX allows for some flags to be passed to the state from the UI (for example entering a specific section of a state)
 /// </summary>
 public void StateTransition(DemoSceneState targetState, int idx = 0)
 {
     StateTransition(targetState, Color.white, idx);
 }
Ejemplo n.º 4
0
    ////activate blackout between scenes
    ///activate, deactivate, reset messages
    ///use onEnable, onDisable?
    //// need to know when we are ready to transition, maybe call a start cleanup, as fades begin



    void Update()
    {
        if (pendingTransition)
        {
            transitionTimer -= Time.deltaTime;

            ///To smoothly transition audio, we fade the listener down while transitioning
            AudioListener.volume = Mathf.Clamp01(transitionTimer / transitionTime);

            /// We're ready to actually transition - the screen should be 100% opaque (white, black, or some other color)
            if (transitionTimer <= 0)
            {
                /// WARNING - this was the previous way of handling this - but waiting on UI is bad practice, and it stayed in the code too long.  I leave this here as a reminder to whoever looks at this - please, don't wait on UI transitions that can be controlled from multiple sources
                //if(Blackout.Instance.BlackoutValue == 1){

                pendingTransition = false;

                /// Exit the current state
                currentState.ExitState(this);
                currentState = nextState;

                /// since the screen is opaque, we can rotate the entire scene so that forward is the direction the user is currently facing
                /// certain scenes may have orientation offsets based on the transition index (in the hike, certain nodes have you spawn at different angles)
                float orientationOffset = currentState.GetOrientationOffset(transitionIdx);
                currentState.OrientateScene(orientationOffset + VRInput.Instance.Yaw);                //+ VRInput.Instance.Yaw

                /// we're good to load up the next scene, at the correct angle
                currentState.EnterState(this, transitionIdx);

                /// if we have a spawn point, move the player there
                if (currentState.SpawnPoint != null)
                {
                    player.SetTarget(currentState.SpawnPoint);
                }

                /// start fading the scene back in
                currentState.ClearBlackout();
            }
        }
        else
        {
            ///To smoothly transition audio, we fade the listener back up
            if (AudioListener.volume < 1)
            {
                AudioListener.volume = Mathf.Clamp01(AudioListener.volume + 2 * Time.deltaTime);
            }
            //#if UNITY_EDITOR
            //StateTransitionDebug();

            //#endif
        }
        if (currentState != null)
        {
            currentState.DoUpdate(this);
        }

        if (Cardboard.SDK.BackButtonPressed)
        {
            Application.Quit();
        }
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Transition to another state.  Re-entry IS permitted to allow for resetting state.  Optional parameter IDX allows for some flags to be passed to the state from the UI (for example entering a specific section of a state)
 /// </summary>
 public void StateTransition(DemoSceneState targetState, int idx = 0)
 {
     StateTransition(targetState, Color.white, idx);
 }
Ejemplo n.º 6
0
    ////activate blackout between scenes
    ///activate, deactivate, reset messages
    ///use onEnable, onDisable?
    //// need to know when we are ready to transition, maybe call a start cleanup, as fades begin
    void Update()
    {
        if(pendingTransition){

            transitionTimer -= Time.deltaTime;

            ///To smoothly transition audio, we fade the listener down while transitioning
            AudioListener.volume = Mathf.Clamp01(transitionTimer / transitionTime);

            /// We're ready to actually transition - the screen should be 100% opaque (white, black, or some other color)
            if(transitionTimer <= 0){

            /// WARNING - this was the previous way of handling this - but waiting on UI is bad practice, and it stayed in the code too long.  I leave this here as a reminder to whoever looks at this - please, don't wait on UI transitions that can be controlled from multiple sources
            //if(Blackout.Instance.BlackoutValue == 1){

                pendingTransition = false;

                /// Exit the current state
                currentState.ExitState(this);
                currentState = nextState;

                /// since the screen is opaque, we can rotate the entire scene so that forward is the direction the user is currently facing
                /// certain scenes may have orientation offsets based on the transition index (in the hike, certain nodes have you spawn at different angles)
                float orientationOffset = currentState.GetOrientationOffset(transitionIdx);
                currentState.OrientateScene(orientationOffset + VRInput.Instance.Yaw);//+ VRInput.Instance.Yaw

                /// we're good to load up the next scene, at the correct angle
                currentState.EnterState(this, transitionIdx);

                /// if we have a spawn point, move the player there
                if(currentState.SpawnPoint != null){
                    player.SetTarget(currentState.SpawnPoint);
                }

                /// start fading the scene back in
                currentState.ClearBlackout();

            }
        }
        else{

            ///To smoothly transition audio, we fade the listener back up
            if(AudioListener.volume <1){
                AudioListener.volume = Mathf.Clamp01(AudioListener.volume + 2*Time.deltaTime);
            }
            //#if UNITY_EDITOR
                //StateTransitionDebug();

            //#endif
        }
        if(currentState != null){
            currentState.DoUpdate(this);
        }

        if(Cardboard.SDK.BackButtonPressed){
            Application.Quit ();
        }
    }
Ejemplo n.º 7
0
 void Awake()
 {
     instance = this;
     currentState = splashScene;
     currentState.EnterState(this);
     Blackout.Instance.TargetBlackoutValue = 0;
 }
Ejemplo n.º 8
0
    /// <summary>
    /// Transition to another state.  Re-entry IS permitted to allow for resetting state. Takes a transition color to control the fade color.  Optional parameter IDX allows for some flags to be passed to the state from the UI (for example entering a specific section of a state)
    /// </summary>
    public void StateTransition(DemoSceneState targetState,Color c, int idx = 0)
    {
        ///Make sure we aren't mid-transition - primarily because of graphical glitches
        if(!pendingTransition ){

            ///First we begein exiting the current state.
            currentState.BeginExitState(this);

            ///Update the target indices
            transitionIdx = idx;
            nextState = targetState;

            ///we are transitioning, so yeah, flag that, too
            pendingTransition = true;

            ///start our fade to (color c)
            Blackout.Instance.SetColor(c);
            Blackout.Instance.TargetBlackoutValue = 1;

            ///start a timer to end the transition.  This used to wait on blackout, but that actually caused a seriously scary bug when there was a feature request to fade to black at other times.  You were able to start a transition, and get stuck - so instead we maintain our own separate timer.
            ///if the blackout speed changes later, this time will need to be adjusted.  Ideally, it should read from a public blackout time, or better yet - blackout could accept a transition speed variable - but that still can be risky for multiple entry on the blackout side
            transitionTimer = transitionTime;

        }
    }