/// Show a line of dialogue, gradually private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onComplete) { LineStarted?.Invoke(); userRequestedNextLine = false; // The final text we'll be showing for this line. string text = localisationProvider.GetLocalisedTextForLine(line); if (text == null) { Debug.LogWarning($"Line {line.ID} doesn't have any localised text."); text = line.ID; } if (textSpeed > 0.0f) { // Display the line one character at a time var stringBuilder = new StringBuilder(); foreach (char c in text) { stringBuilder.Append(c); LineUpdating?.Invoke(stringBuilder.ToString()); if (userRequestedNextLine) { // We've requested a skip of the entire line. // Display all of the text immediately. LineUpdating?.Invoke(text); break; } yield return(new WaitForSeconds(textSpeed)); } } else { // Display the entire line immediately if textSpeed <= 0 LineUpdating?.Invoke(text); } // We're now waiting for the player to move on to the next line userRequestedNextLine = false; // Indicate to the rest of the game that the line has finished being delivered LineFinishDisplaying?.Invoke(); while (userRequestedNextLine == false) { yield return(null); } // Avoid skipping lines if textSpeed == 0 yield return(new WaitForEndOfFrame()); // Hide the text and prompt LineEnded?.Invoke(); onComplete(); }
private void OnLineStartedEvent() { _launchedTimeCounter++; LineStarted?.Invoke(this, new EventArgs()); }