void UpdateGameplayCursor() { // Choose sprite for main cursor (stasis) // If hovering over a stasis bubble if (LevelStateManager.CursorIsOverAStasisBubble() || TetherManager.CursorIsOverATetherPoint()) { mainCursorRend.sprite = cursorStasisHover; } // TODO: This might be the wrong check. Might need to check where the player checks if can shoot a stasis bubble else if (GameManager.inst.canUseStasis && LevelStateManager.canAddStasisBubble()) { mainCursorRend.sprite = cursorStasisEnabled; } else { mainCursorRend.sprite = cursorStasisDisabled; } // Secondary cursor (dash target) // Temporary: hide the dash cursor while zoomed out // TODO: replace this with a separate CursorState for zoom out if (GameManager.CameraIsZoomedOut() || !GameManager.inst.canUseDash) { dashCursorRend.enabled = false; } else { dashCursorRend.enabled = true; } if (GameManager.isPlayerDashing() == true) { dashTargetLock = true; dashTargetLockPos = dashCursor.transform.position; dashCursorRend.sprite = cursorDashTarget; } else { dashTargetLock = false; if (GameManager.dashIsCharged()) { dashCursorRend.sprite = cursorDashEnabled; } else { dashCursorRend.sprite = cursorDashDisabled; } } // Update texture //dashCursorRend.texture = cursorDashEnabled; }
// 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 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(); }