Exemplo n.º 1
0
    void DropInteractible()
    {
        CursorManager.Instance.SetCursor(ECursor.DEFAULT);
        interactibleState = EInteractibleState.UNKNOWN;
        interactible.Drop();
        interactible = null;

        if (tutorialManager.step == ETutorialStep.OBJECT_MOVE)
        {
            tutorialManager.CompleteStep();
        }
    }
Exemplo n.º 2
0
    public void ExitInterfaceRotation()
    {
        interactibleState = EInteractibleState.UNKNOWN;
        inspectionInterface.gameObject.SetActive(false);
        rotationPanel.SetActive(false);
        telescope.SetImageAlpha(false);
        boat.SetImageAlpha(false);
        interactible.ExitRotationInterface();
        interactible = null;

        if (tutorialManager.step == ETutorialStep.OBJECT_ROTATE && tutorialManager.stateCompleted)
        {
            tutorialManager.NextStep();
        }
    }
Exemplo n.º 3
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();
         }
     }
 }
Exemplo n.º 4
0
    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);
        }
    }