virtual public IEnumerator Discover(bool tutorial, TutorialManager tutorialManager) { if (discoverySound != null) { discoverySound.Post(gameObject); yield return(new WaitForSeconds(1.5f)); } if (!name.Equals("MegaTyphoon")) { AkSoundEngine.PostEvent("Play_Note", gameObject); meshRenderer.enabled = true; } visible = true; discovered = true; if (tutorial) { tutorialManager.CompleteStep(); } for (int i = 0; i < elementsToActivate.Length; i++) { elementsToActivate[i].SetActive(true); } }
public void Rotate(int axis, int direction) { int angle = getRotation(axis); if (angle != 0) { AkSoundEngine.PostEvent("Play_Manipulation", gameObject); foreach (Collider collider in colliders) { collider.enabled = false; } rotating = true; rotationTime = 0; rotationBefore = transform.rotation; Vector3 axisVec = Vector3.zero; if (axis == 0) { axisVec = Vector3.right; } else if (axis == 1) { axisVec = Vector3.up; } else if (axis == 2) { axisVec = Vector3.forward; } rotationAfter = Quaternion.AngleAxis(angle * direction, axisVec) * rotationBefore; if (zoom) { inspectionInterface.SetButtonsInteractable(false); if (axis == 2 && angle == 180) { switchTranscriptSide = true; } } if (tutorialManager.step == ETutorialStep.OBJECT_ROTATE) { tutorialManager.CompleteStep(); } } }
public IEnumerator Berth(Island island, bool tutorialNow) { inputManager.StopCurrentInteractions(); inventory.HandleBerth(true); currentIsland = island; tutorial = tutorialNow; if (!island.discovered) { yield return(StartCoroutine(island.Discover(tutorialNow, tutorialManager))); yield return(new WaitForSeconds(1)); } islandBackground.GetComponent <SpriteRenderer>().sprite = island.background; islandCharacter.GetComponent <SpriteRenderer>().sprite = island.character; currentIslandNumber = island.islandNumber; firstVisit = island.firstTimeVisiting; island.Berth(); EventManager.Instance.Raise(new BlockInputEvent() { block = true, navigation = false }); globalAnimator.SetTrigger("FirstBerth"); if (tutorialNow) { tutorialManager.CompleteStep(); } yield return(new WaitForSeconds(4)); dialogueManager.StartDialogue(island.dialogue, firstVisit); }
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); } }
void Update() { if (navigating) { journeyTarget.y = boat.transform.position.y; Vector3 journey = journeyTarget - boat.transform.position; // End of journey if (journey.sqrMagnitude <= 0.0005f) { navigating = false; // If typhoon at end of journey if (boatScript.inATyphoon && !fromTyphoon) { Debug.Log("Boat in typhoon!"); AkSoundEngine.PostEvent("Play_Typhon", gameObject); StartCoroutine(WaitBeforeGoingToInitialPos(boatScript.typhoon)); } // If correct position else if (!lastZone) { AkSoundEngine.PostEvent("Play_Arrival", gameObject); AkSoundEngine.PostEvent("Stop_Typhon", gameObject); lightScript.rotateDegreesPerSecond.value.y = -0.1f; // Save position lastValidPosition.transform.position = boat.transform.position; lastValidPositionZone = map.currentZone; // Berth on island if needed if (boatScript.onAnIsland && boatScript.currentIsland.islandNumber != screenManager.currentIslandNumber && !fromTyphoon && (tutorialManager.step == ETutorialStep.NO_TUTORIAL || tutorialManager.step == ETutorialStep.GO_TO_ISLAND)) { BerthOnIsland((goalCollider != null)); } else { //EndJourneyAtSea screenManager.EndNavigationAtSea(); telescope.RefreshElements(journeyTarget, map.GetCurrentPanorama(), map.GetCurrentRain()); EventManager.Instance.Raise(new BlockInputEvent() { block = false, navigation = false }); if (goalCollider && insideGoal) { tutorialManager.CompleteStep(); } } fromTyphoon = false; if (goalCollider && insideGoal) { goalCollider = null; insideGoal = false; } } else if (lastZone) { lightScript.rotateDegreesPerSecond.value.y = 0; } } // Still journeying else { float distCovered = (Time.time - journeyBeginTime) * currentSpeed; float fracJourney = distCovered / journeyLength; boat.transform.position = Vector3.Lerp(boat.transform.position, journeyTarget, fracJourney); // Typhoon if (boatScript.inATyphoon && !fromTyphoon) { Debug.Log("Boat in typhoon!"); AkSoundEngine.PostEvent("Play_Typhon", gameObject); StartCoroutine(WaitBeforeGoingToInitialPos(boatScript.typhoon)); } } } }