// Update is called once per frame void Update() { //if (Input.GetMouseButtonDown(0)) if (CustomController.GetButtonDown(Constants.TakePicture)) { if (cameraSnap == null || CameraReady == false) { return; } cameraSnap.SnapShutter(); TakePicture(); if (cameraSFX != null) { cameraSFX.Play(); } if (picText != null) { picText.text = (allPics.Length - picIndex).ToString(); } } if (CustomController.GetButtonDown(Constants.ReadyCamera)) { ReadyCamera(); } if (CustomController.GetButtonUp(Constants.ReadyCamera)) { UnReadyCamera(); } }
// Update is called once per frame void Update() { timer += Time.deltaTime; //dont throw items if camera is poised for taking pictures if (photographer != null && photographer.CameraReady) { return; } //if enough time has passed and the object limit is not exceeded, create object and throw when button is pressed if (CustomController.GetButtonDown(Constants.ThrowObject) && timer >= coolDownTime && currentObjects < objectLimit) { ThrowCarrot(); } }
//add on method to support crouching //reduce height if player pressed crouch button, return to normal on release private void HandleCrouch() { if (CustomController.GetButtonDown(Constants.CrouchButton) && !IsCrouching) { transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y / 2.0f, transform.localScale.z); IsCrouching = true; //reduce speed while crouching m_WalkSpeed /= 2.0f; } if (CustomController.GetButtonUp(Constants.CrouchButton) && IsCrouching) { transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y * 2.0f, transform.localScale.z); IsCrouching = false; //return to normal speed m_WalkSpeed *= 2.0f; } }
// Update is called once per frame void Update() { //toggle pause if (CustomController.GetButtonDown(Constants.Pause) && !DontAllowPause) { if (paused) { paused = false; Time.timeScale = 1; pauseText.SetActive(false); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } else if (!paused) { paused = true; Time.timeScale = 0; pauseText.SetActive(true); Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } // SceneManager.LoadScene("Lab"); } //decrease timer //timeRemaining -= Time.deltaTime; //int minutes = Mathf.FloorToInt(timeRemaining / 60f); //int seconds = Mathf.FloorToInt(timeRemaining - minutes * 60); // timeText.text = "Time Remaining: " + string.Format("{0:0}:{1:00}", minutes, seconds); //check framerate if (debug && debugText != null) { int fps = (int)(1f / Time.unscaledDeltaTime); debugText.text = "FPS: " + fps; } }