예제 #1
0
        private void ParseDialogueNode(XmlNode node, DialogueData XMLParent)
        {
            if (node.NodeType == XmlNodeType.Comment)
            {
                return;
            }

            DialogueData dat;

            if (node.Name == "AlternativeDialogue")
            {
                //Dialogue alternative to parent.
                if (XMLParent == null)
                {
                    throw new TechnicalException(node.Name + " is not a valid Custom Spawns Dialogue Token!");
                }

                dat = InitializeDialogueNode(node, XMLParent.Parent, XMLParent); // initialize with same parameters as our XML parent.

                return;
            }

            if (node.Name != "Dialogue")
            {
                throw new TechnicalException(node.Name + " is not a valid Custom Spawns Dialogue Token!");
            }

            //regular dialogue node.

            dat = InitializeDialogueNode(node, XMLParent, null);

            //Now process children.

            foreach (XmlNode child in node)
            {
                ParseDialogueNode(child, dat);
            }
        }
예제 #2
0
        private DialogueData InitializeDialogueNode(XmlNode node, DialogueData XMLParent, DialogueData alternativeTarget)
        {
            DialogueData dat = new DialogueData();

            dat.InjectedToTaleworlds = false;

            //NODE RELATIONS

            dat.Parent = XMLParent;

            if (dat.Parent == null)
            {
                rootDialogueData.Add(dat);
            }
            else
            {
                XMLParent.Children.Add(dat);
            }

            if (alternativeTarget == null)
            {
                dat.Children = new List <DialogueData>();

                dat.Dialogue_ID = "CS_Dialogue_" + currentID.ToString();

                currentID++;
            }
            else
            {
                dat.Children = alternativeTarget.Children;

                dat.Dialogue_ID = alternativeTarget.Dialogue_ID;
            }

            //NODE PROPERTIES

            if (node.Attributes["condition"] != null)
            {
                dat.Condition = ParseCondition(node.Attributes["condition"].Value);
            }

            if (node.Attributes["consequence"] != null)
            {
                dat.Consequence = ParseConsequence(node.Attributes["consequence"].Value);
            }

            bool isPlayerDialogue;

            if (!bool.TryParse(node.Attributes["player"]?.Value, out isPlayerDialogue))
            {
                dat.IsPlayerDialogue = false;
            }
            else
            {
                dat.IsPlayerDialogue = isPlayerDialogue;
            }

            dat.DialogueText = node.Attributes["text"]?.Value;


            return(dat);
        }