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) { Horizontal = ExString.EqualsDefault(el.GetAttribute("horizontal"), "yes", false), MaxElemsPerRow = ExParsers.ParseDefault(el.GetAttribute("max-elements-per-row"), -1), Alignment = el.HasAttribute("alignment") ? ExParsers.ParseEnum <TextAnchor>(el.GetAttribute("alignment")) : TextAnchor.UpperCenter }; 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])); }
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(element.GetAttribute("editor-x"), -1)); editorY = Mathf.Max(-1, ExParsers.ParseDefault(element.GetAttribute("editor-y"), -1)); //If there is a "waitUserInteraction" attribute, store if the lines will wait until user interacts keepShowingDialogue = "yes".Equals(element.GetAttribute("keepShowing")); // 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); currentNode.setEditorX(editorX); currentNode.setEditorY(editorY); // 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); } else if (el.Name == "option-node") { random = "yes".Equals(el.GetAttribute("random")); showUserOption = "yes".Equals(el.GetAttribute("showUserOption")); preListening = "yes".Equals(el.GetAttribute("preListening")) || editorX >= 0 || editorY >= 0; currentNode = new OptionConversationNode(random, keepShowing, showUserOption, preListening, editorX, editorY); //XAPI ELEMENTS ((OptionConversationNode)currentNode).setXApiQuestion(el.GetAttribute("question") ?? ""); //END OF XAPI // 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])); }