Example #1
0
 void HandleMouseLeftButtonDown()
 {
     AkSoundEngine.PostEvent("Play_Click", gameObject);
     hitsOnRayToMouse = hitsOnRayToMouse.OrderBy(hit => Vector3.SqrMagnitude(mainCamera.transform.position - hit.point)).ToArray();
     if (hitsOnRayToMouse.Length > 0)
     {
         if (interactibleState != EInteractibleState.CLICKED)
         {
             // Launch navigation
             if (!blockInput && (!tutorial || tutorialManager.step == ETutorialStep.BOAT_MOVE || tutorialManager.step == ETutorialStep.GO_TO_ISLAND) && hitsOnRayToMouse.Any(hit => hit.collider.CompareTag("Boat")))
             {
                 navigation = true;
                 boatAnimator.SetBool("Hold", true);
                 boat.StartTargeting();
             }
             else
             {
                 // Interactible
                 RaycastHit hitInfo = hitsOnRayToMouse.FirstOrDefault(hit => hit.collider.GetComponent <Interactible>());
                 if ((!blockInput || navigating) && hitInfo.collider && (!tutorial || tutorialManager.step >= ETutorialStep.OBJECT_MOVE) && hitInfo.collider.GetComponent <Interactible>().IsGrabbable())
                 {
                     interactible      = hitInfo.collider.GetComponent <Interactible>();
                     interactibleState = EInteractibleState.DRAGNDROP;
                     CursorManager.Instance.SetCursor(ECursor.DRAG);
                     Vector3 interactibleGrabbedPos = interactible.GetGrabbedPosition();
                     interactibleScreenPos = mainCamera.WorldToScreenPoint(interactibleGrabbedPos);
                     interactibleOffset    = interactibleGrabbedPos - mainCamera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, interactibleScreenPos.z));
                     interactible.Grab();
                 }
                 else if (!blockInput)
                 {
                     // Telescope
                     bool telescopeClick = (telescope.gameObject.activeInHierarchy && !telescopeDrag &&
                                            (!tutorial || tutorialManager.step == ETutorialStep.TELESCOPE_MOVE || tutorialManager.step == ETutorialStep.TELESCOPE_ZOOM) &&
                                            hitsOnRayToMouse.Any(hit => hit.collider.CompareTag("UpPartCollider")));
                     if (telescopeClick)
                     {
                         if (!firstClickTelescope)
                         {
                             firstClickTelescope = true;
                             timerDoubleClick    = Time.time;
                         }
                         else
                         {
                             firstClickTelescope = false;
                             if (!tutorial || tutorialManager.step == ETutorialStep.TELESCOPE_ZOOM)
                             {
                                 telescope.ChangeZoom();
                             }
                         }
                     }
                     else if (!tutorial && hitsOnRayToMouse.Any(hit => hit.collider.CompareTag("Character")))
                     {
                         // Character
                         StartCoroutine(screenManager.RelaunchDialogue());
                         StartCoroutine(WaitBeforeResettingHoverTrigger());
                     }
                 }
             }
         }
         else if (!eventSystem.IsPointerOverGameObject() && !hitsOnRayToMouse.Any(hit => hit.collider.gameObject.name == interactible.name))
         {
             ExitInterfaceRotation();
         }
     }
 }