IEnumerator StartCutscene() { yield return(null); camFollowGuy = true; crossAnimator.SetBool("On", false); playerController.Ride(transform); personCutsceneAnimator.Play("CutsceneStartPerson", 0, .25f); yield return(WaitAndMakeFootstepSounds(10f * .75f)); personAnimator.SetBool("Stand", true); //Dialogue yield return(dialogueManager.StartDialogue(Dialogue.Cutscene01StartDialogue())); //GoAwayPerson personAnimator.SetBool("Stand", false); personCutsceneAnimator.SetTrigger("GoAway"); yield return(WaitAndMakeFootstepSounds(1.5f)); autoDoor.ForceOpen(true); yield return(WaitAndMakeFootstepSounds(1.5f)); autoDoor.ForceOpen(false); yield return(new WaitForSecondsPaused(3f, PauseManager.isPaused())); carAudio.Play(); camFollowGuy = false; yield return(playerController.RotatePlayer(Quaternion.LookRotation(paperLook.position - playerController.camTransform.position), 50)); crossAnimator.SetBool("On", true); playerController.UnRide(); }
IEnumerator InspectFallenBox() { playerController.SetCanMove(false); boxFallAnim.SetTrigger("Fall"); StartCoroutine(playerController.RotatePlayer(Quaternion.LookRotation(boxFallAnim.transform.position - playerController.transform.position), 50)); yield return(new WaitForSecondsPaused(1f, PauseManager.isPaused())); yield return(dialogueManager.StartDialogue(Dialogue.OneLineMonologue("What was that?"))); playerController.SetCanMove(true); }
IEnumerator WaitAndMakeFootstepSounds(float seconds) { float timeBetweenSteps = 0.775f; for (float f = 0; f < seconds; f += timeBetweenSteps) { yield return(new WaitForSecondsPaused(timeBetweenSteps, PauseManager.isPaused())); footstepAudio.clip = footstepAudioClips[Random.Range(0, footstepAudioClips.Length)]; footstepAudio.pitch = 1f - Random.Range(-.1f, .1f); footstepAudio.Play(); } }
void LateUpdate() { if (cam == null) { cam = playerController.camTransform; } if (PauseManager.isPaused().Value) { return; } //Get Input bool useKey = Input.GetKeyDown(GlobalSettings.keyUse) || Input.GetKeyDown(GlobalSettings.keyUse2); //!(IsRiding & pressing) if (!(useKey && playerController.currentRide != null)) { //Get useable GameObject and maybe use it RaycastHit hit; if (Physics.Raycast(cam.position, cam.forward, out hit, range, mask)) { GameObject hitObject = hit.collider.gameObject; if (hitObject.CompareTag("Useable")) { Useable[] useables = hitObject.GetComponents <Useable>(); if (useables == null) { return; } if (playerController.GetCanMove()) { foreach (Useable useable in useables) { useable.LookingAt(); if (useKey) { useable.Use(); } } } } } } }
IEnumerator StartCutscene() { yield return(null); animator.SetTrigger("Go"); playerController.Ride(transform); yield return(new WaitForSecondsPaused(1f, PauseManager.isPaused())); audioSource.Play(); yield return(new WaitForSecondsPaused(5f, PauseManager.isPaused())); crossAnimator.SetBool("On", false); yield return(dialogueManager.StartDialogue(Dialogue.Cutscene02StartDialogue())); crossAnimator.SetBool("On", true); playerController.UnRide(); }
void Update() { //Apply Camera Effects CameraEffects(); //Do nothing when Player isn't allowed to move if (!canMove || PauseManager.isPaused().Value) { return; } //Get Inputs MoveData inputs = new MoveData() { xRot = Input.GetAxis("Mouse Y") * mouseSensitivityY, yRot = Input.GetAxis("Mouse X") * mouseSensitivityX, axisHorizontal = GlobalSettings.usingMouse ? Input.GetAxisRaw("Horizontal") : Input.GetAxis("Horizontal"), axisVertical = GlobalSettings.usingMouse ? Input.GetAxisRaw("Vertical") : Input.GetAxis("Vertical"), axisSneak = Input.GetAxisRaw("Sneak"), axisSprint = Input.GetAxisRaw("Sprint"), axisJump = Input.GetAxis("Jump") }; //Don't move when sitting or while riding, use Move-Method of the rideable-Object if (currentRide != null) { if (currentRide.Move(inputs)) { Rotate(inputs.xRot, inputs.yRot); } return; } else { Rotate(inputs.xRot, inputs.yRot); Move(inputs); } }
IEnumerator TypeSentence(string sentence) { text.text = ""; bool skip = false; for (int i = 0; i < sentence.Length; i++) { if (PauseManager.isPaused().Value) { yield return(new WaitWhile(() => PauseManager.isPaused().Value)); } if (sentence[i] == '§' && i + 1 < sentence.Length && TextCode(sentence[i + 1])) { i++; continue; } text.text += sentence[i]; every4thLetter = (every4thLetter + 1) % 4; if (!skip && every4thLetter == 0) { PlayRandomSound(); } if (IsPressingConfirm()) { skip = true; } if (!skip) { yield return(new WaitForSeconds(1f / 60f)); } } }
public IEnumerator StartDialogue(DialogueNode dialogue) { if (!isInDialogue) { isInDialogue = true; Reset(); anim.SetBool("Activated", true); yield return(new WaitForSeconds(.5f)); while (true) { nameText.text = dialogue.currentNameText; currentAudioClips = GetRightAudioClips(dialogue.currentVoice); if (PauseManager.isPaused().Value) { yield return(new WaitWhile(() => PauseManager.isPaused().Value)); } yield return(TypeSentence(dialogue.currentText)); if (Input.GetKeyDown(KeyCode.L)) { break; } if (dialogue.currentChoices != null && dialogue.currentChoices.Count > 0) { choices[0].GetComponentInChildren <Text>().text = dialogue.currentChoices[0]; choices[0].SetActive(true); eventSystem.SetSelectedGameObject(choices[0]); switch (dialogue.nextNodes.Count) { case 1: break; case 2: choices[1].GetComponentInChildren <Text>().text = dialogue.currentChoices[1]; choices[1].SetActive(true); break; case 3: choices[2].GetComponentInChildren <Text>().text = dialogue.currentChoices[2]; choices[2].SetActive(true); goto case 2; default: Debug.LogWarning("More than 3 choices are not implemented yet."); break; } anim.SetBool("Choices", true); pressedChoice = -1; yield return(new WaitWhile(() => pressedChoice == -1 || IsPressingConfirm())); if (pressedChoice < 1 || pressedChoice > 3) { Debug.LogError("unsupported choice"); } dialogue = dialogue.nextNodes[pressedChoice - 1]; anim.SetBool("Choices", false); eventSystem.SetSelectedGameObject(null); choices[0].SetActive(false); choices[1].SetActive(false); choices[2].SetActive(false); } else { yield return(new WaitUntil(() => (!PauseManager.isPaused().Value&& IsPressingConfirm()))); yield return(new WaitUntil(() => (!PauseManager.isPaused().Value&& !IsPressingConfirm()))); if (dialogue.nextNodes.Count == 0) { break; } if (dialogue.nextNodes[0].currentText == null) { ending = dialogue.nextNodes[0].end; break; } dialogue = dialogue.nextNodes[0]; } } anim.SetBool("Activated", false); isInDialogue = false; } }