private void HandleTrustUI(DialogueParser.DialogueLine l) { int rp = Mathf.Clamp(Stats.relationshipPoints[l.node.character], -1, 1) + 1; if (trustUIActive && l.node.character != Character.player) { for (int i = 0; i < trustUI.Count; ++i) { if (rp == i) { if (!trustUI[i].IsVisible) { trustUI[i].SelfFadeIn(); } } else { if (trustUI[i].IsVisible) { trustUI[i].SelfFadeOut(); } } } } }
/// <summary> /// Updates the current dialogue line number once the player has clicked on a dialogue option. /// </summary> private void UpdateLine(ref DialogueParser.DialogueLine current, DialogueParser.DialogueLine newLine) { current = newLine; presentingOptions = false; foreach (Button b in dialogueButtons) { b.gameObject.SetActive(false); b.onClick.RemoveAllListeners(); } }
/// <summary> /// Runs the dialogue for the scene loaded in the dialogue parser. /// </summary> private IEnumerator RunDialogue() { Dictionary <Character, Expression> lastExpression = new Dictionary <Character, Expression>(); for (int i = 0; i < dParser.Lines.Count; ++i) { DialogueParser.DialogueLine d = dParser.Lines[i]; if (d.character == Character.end) { break; } if (d.character != Character.options) { if (!lastExpression.ContainsKey(d.character) || d.expression != lastExpression[d.character]) { SetExpression(d.character, d.expression, d.position == "R"); } if (!lastExpression.ContainsKey(d.character)) { lastExpression.Add(d.character, d.expression); } else { lastExpression[d.character] = d.expression; } yield return(CharacterDialogue(d.character, d.content)); } else { ClearTexts(); presentingOptions = true; for (int j = 0; j < d.options.Length; ++j) { dialogueButtons[j].gameObject.SetActive(true); dialogueButtons[j].GetComponent <TextMeshProUGUI>().text = d.options[j].Split(':')[0]; // On click gets called after j is incremented, so we have to save it as a temp value. int temp = j; dialogueButtons[temp].onClick.AddListener(() => UpdateLine(ref i, int.Parse(d.options[temp].Split(':')[1]))); } questionText.text = lastQuestion; question.SelfFadeIn(); while (presentingOptions) { yield return(null); } question.SelfFadeOut(); } } FinishText(); }
/// <summary> /// Runs the dialogue for the scene loaded in the dialogue parser. /// </summary> private IEnumerator RunDialogue(int scene, bool dialogue, Character c) { if (c == Character.stan && scene == 4) { SoundManager.SongEvent(1); } Dictionary <Character, Expression> lastExpression = new Dictionary <Character, Expression>(); if (dialogue) { yield return(dParser.LoadDialogue(Path.Combine(Path.Combine("Dialogue", c.ToString()), "Dialogue" + scene))); if (trustUIActive) { Stats.CurrentTime += Stats.DIALOGUE_START_TIME_INCREMENT; } } else { yield return(dParser.LoadDialogue(Path.Combine(Path.Combine("Snippet", c.ToString()), "Snippet" + scene))); } DialogueParser.DialogueLine l = dParser.Head; while (true) { // Handle things done before dialogue string position = l.node.character == Character.player || l.node.forceLeft ? "L" : "R"; Image e = (position == "R" ? rightCharacterPortraits : leftCharacterPortraits)[(int)l.node.character][(int)l.node.expression].GetComponent <Image>(); HandleTrustUI(l); e.color = Color.white; // Handle dialogue AssignExpression(ref lastExpression, l.node.character, l.node.expression, position); yield return(CharacterDialogue(l.node.character, l.node.dialogue)); // Handle things after dialogue e.color = new Color(135 / 255.0f, 135 / 255.0f, 135 / 255.0f, 165 / 255.0f); if (l.node.longOption) { IncrementDialogueTime(); } if (l.node.positive) { AddRelationshipPoints(l.node.characterAffected, 1); } if (l.node.negative) { AddRelationshipPoints(l.node.characterAffected, -1); } if (l.node.fired) { FiredCharacter(l.node.characterAffected); } if (-1 < l.node.infoGathered && l.node.infoGathered < 11) { GotInfoOnCharacter(l.node.characterAffected, l.node.infoGathered); } l.RestrictConnections(); if (l.connections.Count < 2) { if (l.connections.Count == 1) { l = l.connections[0]; } else { break; } } else { ClearTexts(); presentingOptions = true; for (int j = 0; j < l.connections.Count; ++j) { dialogueButtons[j].gameObject.SetActive(true); dialogueButtons[j].GetComponent <TextMeshProUGUI>().text = Stats.ReplacePlayerName(l.connections[j].node.dialogue); // On click gets called after j is incremented, so we have to save it as a temp value. int temp = j; dialogueButtons[j].onClick.AddListener(() => UpdateLine(ref l, l.connections[temp])); } questionText.text = l.node.dialogue; question.SelfFadeIn(); while (presentingOptions) { yield return(null); } question.SelfFadeOut(); } } if (c == Character.stan && scene == 4) { if (Stats.fired[Character.stan]) { SoundManager.SongEvent(5); } else { SoundManager.SongEvent(4); } } if (scene > 10) { Stats.CurrentTime = 60 * 17; } FinishText(); }
/// <summary> /// Runs the dialogue for the scene loaded in the dialogue parser. /// </summary> private IEnumerator RunDialogue() { Dictionary <Character, Expression> lastExpression = new Dictionary <Character, Expression>(); for (int i = 0; i < dParser.Lines.Count; ++i) { DialogueParser.DialogueLine d = dParser.Lines[i]; if (d.character == Character.end) { break; } if (d.character != Character.options) { AssignExpression(ref lastExpression, d.character, d.expression, d.position); if (d.receiving != Character.end) { AssignExpression(ref lastExpression, d.receiving, d.rExpression, d.position == "R" ? "L" : "R"); } yield return(CharacterDialogue(d.character, d.content)); if (d.options[0] != null) { if (d.options.Length == 1) { UpdateLine(ref i, int.Parse(d.options[0])); } } } else { ClearTexts(); presentingOptions = true; for (int j = 0; j < d.options.Length; ++j) { dialogueButtons[j].gameObject.SetActive(true); dialogueButtons[j].GetComponent <TextMeshProUGUI>().text = d.options[j].Split(':')[0]; // On click gets called after j is incremented, so we have to save it as a temp value. string[] options = d.options[j].Split(':'); dialogueButtons[j].onClick.AddListener(() => UpdateLine(ref i, int.Parse(options[1]))); // Handle option stat modifications if present for (int k = 2; k < options.Length; k++) { if (options[k].ToUpper() == "L") { dialogueButtons[j].onClick.AddListener(IncrementDialogueTime); } else { string[] statMods = options[k].Split(','); Character c = (Character)Enum.Parse(typeof(Character), statMods[0]); if (statMods[1] == "+") { dialogueButtons[j].onClick.AddListener(() => AddRelationshipPoints(c, 1)); } else if (statMods[1] == "-") { dialogueButtons[j].onClick.AddListener(() => AddRelationshipPoints(c, -1)); } else { dialogueButtons[j].onClick.AddListener(() => GotInfoOnCharacter(c, int.Parse(statMods[1]))); } } } } questionText.text = lastQuestion; question.SelfFadeIn(); while (presentingOptions) { yield return(null); } question.SelfFadeOut(); } } FinishText(); }