public override ConversationLine removeLine(int index)
        {
            ConversationLine tmp = dialogue[index];

            dialogue.RemoveAt(index);
            return(tmp);
        }
Ejemplo n.º 2
0
        public override ConversationLine removeLine(int index)
        {
            ConversationLine item = options[index];

            options.RemoveAt(index);
            return(item);
        }
Ejemplo n.º 3
0
        public object Clone()
        {
            ConversationLine cl = (ConversationLine)this.MemberwiseClone();

            cl.name        = (name != null ? name : null);
            cl.text        = (text != null ? text : null);
            cl.conditions  = (conditions != null ? (Conditions)conditions.Clone() : null);
            cl.keepShowing = keepShowing;
            cl.resources   = resources.ConvertAll(r => r.Clone() as ResourcesUni);
            return(cl);
        }
Ejemplo n.º 4
0
        public object Clone()
        {
            ConversationLine cl = (ConversationLine)this.MemberwiseClone();

            cl.audioPath        = (audioPath != null ? audioPath : null);
            cl.name             = (name != null ? name : null);
            cl.synthesizerVoice = synthesizerVoice;
            cl.text             = (text != null ? text : null);
            cl.conditions       = (conditions != null ? (Conditions)conditions.Clone() : null);
            cl.keepShowing      = keepShowing;
            return(cl);
        }
Ejemplo n.º 5
0
 public override void addLine(int index, ConversationLine line)
 {
     options.Insert(index, line);
 }
Ejemplo n.º 6
0
 public override void addLine(ConversationLine line)
 {
     options.Add(line);
 }
        public override void ParseElement(XmlElement element)
        {
            XmlNodeList
                speakschar   = element.SelectNodes("speak-char"),
                speaksplayer = element.SelectNodes("speak-player"),
                responses    = element.SelectNodes("response"),
                options      = element.SelectNodes("option"),
                effects      = element.SelectNodes("effect"),
                gosback      = element.SelectNodes("go-back");


            string tmpArgVal;

            // Store the name
            string conversationName = "";

            tmpArgVal = element.GetAttribute("id");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                conversationName = tmpArgVal;
            }

            // Create a dialogue node (which will be the root node) and add it to a new tree
            // The content of the tree will be built adding nodes directly to the root
            currentNode     = new DialogueConversationNode();
            conversation    = new TreeConversation(conversationName, currentNode);
            pastOptionNodes = new List <ConversationNode>();

            foreach (XmlElement el in speakschar)
            {
                // Set default name to "NPC"
                characterName = "NPC";
                audioPath     = "";

                // If there is a "idTarget" attribute, store it
                tmpArgVal = el.GetAttribute("idTarget");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    characterName = tmpArgVal;
                }

                // If there is a "uri" attribute, store it as audio path
                tmpArgVal = el.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    audioPath = tmpArgVal;
                }

                // If there is a "uri" attribute, store it as audio path
                tmpArgVal = el.GetAttribute("synthesize");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    string response = tmpArgVal;
                    if (response.Equals("yes"))
                    {
                        synthesizerVoice = true;
                    }
                    else
                    {
                        synthesizerVoice = false;
                    }
                }

                // Store the read string into the current node, and then delete the string. The trim is performed so we
                // don't
                // have to worry with indentations or leading/trailing spaces
                ConversationLine line = new ConversationLine(characterName, el.InnerText);
                if (audioPath != null && !this.audioPath.Equals(""))
                {
                    line.setAudioPath(audioPath);
                }

                line.setSynthesizerVoice(synthesizerVoice);
                currentNode.addLine(line);
            }

            foreach (XmlElement el in speaksplayer)
            {
                audioPath = "";

                // If there is a "uri" attribute, store it as audio path
                tmpArgVal = el.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    audioPath = tmpArgVal;
                }
                // If there is a "uri" attribute, store it as audio path
                tmpArgVal = el.GetAttribute("synthesize");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    string response = tmpArgVal;
                    if (response.Equals("yes"))
                    {
                        synthesizerVoice = true;
                    }
                    else
                    {
                        synthesizerVoice = false;
                    }
                }

                // Store the read string into the current node, and then delete the string. The trim is performed so we
                // don't have to worry with indentations or leading/trailing spaces
                ConversationLine line = new ConversationLine(ConversationLine.PLAYER, el.InnerText);
                if (audioPath != null && !this.audioPath.Equals(""))
                {
                    line.setAudioPath(audioPath);
                }
                line.setSynthesizerVoice(synthesizerVoice);

                currentNode.addLine(line);
            }

            foreach (XmlElement el in responses)
            {
                //If there is a "random" attribute, store is the options will be random
                tmpArgVal = el.GetAttribute("random");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("yes"))
                    {
                        random = true;
                    }
                    else
                    {
                        random = false;
                    }
                }

                //If there is a "keepShowing" attribute, keep the previous conversation line showing
                tmpArgVal = el.GetAttribute("keepShowing");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("yes"))
                    {
                        keepShowing = true;
                    }
                    else
                    {
                        keepShowing = false;
                    }
                }

                //If there is a "showUserOption" attribute, identify if show the user response at option node
                tmpArgVal = el.GetAttribute("showUserOption");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("yes"))
                    {
                        showUserOption = true;
                    }
                    else
                    {
                        showUserOption = false;
                    }
                }


                //If there is a "showUserOption" attribute, identify if show the user response at option node
                tmpArgVal = el.GetAttribute("preListening");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("yes"))
                    {
                        preListening = true;
                    }
                    else
                    {
                        preListening = false;
                    }
                }

                //If there is a "x" and "y" attributes with the position where the option node has to be painted,
                tmpArgVal = el.GetAttribute("preListening");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("yes"))
                    {
                        preListening = true;
                    }
                    else
                    {
                        preListening = false;
                    }
                }

                //If there is a "x" and "y" attributes with the position where the option node has to be painted
                tmpArgVal = el.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x = int.Parse(tmpArgVal);
                }
                tmpArgVal = el.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y = int.Parse(tmpArgVal);
                }

                // Create a new OptionNode, and link it to the current node
                ConversationNode nuevoNodoOpcion = new OptionConversationNode(random, keepShowing, showUserOption, preListening);
                nuevoNodoOpcion.setEditorX(x);
                nuevoNodoOpcion.setEditorY(y);
                currentNode.addChild(nuevoNodoOpcion);

                // Change the actual node for the option node recently created
                currentNode = nuevoNodoOpcion;
            }

            {
                var iterator = options.GetEnumerator();
                while (iterator.MoveNext())
                {
                    currentNode = pastOptionNodes[pastOptionNodes.Count - 1];
                    pastOptionNodes.RemoveAt(pastOptionNodes.Count - 1);
                }
            }

            foreach (XmlElement el in effects)
            {
                currentEffects = new Effects();
                //new EffectSubParser_(currentEffects, chapter).ParseElement(el);
                currentNode.setEffects(currentEffects);
            }
            {
                var i = gosback.GetEnumerator();
                while (i.MoveNext())
                {
                    currentNode.addChild(pastOptionNodes[pastOptionNodes.Count - 1]);
                }
            }

            chapter.addConversation(new GraphConversation((TreeConversation)conversation));
        }
Ejemplo n.º 8
0
        private void parseLines(ConversationNode node, XmlElement lines, params object[] parameters)
        {
            string tmpArgVal = "";

            currentLinks = new List <int>();
            bool addline           = true;
            bool timeoutConditions = false;

            foreach (XmlElement ell in lines.ChildNodes)
            {
                addline = true;
                // If there is a "keepShowing" attribute, store its value
                keepShowingLine = ExString.EqualsDefault(ell.GetAttribute("keepShowing"), "yes", false);

                if (ell.Name == "speak-player")
                {
                    // Store the read string into the current node, and then delete the string. The trim is performed so we
                    // don't have to worry with indentations or leading/trailing spaces


                    conversationLine = new ConversationLine(ConversationLine.PLAYER, GetText(ell));
                    conversationLine.setKeepShowing(keepShowingLine);
                    //XAPI ELEMENTS
                    conversationLine.setXApiCorrect("true".Equals(ell.GetAttribute("correct")));
                    //END OF XAPI
                    // RESOURCES
                    foreach (var res in DOMParserUtility.DOMParse <ResourcesUni>(ell.SelectNodes("resources"), parameters))
                    {
                        conversationLine.addResources(res);
                    }
                }
                else if (ell.Name == "speak-char")
                {
                    // If it is a non-player character line, store the character name and audio path (if present)
                    // Set default name to "NPC"
                    characterName = "NPC";
                    // If there is a "idTarget" attribute, store it
                    characterName = ell.GetAttribute("idTarget");

                    // Store the read string into the current node, and then delete the string. The trim is performed so we
                    // don't have to worry with indentations or leading/trailing spaces
                    conversationLine = new ConversationLine(characterName, GetText(ell));
                    conversationLine.setKeepShowing(keepShowingLine);
                    // RESOURCES
                    foreach (var res in DOMParserUtility.DOMParse <ResourcesUni>(ell.SelectNodes("resources"), parameters))
                    {
                        conversationLine.addResources(res);
                    }
                }
                else if (ell.Name == "condition")
                {
                    addline = false;
                    var currentConditions = DOMParserUtility.DOMParse(ell, parameters) as Conditions ?? new Conditions();

                    if (timeoutConditions)
                    {
                        ((OptionConversationNode)currentNode).TimeoutConditions = currentConditions;
                    }
                    else
                    {
                        currentNode.getLine(currentNode.getLineCount() - 1).setConditions(currentConditions);
                    }
                }
                else if (ell.Name == "child")
                {
                    addline   = false;
                    tmpArgVal = ell.GetAttribute("nodeindex");
                    if (!string.IsNullOrEmpty(tmpArgVal))
                    {
                        // Get the child node index, and store it
                        int childIndex = int.Parse(tmpArgVal);
                        currentLinks.Add(childIndex);
                    }
                }
                else if (ell.Name == "timeout")
                {
                    ((OptionConversationNode)currentNode).Timeout = ExParsers.ParseDefault(GetText(ell), CultureInfo.InvariantCulture, 10f);
                    timeoutConditions = true;
                    addline           = false;
                }
                else
                {
                    addline = false;
                }

                if (addline)
                {
                    node.addLine(conversationLine);
                }
            }
        }
        private void parseLines(ConversationNode node, XmlElement lines, params object[] parameters)
        {
            string tmpArgVal = "";

            currentLinks = new List <int>();
            bool addline = true;

            foreach (XmlElement ell in lines.ChildNodes)
            {
                addline = true;

                audioPath = ell.GetAttribute("uri");
                // If there is a "synthesize" attribute, store its value
                synthesizerVoice = "yes".Equals(ell.GetAttribute("synthesize"));
                // If there is a "keepShowing" attribute, store its value
                keepShowingLine = "yes".Equals(ell.GetAttribute("keepShowing"));

                if (ell.Name == "speak-player")
                {
                    // Store the read string into the current node, and then delete the string. The trim is performed so we
                    // don't have to worry with indentations or leading/trailing spaces
                    conversationLine = new ConversationLine(ConversationLine.PLAYER, ell.InnerText);

                    conversationLine.setAudioPath(audioPath);
                    conversationLine.setSynthesizerVoice(synthesizerVoice);
                    conversationLine.setKeepShowing(keepShowingLine);

                    //XAPI ELEMENTS
                    conversationLine.setXApiCorrect("true".Equals(ell.GetAttribute("correct")));
                    //END OF XAPI
                }
                else if (ell.Name == "speak-char")
                {
                    // If it is a non-player character line, store the character name and audio path (if present)
                    // Set default name to "NPC"
                    characterName = "NPC";
                    // If there is a "idTarget" attribute, store it
                    characterName = ell.GetAttribute("idTarget") ?? "";

                    // Store the read string into the current node, and then delete the string. The trim is performed so we
                    // don't have to worry with indentations or leading/trailing spaces
                    conversationLine = new ConversationLine(characterName, ell.InnerText);
                    conversationLine.setAudioPath(audioPath);
                    conversationLine.setSynthesizerVoice(synthesizerVoice);
                    conversationLine.setKeepShowing(keepShowingLine);
                }
                else if (ell.Name == "condition")
                {
                    addline = false;
                    var currentConditions = DOMParserUtility.DOMParse(ell, parameters) as Conditions ?? new Conditions();
                    currentNode.getLine(currentNode.getLineCount() - 1).setConditions(currentConditions);
                }
                else if (ell.Name == "child")
                {
                    addline   = false;
                    tmpArgVal = ell.GetAttribute("nodeindex");
                    if (!string.IsNullOrEmpty(tmpArgVal))
                    {
                        // Get the child node index, and store it
                        int childIndex = int.Parse(tmpArgVal);
                        currentLinks.Add(childIndex);
                    }
                }
                else
                {
                    addline = false;
                }

                if (addline)
                {
                    node.addLine(conversationLine);
                }
            }
        }
 public override void addLine(int index, ConversationLine line)
 {
     dialogue.Insert(index, line);
 }
 public override void addLine(ConversationLine line)
 {
     dialogue.Add(line);
 }
Ejemplo n.º 12
0
 /**
  * Adds a new line to the node, in the specified position
  *
  * @param index
  *            Index for insertion
  * @param line
  *            Line for insertion
  */
 public abstract void addLine(int index, ConversationLine line);
Ejemplo n.º 13
0
 /**
  * Adds a new line to the node, in the last position
  *
  * @param line
  *            Line for insertion
  */
 public abstract void addLine(ConversationLine line);