Exemplo n.º 1
0
        static void processDialogueEntries(ref EasyFile file, XElement entriesNode)
        {
            foreach (XElement dialogueEntryNode in entriesNode.Elements())
            {
                DialogueEntry entry = new DialogueEntry();
                foreach (XElement node in dialogueEntryNode.Elements())
                {

                    if (node.Name.ToString() == "id")
                    {
                        entry.id = node.Value.ToString();
                    }
                    if (node.Name.ToString() == "maxLineId")
                    {
                        string noOfLines = node.Value.ToString();
                        int m = -1;
                        try
                        {
                            m = Int32.Parse(noOfLines);
                        }
                        catch (FormatException e)
                        {
                            Console.WriteLine(e.Message);
                        }
                        entry.maxLineId = m;

                    }
                    if (node.Name.ToString() == "speakers")
                    {
                        foreach (XElement speakerNode in node.Elements())
                        {
                            if (speakerNode.Name.ToString() == "string")
                            {
                                entry.speakers.Add(speakerNode.Value.ToString());
                            }

                        }
                    }

                }
                file.entries.Add(entry);

            }
        }
Exemplo n.º 2
0
        static void processDialogueLines(ref EasyFile file, XElement lines)
        {
            foreach (XElement line in lines.Elements())
            {
                DialogueLine dLine = new DialogueLine();
                foreach (XElement node in line.Elements())
                {
                    if (node.Name.ToString() == "id")
                    {
                        string id = node.Value.ToString();
                        try
                        {
                            dLine.id = Int32.Parse(id);
                        }
                        catch (FormatException e)
                        {
                            Console.WriteLine(e.Message);
                            dLine.id = -1;
                        }
                    }

                    if (node.Name.ToString() == "dialogueEntry")
                    {
                        dLine.dialogueEntry = node.Value.ToString();
                    }
                    if (node.Name.ToString() == "dialogue")
                    {
                        dLine.dialogue = node.Value.ToString();
                    }
                    if (node.Name.ToString() == "output")
                    {
                        foreach (XElement outputLine in node.Elements())
                        {
                            if (outputLine.Name.ToString() == "int")
                            {
                                string id = outputLine.Value.ToString();
                                try
                                {
                                    dLine.output.Add(Int32.Parse(id));
                                }
                                catch (FormatException e)
                                {
                                    Console.WriteLine(e.Message);
                                }
                            }

                        }
                    }
                    if (node.Name.ToString() == "userData")
                    {
                        dLine.userData = node.Value.ToString();
                    }
                    if (node.Name.ToString() == "speaker")
                    {
                        dLine.speaker = node.Value.ToString();
                    }

                }
                file.lines.Add(dLine);
            }
        }
Exemplo n.º 3
0
        public static EasyFile LoadEasyFileFromPath(string path)
        {
            XDocument doc = new XDocument();

            try
            {
                doc = XDocument.Load(path);
            }
            catch (Exception e)
            {

                Console.Write("exception found");
            }
            XElement _root = doc.Root;
            Console.WriteLine("processing loadDialogueMatcher  : " + _root.Name);

            //file.

            foreach (XElement currentNode in _root.Elements())
            {
                if (currentNode.Name.ToString() == "name")
                {
                    easyFile = new EasyFile(currentNode.Value.ToString());

                }
                else if (currentNode.Name.ToString() == "entries")
                {
                    processDialogueEntries(ref easyFile, currentNode);
                }
                else if (currentNode.Name.ToString() == "lines")
                {
                    processDialogueLines(ref easyFile, currentNode);
                }

            }

            return easyFile;
        }