void Update() { if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return)) { if (storyCompleted && dialogUI.dialogCompleted()) { GameManager.EndConversation(); } advanceStory(); } if (dialogUI.dialogCompleted() && CleanupFunction != null) { CleanupFunction(); CleanupFunction = null; } }
public void advanceStory() { if (!dialogUI.dialogCompleted()) { dialogUI.resolveDialog(); return; } if (currentLine < lines.Count) { string line; string instructions; do { line = ""; instructions = ""; if (!(currentLine < lines.Count)) { break; } line = lines[currentLine]; Debug.Log(line); if (twineParser.IsInstruction(line)) { instructions = line.Substring(line.IndexOf("%"), line.Substring(1).IndexOf("%") + 1); ApplyInstructions(instructions); currentLine++; } if (twineParser.IsReaction(line)) { instructions = line.Substring(line.IndexOf("#") + 1, line.Substring(1).IndexOf("#")); ApplyReaction(instructions); currentLine++; } if (twineParser.IsSound(line)) { instructions = line.Substring(line.IndexOf("$") + 1, line.Substring(1).IndexOf("$")); ApplySound(instructions); currentLine++; } if (twineParser.IsBGM(line)) { instructions = line.Substring(line.IndexOf("~") + 1, line.Substring(1).IndexOf("~")); ApplyBGM(instructions); currentLine++; } if (twineParser.IsEnding(line)) { instructions = line.Substring(line.IndexOf("&") + 1, line.Substring(1).IndexOf("&")); ApplyEnding(instructions); currentLine++; } } while (instructions != ""); string speakerName = ""; string dialog = ""; if (line.IndexOf(":") >= 0 && line.IndexOf(":") <= "BEAUREGARD".Length) { speakerName = line.Substring(0, line.IndexOf(":")); dialog = line.Substring(line.IndexOf(":") + 2); } else { dialog = line; } dialogUI.displayDialog(speakerName, dialog); currentLine++; } if (currentLine == lines.Count) { if (currentStory.State == TwineStoryState.Complete) { storyCompleted = true; } else { CleanupFunction = DisplayOptions; } } }