Exemple #1
0
    /// <summary>
    /// Begins the tether back sequence, skipping the tether menu animation part of the coroutine
    /// Essentially the same as OnTetherGameplayButtonClick(int stateToLoad), but repurposed for tapping the tether menu key instead of pressing a tether button in the bottom left UI
    /// </summary>
    void OnFastTetherStart(int stateToLoad)
    {
        if (tetherUIState != TetherUIState.GAMEPLAY)
        {
            Debug.LogError("Shouldn't be able to fast load tether point when not in TetherUIState.GAMEPLAY. Currently in TetherUIState." + tetherUIState);
            return;
        }

        tetherUIState = TetherUIState.TETHER_ANIMATION;
        //GameManager.setPause(true);
        GameManager.inst.ExitPauseState();
        GameManager.inst.EnterPauseState(PauseType.TETHER_TRANSITION);
        CursorManager.inst.lockCursorType = true;
        CursorManager.inst.cursorState    = CursorState.DEACTIVATED;

        // Start the animation coroutine that jumps directly into the tether animation code
        StartCoroutine("TetherBackAnimation", stateToLoad);
    }
Exemple #2
0
    /// <summary>
    /// Tether Button click for tether buttons in pop up menu
    /// </summary>
    /// <param name="stateToLoad">LevelStateManager state to load, starting at 0.</param>
    public void OnTetherMenuButtonClick(int stateToLoad)
    {
        if (tetherUIState != TetherUIState.TETHER_MENU)
        {
            Debug.LogError("Shouldn't be able to click menu tether button when not in TetherUIState.TETHER_MENU. Currently in TetherUIState." + tetherUIState);
            return;
        }
        AudioLibrary.PlayTetherSelect();
        tetherUIState = TetherUIState.TETHER_ANIMATION;
        //GameManager.setPause(true);
        GameManager.inst.ExitPauseState();
        GameManager.inst.EnterPauseState(PauseType.TETHER_TRANSITION);
        CursorManager.inst.lockCursorType = true;
        CursorManager.inst.cursorState    = CursorState.DEACTIVATED;

        // Start the animation coroutine that begins with the hide menu code
        StartCoroutine("TetherBackAnimation_HideMenu", stateToLoad);
    }
Exemple #3
0
    IEnumerator TetherBackAnimation(int stateToLoad)
    {
        //Debug.Log("TetherBackAnimation coroutine started");

        // The tether menu should be gone by this point

        // Make Margot play her tether animation
        // start animation
        playerScript.PlayTetherAnimation();
        AudioLibrary.PlayTetherRewindSound();

        // Play ripple out particle effect
        ParticleSystem ripples = Instantiate(Resources.Load("Prefabs/ParticlesRippleOut") as GameObject, GameManager.GetPlayer().transform).GetComponent <ParticleSystem>();

        ripples.transform.position = GameManager.GetPlayer().transform.position;
        ripples.Play();

        // Temporary way of delaying; should eventually have the animation controller tell this script that Margot's animation has finished
        yield return(new WaitForSeconds(0.5f));

        /*
         *      while (false)
         *      {
         *              //  Wait for Margot's animation to finish
         *              yield return null;
         *      }
         */

        // Next, start two simultaneous actions
        //  (1) Make the screen transition play
        tetherTransition.SetFadeOut();
        tetherShaderTransition.SetFadeOut();

        //	(2) Make the timeline arrow move directly above the previous tether point
        SetArrowTarget(stateToLoad, false, false);

        while (!ArrowReachedTarget() || tetherTransition.TransitionInProgress())
        {
            // Wait for both conditions to finish
            yield return(null);
        }

        Destroy(ripples.gameObject);

        // Load the desired state via LevelStateManager
        LoadTetherPoint(stateToLoad);
        //RemoveTimeTetherIndicator(stateToLoad + 1);
        //LevelStateManager.loadTetherPoint(stateToLoad);

        // How long to wait on the black screen
        yield return(new WaitForSeconds(0.3f));

        // Now that the state has been loaded, make the transition fade back in
        playerScript.PlayReappearAnimation();
        yield return(new WaitForSeconds(0.1f));

        tetherTransition.SetFadeIn();
        tetherShaderTransition.SetFadeIn();

        // Play ripple in particle effect
        ripples = Instantiate(Resources.Load("Prefabs/ParticlesRippleIn") as GameObject, GameManager.GetPlayer().transform).GetComponent <ParticleSystem>();
        ripples.transform.position = GameManager.GetPlayer().transform.position;
        ripples.Play();

        while (tetherTransition.TransitionInProgress())
        {
            // Wait for the transition in to finish
            yield return(null);
        }

        // When the transition is done, start these simultaneous actions
        //  (1) Make Margot play her appear animation

        ripples.enableEmission = false;

        yield return(new WaitForSeconds(0.2f));

        //	(2) Move the timeline arrow to the middle position in front of the tether point we just reverted to
        SetArrowTarget(stateToLoad, true, false);

        // TODO need compound boolean
        while (!ArrowReachedTarget())
        {
            // Wait for both conditions to finish
            yield return(null);
        }

        yield return(new WaitForSeconds(0.5f));

        Destroy(ripples.gameObject);

        // Now that the process has finished, restore control to the player
        // TODO
        tetherUIState = TetherUIState.GAMEPLAY;
        //GameManager.setPause(false);
        GameManager.inst.ExitPauseState();
        CursorManager.inst.lockCursorType = false;
        CursorManager.inst.OnCursorBoundsUpdated();
    }
Exemple #4
0
    void Update()
    {
        /*
         * Create tether point functionality
         */

        // Creating a tether point
        if (tetherUIState == TetherUIState.GAMEPLAY && !GameManager.isPlayerDead() && !GameManager.CameraIsZoomedOut() && GameManager.inst.pauseType == PauseType.NONE && !GameManager.isPlayerDashing() && !GameManager.GetPlayerScript().inPlaceTetherAnim())
        {
            if (PlayerControlManager.GetKeyDown(ControlInput.DROP_TETHER))
            {
                //CreatePoint();
                //GameManager.GetPlayer().GetComponent<Player>().setPlaceAnchorAnim();

                // Order flipped so the tether point exists for the screenshot
                // Test!
                CreatePoint();
            }
        }


        /*
         * Fast tethering functionality
         */

        // Keep track of the fast tether back key
        if (allowFastTether)
        {
            // These conditions determine whether tethering is allowed
            if (tetherUIState == TetherUIState.GAMEPLAY && !GameManager.isPlayerDead() && !GameManager.CameraIsZoomedOut() && !GameManager.isPlayerDashing() && !GameManager.isPaused())
            {
                // If the player presses the menu key, start the timer
                //if (Input.GetKeyDown(PlayerControlManager.LH_TetherMenu) || Input.GetKeyDown(PlayerControlManager.RH_TetherMenu))
                if (PlayerControlManager.GetKeyDown(ControlInput.TETHER_MENU))
                {
                    fastTetherKeyTimer = fastTetherKeyTime;
                }

                // If the menu button is released before the timer has reached zero, call a fast tether back
                //if (Input.GetKeyUp(PlayerControlManager.LH_TetherMenu) || Input.GetKeyUp(PlayerControlManager.RH_TetherMenu))
                if (PlayerControlManager.GetKeyUp(ControlInput.TETHER_MENU))
                {
                    OnFastTetherStart(LevelStateManager.curState);
                }
            }
        }
        else
        {
            fastTetherKeyTimer = 0;
        }

        // Update fastTetherKeyTimer
        if (fastTetherKeyTimer > 0)
        {
            fastTetherKeyTimer -= Time.deltaTime;
            if (fastTetherKeyTimer < 0)
            {
                fastTetherKeyTimer = 0;
            }
        }


        /*
         * Tether menu functionality
         */

        // Bringing up the tether menu
        // Adding the pause menu active check prevents the cursor from getting reverted to the gameplay cursor while the pause menu is up
        if ((tetherUIState == TetherUIState.GAMEPLAY || tetherUIState == TetherUIState.TETHER_MENU) && !PauseMenuManager.pauseMenuActive)
        {
            // Test for bringing up the menu, while alive
            if (!GameManager.isPlayerDead())
            {
                // If the tether menu key is held down
                //if (PlayerControlManager.GetKey(ControlInput.TETHER_MENU) && !GameManager.CameraIsZoomedOut() && fastTetherKeyTimer <= 0 && !GameManager.isPlayerDashing())
                if (PlayerControlManager.GetKey(ControlInput.TETHER_MENU) && fastTetherKeyTimer <= 0 && tetherMenuDisableTimer == 0 && !GameManager.isPlayerDashing() && (GameManager.inst.pauseType == PauseType.NONE || GameManager.inst.pauseType == PauseType.TETHER_MENU))
                {
                    tetherUIState = TetherUIState.TETHER_MENU;
                    //GameManager.setPause(true);
                    if (GameManager.inst.pauseType == PauseType.NONE)
                    {
                        GameManager.inst.EnterPauseState(PauseType.TETHER_MENU);
                    }

                    CursorManager.inst.lockCursorType = true;
                    CursorManager.inst.cursorState    = CursorState.MENU;
                    ShowTetherMenu();
                }
                else
                {
                    tetherUIState = TetherUIState.GAMEPLAY;

                    //GameManager.setPause(false);
                    if (GameManager.inst.pauseType == PauseType.TETHER_MENU)
                    {
                        GameManager.inst.ExitPauseState();
                        //Debug.Log("ExitPauseState()");
                    }

                    CursorManager.inst.lockCursorType = false;
                    CursorManager.inst.OnCursorBoundsUpdated();
                    HideTetherMenu();
                }
            }
            // If the player is dead, force the menu to come up
            else
            {
                tetherUIState = TetherUIState.TETHER_MENU;
                //GameManager.setPause(true);
                GameManager.inst.EnterPauseState(PauseType.TETHER_MENU);
                CursorManager.inst.lockCursorType = true;
                CursorManager.inst.cursorState    = CursorState.MENU;
                ShowTetherMenu();
            }
        }

        /*
         * Tether Corner HUD visibility
         */

        if (tetherHUDVisible)
        {
            tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 1, tetherHUDFadeInSpeed * Time.deltaTime);
        }
        else
        {
            tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 0, tetherHUDFadeOutSpeed * Time.deltaTime);
        }

        /*
         * Tether Corner HUD fading when zooming out
         */

        // When zooming/zoomed out, hide the bottom left time tether HUD
        // JK let's not do this

        /*
         * if (GameManager.CameraIsZoomedOut())
         * {
         * tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 0, tetherHUDFadeOutSpeed * Time.deltaTime);
         * }
         * // When zooming back in or not zoomed, reveal the bottom left time tether HUD
         * else
         * {
         * tetherHUDGroup.alpha = Mathf.Lerp(tetherHUDGroup.alpha, 1, tetherHUDFadeInSpeed * Time.deltaTime);
         * }
         */


        /*
         * Other Update Stuff
         */

        UpdateTimeArrowPos();
        //ScreenshotManager.inst.UpdateScreenshotState();

        if (tetherUIState == TetherUIState.TETHER_MENU)
        {
            if (menuLight != null && menuLightOn != null)
            {
                menuLight.sprite = menuLightOn;
            }
        }
        else
        {
            if (menuLight != null && menuLightOff != null)
            {
                menuLight.sprite = menuLightOff;
            }
        }


        // End level tether point collection
        // Once all indicator return objects have returned to the player and been destroyed, this will allow EndLevelAllTetherPointdCollected to return true
        if (endLevelWaitForCollection)
        {
            if (IndicatorReturnObject.NoInstancesExist())
            {
                endLevelWaitForCollection = false;
            }
        }

        if (tetherMenuDisableTimer > 0)
        {
            tetherMenuDisableTimer -= Time.deltaTime;
            if (tetherMenuDisableTimer < 0)
            {
                // Don't allow the timer to reach 0 until the tether menu key has been released
                if (PlayerControlManager.GetKey(ControlInput.TETHER_MENU))
                {
                    tetherMenuDisableTimer = 0.1f;
                }
                else
                {
                    tetherMenuDisableTimer = 0f;
                }
            }
        }
    }