Esempio n. 1
0
File: MyXml.cs Progetto: VicBoss/KR
        private static DialogNode loadNode(XmlElement xmlEl, 
            ref Conversation conversation)
        {
            string id = xmlEl.GetAttribute("id");
            string npcPhrase = xmlEl.GetAttribute("npcPhrase");
            string voiceFile = xmlEl.GetAttribute("voiceFile");
            DialogNode node = new DialogNode(id, npcPhrase, voiceFile);

            XmlNodeList responsesXNL = xmlEl.ChildNodes;
            for (int j = 0; j < responsesXNL.Count; j++)
            {
                XmlElement responseXE = (XmlElement)responsesXNL[j];
                string pcPhrase = responseXE.GetAttribute("pcPhrase");
                string link = responseXE.GetAttribute("link");
                ResponseLinkType linkType = ResponseLinkType.dialogNode;
                if (responseXE.GetAttribute("linkType").
                    Equals("dialogNode"))
                    linkType = ResponseLinkType.dialogNode;
                else if (responseXE.GetAttribute("linkType").
                    Equals("endConversation"))
                    linkType = ResponseLinkType.endConversation;
                else
                    linkType = ResponseLinkType.endAndChangeConversation;

                string switchConv = responseXE.
                    GetAttribute("switchConversation");
                bool onlyAllowOnce = bool.Parse(responseXE.
                    GetAttribute("onlyAllowOnce"));

                DialogResponse response = new DialogResponse(pcPhrase, link, 
                    onlyAllowOnce, linkType, switchConv);
                node.addResponse(response);
                if (responseXE.HasChildNodes)
                {
                    XmlElement childNode = (XmlElement)responseXE.FirstChild;
                    DialogNode dn  = loadNode(childNode, ref conversation);
                    response.childNode = dn;
                    conversation.addDialogNode(dn);
                }
            }
            return node;
        }