/** * Adds a new child to the node, in the last position * * @param child * Node for insertion */ public abstract void addChild(ConversationNode child);
public override void addChild(int index, ConversationNode child) { optionNodes.Insert(index, child); }
/** * Tree conversation constructor. * * @param conversationName * Name of the conversation * @param root * Root of the conversation */ public TreeConversation(string conversationName, ConversationNode root) : base(Conversation.TREE, conversationName, root) { }
public override void addChild(ConversationNode child) { optionNodes.Add(child); }
public DialogueConversationNode(bool waitUserInteraction) { dialogue = new List <ConversationLine>(); nextNode = null; this.keepShowing = waitUserInteraction; }
public virtual object Clone() { ConversationNode cn = (ConversationNode)this.MemberwiseClone(); return(cn); }
public object DOMParse(XmlElement element, params object[] parameters) { XmlNode effects; XmlNode end_conversation; string tmpArgVal; // Store the name conversationName = ""; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { conversationName = tmpArgVal; } graphNodes = new List <ConversationNode>(); nodeLinks = new List <List <int> >(); foreach (XmlElement el in element) { //If there is a "editor-x" and "editor-y" attributes editorX = Mathf.Max(-1, ExParsers.ParseDefault(el.GetAttribute("editor-x"), -1)); editorY = Mathf.Max(-1, ExParsers.ParseDefault(el.GetAttribute("editor-y"), -1)); editorCollapsed = ExString.EqualsDefault(el.GetAttribute("editor-collapsed"), "yes", false); //If there is a "waitUserInteraction" attribute, store if the lines will wait until user interacts keepShowingDialogue = ExString.EqualsDefault(el.GetAttribute("waitUserInteraction"), "yes", false); // Node effects end_conversation = el.SelectSingleNode("end-conversation"); if (end_conversation != null) { effects = end_conversation.SelectSingleNode("effect"); } else { effects = el.SelectSingleNode("effect"); } var parsedEffects = DOMParserUtility.DOMParse(effects, parameters) as Effects ?? new Effects(); if (el.Name == "dialogue-node") { currentNode = new DialogueConversationNode(keepShowingDialogue); } else if (el.Name == "option-node") { random = ExString.EqualsDefault(el.GetAttribute("random"), "yes", false); showUserOption = ExString.EqualsDefault(el.GetAttribute("showUserOption"), "yes", false); keepShowing = ExString.EqualsDefault(el.GetAttribute("keepShowing"), "yes", false); preListening = ExString.EqualsDefault(el.GetAttribute("preListening"), "yes", false) || editorX >= 0 || editorY >= 0; var optionConversationNode = new OptionConversationNode(random, keepShowing, showUserOption, preListening); currentNode = optionConversationNode; //XAPI ELEMENTS optionConversationNode.setXApiQuestion(el.GetAttribute("question")); //END OF XAPI } if (currentNode != null) { // Node editor properties currentNode.setEditorX(editorX); currentNode.setEditorY(editorY); currentNode.setEditorCollapsed(editorCollapsed); // Create a new vector for the links of the current node currentLinks = new List <int>(); parseLines(currentNode, el, parameters); currentNode.setEffects(parsedEffects); // Add the current node to the node list, and the set of children references into the node links graphNodes.Add(currentNode); nodeLinks.Add(currentLinks); } } setNodeLinks(); return(new GraphConversation(conversationName, graphNodes[0])); }
private void parseLines(ConversationNode node, XmlElement lines, params object[] parameters) { string tmpArgVal = ""; currentLinks = new List <int>(); bool addline = true; bool timeoutConditions = false; foreach (XmlElement ell in lines.ChildNodes) { addline = true; audioPath = ell.GetAttribute("uri"); // If there is a "synthesize" attribute, store its value synthesizerVoice = ExString.EqualsDefault(ell.GetAttribute("synthesize"), "yes", false); // If there is a "keepShowing" attribute, store its value keepShowingLine = ExString.EqualsDefault(ell.GetAttribute("keepShowing"), "yes", false); if (ell.Name == "speak-player") { // Store the read string into the current node, and then delete the string. The trim is performed so we // don't have to worry with indentations or leading/trailing spaces conversationLine = new ConversationLine(ConversationLine.PLAYER, ell.InnerText); conversationLine.setAudioPath(audioPath); conversationLine.setSynthesizerVoice(synthesizerVoice); conversationLine.setKeepShowing(keepShowingLine); //XAPI ELEMENTS conversationLine.setXApiCorrect("true".Equals(ell.GetAttribute("correct"))); //END OF XAPI } else if (ell.Name == "speak-char") { // If it is a non-player character line, store the character name and audio path (if present) // Set default name to "NPC" characterName = "NPC"; // If there is a "idTarget" attribute, store it characterName = ell.GetAttribute("idTarget"); // Store the read string into the current node, and then delete the string. The trim is performed so we // don't have to worry with indentations or leading/trailing spaces conversationLine = new ConversationLine(characterName, ell.InnerText); conversationLine.setAudioPath(audioPath); conversationLine.setSynthesizerVoice(synthesizerVoice); conversationLine.setKeepShowing(keepShowingLine); } else if (ell.Name == "condition") { addline = false; var currentConditions = DOMParserUtility.DOMParse(ell, parameters) as Conditions ?? new Conditions(); if (timeoutConditions) { ((OptionConversationNode)currentNode).TimeoutConditions = currentConditions; } else { currentNode.getLine(currentNode.getLineCount() - 1).setConditions(currentConditions); } } else if (ell.Name == "child") { addline = false; tmpArgVal = ell.GetAttribute("nodeindex"); if (!string.IsNullOrEmpty(tmpArgVal)) { // Get the child node index, and store it int childIndex = int.Parse(tmpArgVal); currentLinks.Add(childIndex); } } else if (ell.Name == "timeout") { ((OptionConversationNode)currentNode).Timeout = ExParsers.ParseDefault(ell.InnerText, 10f); timeoutConditions = true; addline = false; } else { addline = false; } if (addline) { node.addLine(conversationLine); } } }
public void setRootNode(ConversationNode node) { root = node; }
protected Conversation(int conversationType, string conversationId, ConversationNode root) { this.conversationType = conversationType; this.conversationId = conversationId; this.root = root; }