private IEnumerator StartTextDisplay(Sprite dialogSprite, DialogColorAndFont dialogColorAndFont) { // Configure the text and image dialogImage.color = dialogColorAndFont.GetColor(); dialogText.alignment = dialogColorAndFont.GetTextAnchor(); dialogText.font = dialogColorAndFont.GetFont(); dialogText.fontStyle = dialogColorAndFont.GetFontStyle(); dialogText.fontSize = dialogColorAndFont.GetFontSize(); dialogSpriteRenderer.sprite = dialogSprite; if (_letterByletter) { DisplayNextSentenceLetterByLetter(); } else { DisplayNextSentence(); } yield return(null); }
public void StartDialog(DialogXMLObject.Dialog dialog, string lineId, Sprite dialogSprite, DialogColorAndFont dialogColorAndFont, bool playerCanMove, bool canInteract) { // Set the player movement allowed or disabled SetPlayerDialogChanged(true, playerCanMove); // Move the dialog box in the UI StartCoroutine(OpenDialog()); _sentencesQueue.Clear(); // Create dialog with each sentences of a line foreach (var lines in dialog.LinesList) { if (lines.id == lineId) { foreach (var text in lines.text) { _sentencesQueue.Enqueue(text); } break; } } _letterByletter = dialogColorAndFont.GetLetterByLetter(); _canInteract = canInteract; if (_canInteract) // Press ENTER to go to next sentence { if (_letterByletter) // Display dialog letter by letter or the entire sentence directly { InputsEventManager.OnEnterPressed += DisplayNextSentenceLetterByLetter; } else { InputsEventManager.OnEnterPressed += DisplayNextSentence; } } StartCoroutine(StartTextDisplay(dialogSprite, dialogColorAndFont)); }