예제 #1
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);
            }
        }
예제 #2
0
 /// <summary>
 /// Used internally. Adds a line to the dialogue.
 /// </summary>
 /// <param name="line">The line to be added</param>
 public void AddLine(DialogueLine line)
 {
     dialogueLines.Add(line.id, line);
 }