public IEnumerator VariableStorage_OnExternalChanges_ReturnsExpectedValue() { var runner = GameObject.FindObjectOfType <DialogueRunner>(); DialogueRunnerMockUI dialogueUI = GameObject.FindObjectOfType <DialogueRunnerMockUI>(); var variableStorage = GameObject.FindObjectOfType <VariableStorageBehaviour>(); runner.StartDialogue("VariableTest"); yield return(null); Assert.AreEqual("Jane: Yes! I've already walked 0 laps!", dialogueUI.CurrentLine); variableStorage.SetValue("$laps", 1); runner.Stop(); runner.StartDialogue("VariableTest"); yield return(null); Assert.AreEqual("Jane: Yes! I've already walked 1 laps!", dialogueUI.CurrentLine); variableStorage.SetValue("$laps", 5); runner.Stop(); runner.StartDialogue("FunctionTest"); yield return(null); Assert.AreEqual("Jane: Yes! I've already walked 25 laps!", dialogueUI.CurrentLine); runner.Stop(); runner.StartDialogue("FunctionTest2"); yield return(null); Assert.AreEqual("Jane: Yes! I've already walked arg! i am a pirate no you're not! arg! i am a pirate laps!", dialogueUI.CurrentLine); runner.Stop(); runner.StartDialogue("ExternalFunctionTest"); yield return(null); Assert.AreEqual("Jane: Here's a function from code that's in another assembly: 42", dialogueUI.CurrentLine); runner.Stop(); runner.StartDialogue("BuiltinsTest"); yield return(null); Assert.AreEqual("Jane: round(3.522) = 4; round_places(3.522, 2) = 3.52; floor(3.522) = 3; floor(-3.522) = -4; ceil(3.522) = 4; ceil(-3.522) = -3; inc(3.522) = 4; inc(4) = 5; dec(3.522) = 3; dec(3) = 2; decimal(3.522) = 0.5220001; int(3.522) = 3; int(-3.522) = -3;", dialogueUI.CurrentLine); // dialogueUI.ReadyForNextLine(); }
public IEnumerator HandleLine_OnValidYarnFile_SendCorrectLinesToUI() { var runner = GameObject.FindObjectOfType <DialogueRunner>(); DialogueRunnerMockUI dialogueUI = GameObject.FindObjectOfType <DialogueRunnerMockUI>(); runner.StartDialogue(runner.startNode); yield return(null); Assert.AreEqual("Spieler: Kannst du mich hören? 2", dialogueUI.CurrentLine); dialogueUI.Advance(); Assert.AreEqual("NPC: Klar und deutlich.", dialogueUI.CurrentLine); dialogueUI.Advance(); Assert.AreEqual(2, dialogueUI.CurrentOptions.Count); Assert.AreEqual("Mir reicht es.", dialogueUI.CurrentOptions[0]); Assert.AreEqual("Nochmal!", dialogueUI.CurrentOptions[1]); }
public IEnumerator HandleLine_OnViewsArrayContainingNullElement_SendCorrectLinesToUI() { var runner = GameObject.FindObjectOfType <DialogueRunner>(); DialogueRunnerMockUI dialogueUI = GameObject.FindObjectOfType <DialogueRunnerMockUI>(); // Insert a null element into the dialogue views array var viewArrayWithNullElement = runner.dialogueViews.ToList(); viewArrayWithNullElement.Add(null); runner.dialogueViews = viewArrayWithNullElement.ToArray(); runner.StartDialogue(runner.startNode); yield return(null); Assert.AreEqual("Spieler: Kannst du mich hören? 2", dialogueUI.CurrentLine); dialogueUI.Advance(); Assert.AreEqual("NPC: Klar und deutlich.", dialogueUI.CurrentLine); dialogueUI.Advance(); Assert.AreEqual(2, dialogueUI.CurrentOptions.Count); Assert.AreEqual("Mir reicht es.", dialogueUI.CurrentOptions[0]); Assert.AreEqual("Nochmal!", dialogueUI.CurrentOptions[1]); }
private void Awake() { instance = this; }