void Update() { //Debug.Log("Left Ctrl: " + Input.GetKey(KeyCode.LeftControl)); //Debug.Log("Right Ctrl: " + Input.GetKey(KeyCode.RightControl)); Ray ray = mainCamera.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, mainCamera.transform.position.y)); hitsOnRayToMouse = Physics.RaycastAll(ray); RaycastHit desk = hitsOnRayToMouse.FirstOrDefault(hit => hit.collider.CompareTag("Desk")); if (desk.collider) { mouseProjection.transform.position = desk.point; } // Left button down if (!eventSystem.IsPointerOverGameObject() && Input.GetMouseButtonDown(0)) { HandleMouseLeftButtonDown(); } // Left button up if (Input.GetMouseButtonUp(0)) { HandleMouseLeftButtonUp(); } // Telescope single click if (firstClickTelescope) { float timeSinceClick = Time.time - timerDoubleClick; if (timeSinceClick > delayBetweenDoubleClick || Input.GetMouseButton(0) && timeSinceClick > 0.1f) { firstClickTelescope = false; if (!tutorial || tutorialManager.step == ETutorialStep.TELESCOPE_MOVE || tutorialManager.step == ETutorialStep.TELESCOPE_ZOOM) { if (telescopeDrag) { EndTelescopeDrag(); } telescopeDrag = true; dragBeginPos = Input.mousePosition; Vector3 mouseScreenPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, mainCamera.transform.position.y); telescope.BeginDrag(mainCamera.ScreenToWorldPoint(mouseScreenPos)); } } } // Begin wheel telescope drag if (Input.GetMouseButtonDown(2) && telescope.gameObject.activeInHierarchy && !telescopeDrag && (!tutorial || tutorialManager.step == ETutorialStep.TELESCOPE_MOVE || tutorialManager.step == ETutorialStep.TELESCOPE_ZOOM) && hitsOnRayToMouse.Any(hit => hit.collider.CompareTag("UpPartCollider"))) { telescopeDrag = true; telescopeDragFromWheel = true; dragBeginPos = Input.mousePosition; Vector3 mouseScreenPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, mainCamera.transform.position.y); telescope.BeginDrag(mainCamera.ScreenToWorldPoint(mouseScreenPos)); } // End wheel telescope drag if (Input.GetMouseButtonUp(2) && telescopeDrag && telescopeDragFromWheel) { EndTelescopeDrag(); } // Right button down if (Input.GetMouseButtonDown(1)) { AkSoundEngine.PostEvent("Play_Click", gameObject); if (navigation) { StopNavigation(); } else { if (interactibleState == EInteractibleState.CLICKED) { ExitInterfaceRotation(); } else { hitsOnRayToMouse = hitsOnRayToMouse.OrderBy(hit => Vector3.SqrMagnitude(mainCamera.transform.position - hit.point)).ToArray(); RaycastHit hitInfo = hitsOnRayToMouse.FirstOrDefault(hit => hit.collider.GetComponent <Interactible>()); if ((!blockInput || navigating) && hitInfo.collider && (!tutorial || tutorialManager.step >= ETutorialStep.OBJECT_ZOOM) && hitInfo.collider.GetComponent <Interactible>().IsGrabbable()) { interactible = hitInfo.collider.GetComponent <Interactible>(); interactibleState = EInteractibleState.CLICKED; CursorManager.Instance.SetCursor(ECursor.DEFAULT); interactible.EnterRotationInterface(); inspectionInterface.gameObject.SetActive(true); rotationPanel.SetActive(true); telescope.SetImageAlpha(true); boat.SetImageAlpha(true); if (tutorialManager.step == ETutorialStep.OBJECT_ZOOM) { tutorialManager.CompleteStep(); } } } } } // Interactible rotate if ((!blockInput || navigating) && interactible && interactibleState == EInteractibleState.DRAGNDROP && !interactible.rotating) { if (Input.GetKeyDown(KeyCode.S)) { interactible.Rotate(0, -1); } else if (Input.GetKeyDown(KeyCode.Z)) { interactible.Rotate(0, 1); } else if (Input.GetKeyDown(KeyCode.E)) { interactible.Rotate(1, 1); } else if (Input.GetKeyDown(KeyCode.A)) { interactible.Rotate(1, -1); } else if (Input.GetKeyDown(KeyCode.D)) { interactible.Rotate(2, 1); } else if (Input.GetKeyDown(KeyCode.Q)) { interactible.Rotate(2, -1); } } // Pause if (Input.GetKeyDown(KeyCode.Escape) && !interactible && !telescopeDrag && !navigation) { ToggleOptions(); } // Hover things if (!eventSystem.IsPointerOverGameObject() && !interactible && !telescopeDrag && !navigation) { // Hover boat if (!blockInput && (!tutorial || tutorialManager.step == ETutorialStep.BOAT_MOVE || tutorialManager.step == ETutorialStep.GO_TO_ISLAND) && hitsOnRayToMouse.Any(hit => hit.collider.CompareTag("Boat"))) { CursorManager.Instance.SetCursor(ECursor.HOVER); boatAnimator.SetBool("Hover", true); } else { boatAnimator.SetBool("Hover", false); // Hover up part if (!blockInput && (!tutorial || tutorialManager.step == ETutorialStep.TELESCOPE_MOVE || tutorialManager.step == ETutorialStep.TELESCOPE_ZOOM) && hitsOnRayToMouse.Any(hit => hit.collider.CompareTag("UpPartCollider"))) { globalAnimator.SetBool("Hover", true); if (telescope.gameObject.activeInHierarchy) { CursorManager.Instance.SetCursor(ECursor.HOVER); // Telescope zoom if (Input.GetAxis("Mouse ScrollWheel") != 0 && telescope.gameObject.activeInHierarchy && (!tutorial || tutorialManager.step == ETutorialStep.TELESCOPE_ZOOM)) { telescope.Zoom(Input.GetAxis("Mouse ScrollWheel")); } } else if (hitsOnRayToMouse.Any(hit => hit.collider.CompareTag("Character"))) { CursorManager.Instance.SetCursor(ECursor.HOVER); } else { CursorManager.Instance.SetCursor(ECursor.DEFAULT); } } else if ((!blockInput || navigating) && (!tutorial || tutorialManager.step >= ETutorialStep.OBJECT_ZOOM) && hitsOnRayToMouse.Any(hit => hit.collider.GetComponent <Interactible>())) { // Hover interactible CursorManager.Instance.SetCursor(ECursor.HOVER); } else if (!blockInput || navigating) { CursorManager.Instance.SetCursor(ECursor.DEFAULT); globalAnimator.SetBool("Hover", false); } } } // Telescope drag if (telescopeDrag) { if (!Input.GetMouseButton(0) && !Input.GetMouseButton(2)) { EndTelescopeDrag(); } else { dragCurrentPos = Input.mousePosition; dragSpeed = -(dragCurrentPos - dragBeginPos).x * Time.deltaTime; telescope.UpdateSpeed(dragSpeed); } } // Navigation if (navigation) { navigationManager.UpdateNavigation(mouseProjection.transform.position); } }