/// <summary> /// Reads a DialogCommand from an XML node /// </summary> /// <param name="node">The node to read from</param> /// <returns>A DialogCommand read from the node</returns> public static DialogueCommand ReadFromXML(XmlNode node) { // Define a new command to return the result in DialogueCommand command = new DialogueCommand(); // Set the command to the node's inner text command.m_command = node.InnerText; // If the node has the condtion attribute defined, load it's value into the condition if (node.Attributes["condition"] != null) { command.m_condition = node.Attributes["condition"].Value; } // Return the result return(command); }
/// <summary> /// Reads a DialogChoice from an XML node /// </summary> /// <param name="node">The node to read from</param> /// <returns>A DialogChoice read from the node</returns> public static DialogueChoice ReadFromXML(XmlNode node) { DialogueChoice choice = new DialogueChoice(); if (node.Attributes["id"] != null) { choice.m_id = int.Parse(node.Attributes["id"].Value); } // If the Next ID attribute exists, read it if (node.Attributes["nextId"] != null) { choice.m_nextId = int.Parse(node.Attributes["nextId"].Value); } // If the condition attribute exists, read it if (node.Attributes["condition"] != null) { choice.m_condition = node.Attributes["condition"].Value; } // If the message node exists, save it to the output if (node["message"] != null) { choice.m_message = node["message"].InnerText; } // Get the commands subnode XmlNode commands = node.SelectSingleNode("commands"); // If the commands list is defined if (commands != null) { // Iterate over all subnodes foreach (XmlNode commandNode in commands) { // Load the command from the subnode choice.m_commands.Add(DialogueCommand.ReadFromXML(commandNode)); } } // Return the result return(choice); }