public void Random(string[] args) { for (int i = 0; i < args.Length; i++) { double randVal = RG.NextDouble() * 100; if ((args[i] != "rest" && args[i] != "else" && randVal <= varManager.EvaluateFormula(args[i])) || (args[i] == "rest" || args[i] == "else")) { DialogueManager.uiManager.choices = new string[args.Length]; DialogueManager.uiManager.ChooseChoice(i); return; } } dialogue.FallThrough(); DialogueManager.currentlyActiveChoice.choicesPassed += args.Length; }
public IEnumerator ReadDialogue(Choice subChoice, float time = 0) { //uiManager.dialogueText.text = string.Empty; while (uiManager.isDisplayingText) { yield return(new WaitForEndOfFrame()); } yield return(new WaitForSeconds(time)); currentlyActiveChoice = subChoice; string func; for (int i = dialogueLine[dialogueLine.Count - 1]; i < subChoice.choiceText.Count; i++) { string line = subChoice.choiceText[i]; dialogueLine[dialogueLine.Count - 1] = i; switch (subChoice.choiceText[i].First()) { default: text += (varManager.EvaluateFormula("charVisible") == 1 ? (charManager.currentChar + ": ") : "") + subChoice.choiceText[i]; if (text.Contains("\\n")) { text = text.Replace(" \\n", "\n").Replace("\\n", "\n"); } else { StartCoroutine(uiManager.DisplayText(text)); yield return(new WaitForSeconds(.6f)); canPressButton = true; while (canPressButton) { yield return(new WaitForEndOfFrame()); } text = string.Empty; } break; case '-': //$SwitchCharacter() --- OR --- $SetCast() Quick notation line = line.Replace("-", "").Replace("(", "").Replace(")", ""); string[] args = parser.ParseParameters(line); if (args.Length == 1) { charManager.SetCurrentChar(args[0]); } else { charManager.SetCharacterCast(args); } break; case '*': //$DisplayChoice() Quick notation SaveLine(i + 1); uiManager.DisplayChoices(line.Replace("*", "")); yield break; case '[': //$SetVar() Quick notation line = line.Replace("[", "").Replace("]", "").Replace(" ", ""); func = "setvar(" + line + ")"; functionManager.InterpretFunction(func); break; case '<': //$SetPersistentVar() Quick notations line = line.Replace("<", "").Replace(">", "").Replace(" ", ""); func = "setpersistentvar(" + line + ")"; functionManager.InterpretFunction(func); break; case '|': //$GetVar() Quick notation --OR-- $CompareVar() Quick notation line = line.Replace("|", "").Replace(" ", ""); if (!(line.Contains(">") || line.Contains("<") || line.Contains("="))) { Debug.Log(varManager.EvaluateFormula(line)); break; } else { SaveLine(i + 1); func = "comparevar(" + line + ")"; functionManager.InterpretFunction(func); yield break; } case '%': //$ChanceDialogue() Quick Notation line = line.Replace(" ", "").Replace("%", "").Replace("(", "").Replace(")", ""); SaveLine(i + 1); func = "random(" + line + ")"; functionManager.InterpretFunction(func); yield break; case '$': //Special function func = line.Substring(1, line.IndexOf("(") - 1).ToLower(); if (thes.IsSynonym("wait", func)) { StartCoroutine(uiManager.DisplayText(text, true)); text = string.Empty; } if (functionManager.RequiresStop(line.ToLower().Replace("$", ""))) { SaveLine(i + 1); functionManager.InterpretFunction(line.Replace("$", "")); yield break; } else { functionManager.InterpretFunction(line.Replace("$", "")); break; } } } if (subChoice.parentChoice != subChoice) { FallThrough(); } else { Debug.LogWarning("[Snow# 4] End of File."); } }