// Update is called once per frame void Update() { if (JournalActivator.IsPaused == false) { StartDialogueText.gameObject.SetActive(false); if (DialogueController.HandlingText == false) { DialogueController.gameObject.SetActive(false); RaycastHit raycastHit; if (Physics.Raycast(new Ray(transform.position, transform.forward), out raycastHit, 100, (1 << 0), QueryTriggerInteraction.Collide)) { Dialogueable dialogueable = raycastHit.collider.gameObject.GetComponent <Dialogueable>(); if (dialogueable != null) { if (StartDialogueText.gameObject.activeSelf == false) { StartDialogueText.gameObject.SetActive(true); //StartDialogueText.text = "Press <color=red>E</color> to <color=yellow>" + dialogueable.interactionText + "</color>"; } if (Input.GetKeyDown(KeyCode.E)) { DialogueController.gameObject.SetActive(true); DialogueController.HandleDialogueText(dialogueable.textChapter); } } } } } }
private IEnumerator _HandleDialogueText(TextAsset text) { yield return(new WaitForEndOfFrame()); while (data != null && chapterProgress < data.Count) { //Debug.Log("waiting for next in chapter file"); if (_next && isHandlingLine == false) { string line = data[chapterProgress]; LineType lineType = GetLineType(line); //Debug.Log(lineType.ToString()); HandlingLineCoroutine = StartCoroutine(LineHandlers[lineType].HandleLine(line)); sound.clip = sounds[UnityEngine.Random.Range(0, sounds.Length - 1)]; if (lineType != LineType.Choice) { sound.Play(); } while (isHandlingLine) { yield return(new WaitForEndOfFrame()); } sound.Stop(); yield return(new WaitForEndOfFrame()); } yield return(new WaitForEndOfFrame()); } //Debug.Log("Progress: " + chapterProgress + " TOTAL: " + data.Count); while (!_next) { yield return(new WaitForEndOfFrame()); } DetachCamera.Reattach(); GetComponent <CanvasGroup>().ChangeCanvasGroupVisibility(false); ResetDialogueVariables(); if (currentDialogueable != null) { currentDialogueable._interacting = false; } sound.Stop(); currentDialogueable = null; }
public void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <Dialogueable> () != null) { dialogueAvail = true; activeDialogue = other.gameObject.GetComponent <Dialogueable> (); activeDialogue.FToInteract(true); } else if (other.GetComponent <Door> () != null) { WalkBetweenRooms(other.GetComponent <Door> ()); } else if (other.GetComponent <PickupItem> () != null) { if (other.GetComponent <Food>()) { foundFood(); } pickupUIBar.AddItem(other.GetComponent <PickupItem> ()); Destroy(other.gameObject); } else if (other.GetComponent <Vent> () != null) { if (inVent) { inVent = false; ExitVent(other.GetComponent <Vent> ()); } else { inVent = true; EnterVent(other.GetComponent <Vent> ()); } } else if (other.GetComponent <Hunter> () != null && !inVent) { StartCoroutine("HunterAttack", other.GetComponent <Hunter> ()); } else if (other.GetComponent <SavePoint> () != null) { other.GetComponent <SavePoint> ().revSave(); abilityCont.SaveZone(true); } }