/// <summary> /// Plays the next dialogue in the queue /// </summary> protected virtual IEnumerator PlayNextDialogue() { if (_dialogueBox == null) { yield break; } // Check if the item is already given, if so we change the dialogue if (giveItem && itemGiven) { if (toggle) { ObjectToToggle.gameObject.SetActive(!toggle); } giveItem = false; Dialogue = FinalDialogue; } // If a item is needed we call the dedicated coroutine if (needItem) { StartCoroutine(NeedItem()); } if (_currentIndex != 0) { _dialogueBox.FadeOut(FadeDuration); yield return(_transitionTimeWFS); } // if we've reached the last dialogue line, we exit if (_currentIndex >= Dialogue.Length) { if (giveItem) { if (ItemToGive != null) { ItemToGive.gameObject.SetActive(true); itemGiven = true; } } _currentIndex = 0; Destroy(_dialogueBox.gameObject); _collider.enabled = false; _activated = true; if (!CanMoveWhileTalking) { LevelManager.Instance.UnFreezeCharacters(); } if ((_characterButtonActivation != null)) { _characterButtonActivation.InButtonActivatedZone = false; _characterButtonActivation.ButtonActivatedZone = null; } if (ActivableMoreThanOnce) { _activable = false; _playing = false; StartCoroutine(Reactivate()); } else { gameObject.SetActive(false); } yield break; } if (_dialogueBox.DialogueText != null) { _dialogueBox.FadeIn(FadeDuration); _dialogueBox.DialogueText.text = Dialogue[_currentIndex]; } _currentIndex++; if (!ButtonHandled) { StartCoroutine(AutoNextDialogue()); } }
/// <summary> /// Plays the next dialogue in the queue /// </summary> protected virtual IEnumerator PlayNextDialogue() { // we check that the dialogue box still exists if (_dialogueBox == null) { yield break; } // if this is not the first message if (_currentIndex != 0) { // we turn the message off _dialogueBox.FadeOut(FadeDuration); // we wait for the specified transition time before playing the next dialogue yield return(_transitionTimeWFS); } // if we've reached the last dialogue line, we exit if (_currentIndex >= Dialogue.Length) { _currentIndex = 0; Destroy(_dialogueBox.gameObject); _collider.enabled = false; // we set activated to true as the dialogue zone has now been turned on _activated = true; // we let the player move again if (!CanMoveWhileTalking) { LevelManager.Instance.UnFreezeCharacters(); } if ((_characterButtonActivation != null)) { _characterButtonActivation.InButtonActivatedZone = false; _characterButtonActivation.ButtonActivatedZone = null; } // we turn the zone inactive for a while if (ActivableMoreThanOnce) { _activable = false; _playing = false; StartCoroutine(Reactivate()); } else { gameObject.SetActive(false); } yield break; } // we check that the dialogue box still exists if (_dialogueBox.DialogueText != null) { // every dialogue box starts with it fading in _dialogueBox.FadeIn(FadeDuration); // then we set the box's text with the current dialogue _dialogueBox.DialogueText.text = Dialogue[_currentIndex]; } _currentIndex++; // if the zone is not button handled, we start a coroutine to autoplay the next dialogue if (!ButtonHandled) { StartCoroutine(AutoNextDialogue()); } }