private void Awake() { instance = this; }
public IEnumerator InDialogue(SpokenLine[] dialogue, Transform cameraPos, bool flipCamera = false) { inCutscene = true; EnableCameraFollowTargets(false); StartCoroutine(AnimateBlackBars(true)); oldPos = Camera.main.transform.position; oldRot = Camera.main.transform.rotation; if (flipCamera) { MultipleTargetsAverageFollow mf = Camera.main.GetComponent <MultipleTargetsAverageFollow>(); Debug.Log("z offset: " + mf.offset.z); float delta = mf.offset.z * 2f; oldPos.z -= delta; mf.offset.z *= -1; oldRot = Quaternion.Euler(54f, 180f, oldRot.z); } if (cameraPos != null) { yield return(StartCoroutine(MoveCamera(cameraPos.position, cameraPos.rotation))); } bool nextLine = false; foreach (SpokenLine line in dialogue) { fromText.text = line.Name; nextLine = false; audioS.clip = line.clipIndex == -1 ? gnomeSounds[Mathf.FloorToInt(Random.Range(0, gnomeSounds.Length))] : kingSounds[line.clipIndex]; audioS.volume = (line.clipIndex == -1 ? 0.3f : 1f) * Settings.SFX; audioS.Play(); yield return(StartCoroutine(TypeText(line.Line))); if (Data.ControllerConnected()) { nextButton_Controller.gameObject.SetActive(true); nextButton_Keyboard.gameObject.SetActive(false); } else { nextButton_Controller.gameObject.SetActive(false); nextButton_Keyboard.gameObject.SetActive(true); } StartCoroutine(AnimateNextButton()); while (nextLine == false) { if (NextButtonDown()) { yield return(new WaitForEndOfFrame()); skip = false; nextLine = true; } yield return(new WaitForFixedUpdate()); } HideText(); } StartCoroutine(AnimateBlackBars(false)); yield return(StartCoroutine(MoveCamera(oldPos, oldRot))); EnableCameraFollowTargets(true); inCutscene = false; }