public void SelectOption(DialogueOption dialogueOption) { if (currentDialogueController == null) { Debug.LogWarning("No dialogue in progress", this); return; } currentDialogueController.SelectOption(dialogueOption); }
public void SelectOption(DialogueOption dialogueOption) { if (m_currentDialogueNode == null) { Debug.LogWarning("No dialogue in progress", this); return; } if (m_currentDialogueNode.options.Count == 0) { Debug.LogWarning("The current dialogue is not proceeding to options", this); return; } List <DialogueOption> dialogueOptions = m_currentDialogueNode.options; DialogueOption selectedOption = dialogueOptions.Find((DialogueOption d) => d == dialogueOption); if (selectedOption == null) { Debug.LogWarning("Desire dialogue option is not in options of current dialogue node", this); return; } EmitDialogueOptionsEnd(dialogueOptions); ApplyVariableValues(selectedOption.assignments); m_currentDialogueNode = m_dialogue.GetNextDialogueNode(m_currentDialogueNode, m_variableValues); if (m_currentDialogueNode == null) { Debug.LogWarning("No dialogue node found", this); EndDialogue(); return; } EmitDialogueTextBegin(m_currentDialogueNode.dialogueText); }
public void TestOptions() { Assert.AreEqual(m_currentDialogue, null); /** * Test to select Option 1 */ // begin dialogue m_dialogueController.StartDialogue(); Assert.AreEqual(m_currentDialogue, m_dialogue); // begin text m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, "Begin Text"); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, "Text 1"); Assert.AreEqual(m_currentDialogueOptions, null); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, null); Assert.AreNotEqual(m_currentDialogueOptions, null); // Dialogue options keep emitting m_dialogueController.Next(); Assert.AreNotEqual(m_currentDialogueOptions, null); Assert.AreEqual(m_currentDialogueOptions.Count, 2); DialogueOption dialogueOption1 = m_currentDialogueOptions[0]; m_dialogueController.SelectOption(dialogueOption1); Assert.AreEqual(m_currentDialogueText, "Text 2.1"); Assert.AreEqual(m_currentDialogueOptions, null); // No effect m_dialogueController.SelectOption(dialogueOption1); Assert.AreEqual(m_currentDialogueText, "Text 2.1"); Assert.AreEqual(m_currentDialogueOptions, null); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, null); // current dialogue has ended Assert.AreEqual(m_currentDialogue, null); /** * Test to select Option 1 */ // begin dialogue m_dialogueController.StartDialogue(); Assert.AreEqual(m_currentDialogue, m_dialogue); // begin text m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, "Begin Text"); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, "Text 1"); Assert.AreEqual(m_currentDialogueOptions, null); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, null); Assert.AreNotEqual(m_currentDialogueOptions, null); // Dialogue options keep emitting m_dialogueController.Next(); Assert.AreNotEqual(m_currentDialogueOptions, null); Assert.AreEqual(m_currentDialogueOptions.Count, 2); DialogueOption dialogueOption2 = m_currentDialogueOptions[0]; m_dialogueController.SelectOption(dialogueOption2); Assert.AreEqual(m_currentDialogueText, "Text 2.1"); Assert.AreEqual(m_currentDialogueOptions, null); // No effect m_dialogueController.SelectOption(dialogueOption2); Assert.AreEqual(m_currentDialogueText, "Text 2.1"); Assert.AreEqual(m_currentDialogueOptions, null); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, null); /** * Test to select Option 2 */ // begin dialogue m_dialogueController.StartDialogue(); Assert.AreEqual(m_currentDialogue, m_dialogue); // begin text m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, "Begin Text"); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, "Text 1"); Assert.AreEqual(m_currentDialogueOptions, null); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, null); Assert.AreNotEqual(m_currentDialogueOptions, null); // Dialogue options keep emitting m_dialogueController.Next(); Assert.AreNotEqual(m_currentDialogueOptions, null); Assert.AreEqual(m_currentDialogueOptions.Count, 2); DialogueOption dialogueOption3 = m_currentDialogueOptions[1]; m_dialogueController.SelectOption(dialogueOption3); Assert.AreEqual(m_currentDialogueText, "Text 2.2"); Assert.AreEqual(m_currentDialogueOptions, null); // No effect m_dialogueController.SelectOption(dialogueOption3); Assert.AreEqual(m_currentDialogueText, "Text 2.2"); Assert.AreEqual(m_currentDialogueOptions, null); m_dialogueController.Next(); Assert.AreEqual(m_currentDialogueText, null); }