/// EDITED FOR SAILING WITH THE GODS /// Designed for our dialog system to fill in a dialog object private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onComplete) { onLineStart?.Invoke(); userRequestedNextLine = false; string text = localisationProvider.GetLocalisedTextForLine(line); if (text == null) { Debug.LogWarning($"Line {line.ID} doesn't have any localised text."); text = line.ID; } //Split one block of text into multiple sections string[] split = text.Split('^'); //If we need to end after the split, we have to save that for later //Otherwise, we'll end between the split, which isn't right bool eventualEnd = end; end = false; for (int i = 0; i < split.Length; i++) { if (split[i][0] == '&') { ds.AddImage(split[i].Remove(0, 1)); } else { ds.AddToDialogText(currentSpeakerName, split[i], textAlign); } //If this is the final part of the split text, remember if this is the end or not if (i == split.Length - 1) { end = eventualEnd; } // 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 onLineFinishDisplaying?.Invoke(); while (userRequestedNextLine == false) { yield return(null); } } onLineEnd?.Invoke(); onComplete(); }
/// Show a line of dialogue, gradually private IEnumerator DoRunLine(Yarn.Line line, ILineLocalisationProvider localisationProvider, System.Action onComplete) { onLineStart?.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; } string[] split = text.Split('^'); bool eventualEnd = end; end = false; for (int i = 0; i < split.Length; i++) { if (split[i][0] == '&') { ds.AddImage(split[i].Remove(0, 1)); } else { ds.AddToDialogText(currentSpeakerName, split[i], textAlign); } if (i == split.Length - 1) { end = eventualEnd; } // 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 onLineFinishDisplaying?.Invoke(); while (userRequestedNextLine == false) { yield return(null); } } // Hide the text and prompt onLineEnd?.Invoke(); onComplete(); }