Beispiel #1
0
    void Update()
    {
        // Check for key input for bring up/hiding pause menu
        //if (PlayerControlManager.GetKeyDown(ControlInput.PAUSE_MENU) && TetherManager.PauseMenuAllowed() && !disablePauseMenu)
        if (PlayerControlManager.GetKeyDown(ControlInput.PAUSE_MENU) && !disablePauseMenu && !GameManager.CheckPause(check))
        {
            if (!m_pauseMenuActive)
            {
                EnablePauseMenu();
            }
            else
            {
                DisablePauseMenu();
            }
        }

        if (m_pauseMenuActive)
        {
            // Continuously fade menu in
            pauseCanvasGroup.alpha = Mathf.Lerp(pauseCanvasGroup.alpha, 1, menuFadeInSpeed * Time.deltaTime);
        }
        else
        {
            // Continuously fade menu out
            pauseCanvasGroup.alpha = Mathf.Lerp(pauseCanvasGroup.alpha, 0, menuFadeOutSpeed * Time.deltaTime);
        }
    }
Beispiel #2
0
    void UpdateTimers()
    {
        if (GameManager.CheckPause((int)PauseType.GAME) || GameManager.CheckPause((int)PauseType.TETHER_MENU))
        {
            return;
        }
        bool playerFrozen = false;

        foreach (DialogueObject dialogue in _activeDialogues)
        {
            int i = _activeDialogues.IndexOf(dialogue);
            if (dialogue.FreezePlayer)
            {
                playerFrozen = true;
            }
            if (dialogue.FollowTarget != null)
            {
                Vector3 loc         = _activeDialogues [i].FollowTarget.transform.position;
                Vector2 screenPoint = new Vector3(loc.x, loc.y + 1.5f, loc.z);
                //((RectTransform)_activeDialogues [i].UIObject.transform).position = screenPoint;
                //((RectTransform)_activeDialogues [i].UIObject.transform).anchoredPosition = screenPoint - ((RectTransform)transform).sizeDelta / 2f;
            }
            _activeDialogues [i].Timer -= Time.deltaTime;
            if (_activeDialogues[i].Timer <= 0 || PlayerControlManager.GetKeyDown(ControlInput.INTERACT))
            {
                if (_activeDialogues[i].Next != null)
                {
                    CreateBox(_activeDialogues[i].Next);
                    _activeDialogues [i].Next.FreezePlayer = false;
                }
                Destroy(_activeDialogues [i].UIObject);
                _activeDialogues.RemoveAt(i);
                return;
            }
        }
        if (pausePlayer != playerFrozen)
        {
            pausePlayer = playerFrozen;
            if (pausePlayer)
            {
                GameManager.inst.EnterPauseState(PauseType.CUTSCENE);
            }
            else
            {
                GameManager.inst.ExitPauseState(PauseType.CUTSCENE);
            }
        }
        if (!GameManager.CheckPause((int)PauseType.CUTSCENE) && pausePlayer)
        {
            if (pausePlayer)
            {
                GameManager.inst.EnterPauseState(PauseType.CUTSCENE);
            }
        }
    }
    public override bool check(Controller c)
    {
        Player p = State.cast <Player>(c);

        if (PlayerControlManager.GetKeyDown(ControlInput.DASH) &&
            CursorManager.CursorInGameplayState())
        {
            return(true);
        }
        return(false);
    }
Beispiel #4
0
    // Update is called once per frame
    void Update()
    {
        // Test
        //Debug.Log("CursorIsOverATetherPoint: " + TetherManager.CursorIsOverATetherPoint() + "; CursorIsOverAStasisBubble: " + LevelStateManager.CursorIsOverAStasisBubble());


        if (useBubbleAliveTimer && !GameManager.isPaused())
        {
            bubbleAliveTimer -= Time.deltaTime;
            if (bubbleAliveTimer <= 0)
            {
                RemoveBubble();
            }

            // Temporary: Make the bubble get smaller over time
            if (shrinkWithTimer)
            {
                transform.localScale = new Vector3((bubbleAliveTimer / bubbleAliveTime) * initScale.x, (bubbleAliveTimer / bubbleAliveTime) * initScale.y, (bubbleAliveTimer / bubbleAliveTime) * initScale.z);
            }

            // Temporary: Make the bubble fade over time
            if (fadeWithTimer)
            {
                if (spriteRend != null)
                {
                    spriteRend.color = new Color(spriteRend.color.r, spriteRend.color.g, spriteRend.color.b, (bubbleAliveTimer / bubbleAliveTime) * maxBubbleAlpha);
                }
            }
        }

        if (canRightClickDestroy)
        {
            UpdateMouseIsOver();
        }

        // Temporary: You can right click to remove a stasis bubble
        if (canRightClickDestroy && !TetherManager.CursorIsOverATetherPoint())
        {
            if (MouseIsOver() && PlayerControlManager.GetKeyDown(ControlInput.REMOVAL))
            {
                RemoveBubble();
            }
        }

        if (source != null && !source.isPlaying)
        {
            source.loop = true;
            source.clip = stasisHum;
            source.Play();
        }
    }
    public override void perform(Controller c)
    {
        Player p = State.cast <Player> (c);

        Vector3 mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));

        //bool inSBBounds = LevelStateManager.StasisBubbleAtPos (mousePos);

        // Use Stasis Placement ablility
        if (PlayerControlManager.GetKeyDown(ControlInput.FIRE_STASIS))
        {
            if (GameManager.inst.canUseStasis &&
                //!inSBBounds &&
                //!TetherManager.CursorIsOverATetherPoint () &&
                CursorManager.CursorInGameplayState())
            {
                p.setStasisShootAnim();
                c.getSelf().getAbility(0).use(c.getSelf(), mousePos);
            }

            if (!LevelStateManager.canAddStasisBubble() && !GlobalAudio.ClipIsPlaying(AudioLibrary.inst.stasisError))
            {
                AudioLibrary.PlayStasisErrorSound();
            }
        }

        // Use Dash ability
        if (PlayerControlManager.GetKeyDown(ControlInput.DASH))
        {
            if (GameManager.inst.canUseDash && CursorManager.CursorInGameplayState())
            {
                if (c.getSelf().getAbility(1).isReady())
                {
                    AudioLibrary.PlayDashForwardSound();
                }
                else
                {
                    if (!GlobalAudio.ClipIsPlaying(AudioLibrary.inst.dashError))
                    {
                        AudioLibrary.PlayDashErrorSound();
                    }
                }///
                c.getSelf().getAbility(1).use(c.getSelf(), p.getJumpTargetPos());
            }
        }

        p.move();
        p.findTarget();
    }
Beispiel #6
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;
                }
            }
        }
    }
Beispiel #7
0
    // Update is called once per frame
    void Update()
    {
        Collider2D[] hits;

        if (moveParent != null)
        {
            transform.position = moveParent.position + offsetFromMoveParent;
        }


        /*
         * Radius Tether point removal
         * Possibly deprecated
         */

        playerInRemoveRadius = false;

        if (allowRadiusRemoval)
        {
            hits = Physics2D.OverlapCircleAll(tetherPointSprite.transform.position, removeRadius);

            for (int i = 0; i < hits.Length; i++)
            {
                if (hits[i].CompareTag("Player"))
                {
                    playerInRemoveRadius = true;
                }
            }
        }

        // Don't allow the remove prompt/action for the first tether point (when tetherIndex == 0)
        if (playerInRemoveRadius && tetherIndex != 0)
        {
            // Display the remove prompt
            if (removePrompt != null)
            {
                removePrompt.SetActive(true);
            }

            // Test for remove action
            // TODO- might want to have this be a hold action
            if (PlayerControlManager.GetKeyDown(ControlInput.INTERACT) && !beingRemoved)
            {
                TetherManager.inst.RemoveTetherPoint(tetherIndex);
                beingRemoved = true;
            }
        }
        else
        {
            if (removePrompt != null)
            {
                removePrompt.SetActive(false);
            }
        }

        /*
         * Input (right click) Tether point removal
         */
        //if (allowKeyRemoval && tetherIndex != 0 && MouseIsOver() && PlayerControlManager.GetKeyDown(ControlInput.FIRE_STASIS) && !LevelStateManager.CursorIsOverAStasisBubble())
        if (allowKeyRemoval && tetherIndex != 0 && MouseIsOver() && PlayerControlManager.GetKeyDown(ControlInput.REMOVAL) && !beingRemoved)
        {
            TetherManager.inst.RemoveTetherPoint(tetherIndex);
            beingRemoved = true;
        }

        // Check for Destroy
        if (spriteAnimator != null && spriteAnimator.GetCurrentAnimatorStateInfo(0).IsName("WaitForDestroy"))
        {
            // TODO- spawn object that flies toward the player
            if (spawnReturnObj)
            {
                GameObject returnObj = (GameObject)Instantiate(returnObjPrefab, platformAttachPoint.transform.position, transform.rotation);
            }

            Destroy(this.gameObject);
        }

        if (zoomParticles != null)
        {
            if (GameManager.inst.pauseType == PauseType.ZOOM)
            {
                zoomParticles.gameObject.SetActive(true);
            }
            else
            {
                zoomParticles.gameObject.SetActive(false);
            }
        }
    }
Beispiel #8
0
    public void Update()
    {
        // Update the bounds every frame from the separate bounds object
        // This isn't ideal, but is being done so that bounds can be stored in separate gameObject outside the LevelManager prefab
        // This way, you can change the external bounds and have that change update here,
        //      while still allowing the CameraManager to store default camera bounds if the CameraBounds instance isn't assigned
        if (SceneSetup.inst != null)
        {
            b_origin = SceneSetup.inst.b_origin;
            b_max    = SceneSetup.inst.b_max;
            b_min    = SceneSetup.inst.b_min;
        }

        //shake the camera
        if (shakeDur > 0f)
        {
            cam.transform.localPosition = (Vector3)Random.insideUnitCircle * shakeInt;

            shakeInt -= shakeDec * Time.deltaTime;
            if (shakeInt <= 0f)
            {
                shakeDur = 0f;
            }

            shakeDur -= Time.deltaTime;
            if (shakeDur <= 0f)
            {
                shake(0, 0);
                cam.transform.localPosition = Vector2.zero;
            }
        }

        //smooth follow
        if (target != null && smoothFollow)
        {
            Vector3 tarPos = transform.position;
            Vector2 dtt    = target.position - transform.position;
            if (dtt.magnitude > followRadius)
            {
                tarPos            += (Vector3)(dtt.normalized * (dtt.magnitude - followRadius));
                transform.position = Vector3.Lerp(transform.position, tarPos, Time.deltaTime * smoothSpeed);
                fitToBounds(transform, cam);
            }
        }

        if (Application.isPlaying)
        {
            /*
             * //if ((Input.GetKey(PlayerControlManager.LH_ZoomOut) || Input.GetKey(PlayerControlManager.RH_ZoomOut)) && TetherManager.ZoomOutAllowed() && !GameManager.isPlayerDashing())
             * if (PlayerControlManager.GetKey(ControlInput.ZOOM_OUT) && TetherManager.ZoomOutAllowed() && !GameManager.isPlayerDashing())
             * {
             *      m_zoomState = true;
             *      zoomTo(zoomOutSize, zoomOutLerpSpeed);
             *      updateZoomPan(false);
             * }
             * else
             * {
             *      m_zoomState = false;
             *      zoomTo(regularSize, zoomInLerpSpeed);
             *      updateZoomPan(true);
             * }
             */

            if (cameraZoomZoneCollider != null && m_zoomState == false)
            {
                if (cameraZoomZoneCollider.collisionActive)
                {
                    if (cam.orthographicSize <= cameraZoomZoneCollider.targetCameraSize)
                    {
                        zoomTo(cameraZoomZoneCollider.targetCameraSize, zoneZoomOutLerpSpeed);
                        useZoneZoomOutSpeed = true;
                    }
                    else
                    {
                        zoomTo(cameraZoomZoneCollider.targetCameraSize, zoomInLerpSpeed);
                        useZoneZoomOutSpeed = true;
                    }
                }
            }


            // Toggle zoom state key inputs
            if (m_zoomState == false)
            {
                // These conditions determine whether zooming out is allowed
                if (PlayerControlManager.GetKeyDown(ControlInput.ZOOM_OUT) && TetherManager.ZoomOutAllowed() && !GameManager.isPlayerDashing() && !PauseMenuManager.pauseMenuActive && !GameManager.inst.IsWorldPauseType(GameManager.inst.pauseType))
                {
                    m_zoomState = true;
                    GameManager.inst.EnterPauseState(PauseType.ZOOM);
                }
            }
            else
            {
                if (PlayerControlManager.GetKeyDown(ControlInput.ZOOM_OUT) && !PauseMenuManager.pauseMenuActive)
                {
                    m_zoomState = false;
                    GameManager.inst.ExitPauseState();
                    useZoneZoomOutSpeed = false;
                }
            }

            // If the player is dead, force the zoom to cancel
            if (GameManager.isPlayerDead())
            {
                m_zoomState = false;
            }

            // Update zoom properties, based on m_zoomState
            if (m_zoomState == true)
            {
                zoomTo(zoomOutSize, zoomOutLerpSpeed);
                updateZoomPan(false);
            }
            else
            {
                updateZoomPan(true);

                if (cameraZoomZoneCollider == null || !cameraZoomZoneCollider.collisionActive)
                {
                    if (useZoneZoomOutSpeed)
                    {
                        zoomTo(regularSize, zoneZoomInLerpSpeed);
                    }
                    else
                    {
                        zoomTo(regularSize, zoomInLerpSpeed);
                    }
                    //updateZoomPan(true);
                }
            }
        }

        updateAtBounds();
    }