Пример #1
0
            public InsertNodeTool(ConversationDataControl content, ConversationNodeDataControl parent, int nodeType, int index)
            {
                this.content    = content;
                this.isRootNode = parent == null;
                this.parent     = isRootNode ? content.getRootNode() : parent;
                ConversationNode node = null;

                switch (nodeType)
                {
                case DIALOG_NODE: node = new DialogueConversationNode(); break;

                case OPTION_NODE: node = new OptionConversationNode(); break;
                }


                this.index = index;
                var parentRect = isRootNode ? new RectInt(0, 25, 0, 0) : parent.getEditorRect();
                var childRect  = isRootNode ? content.getRootNode().getEditorRect() : parent.getChilds()[index].getEditorRect();

                var center = (parentRect.center + childRect.center) / 2f;

                node.setEditorX((int)(center.x - node.getEditorWidth() / 2f));
                node.setEditorY((int)(center.y - node.getEditorHeight() / 2f));

                this.newNode  = ConversationNodeDataControlFactory.Instance.CreateDataControlFor(content, node);
                this.subTools = CreateTools();
            }
Пример #2
0
            public LinkConversationNodeTool(ConversationDataControl conversation, ConversationNodeDataControl father, int nodeType, int index)
            {
                this.father = father;
                ConversationNode childNode = null;

                if (nodeType == DIALOG_NODE)
                {
                    childNode = new DialogueConversationNode();
                }
                else if (nodeType == OPTION_NODE)
                {
                    childNode = new OptionConversationNode();
                }
                else
                {
                    throw new Exception("Not valid node type!");
                }
                var parentRect = this.father.getEditorRect();

                childNode.setEditorX(parentRect.x + parentRect.width + 35);
                childNode.setEditorY(parentRect.y);

                child = this.father.conversation.getNodeDataControl(childNode);

                this.father     = father;
                this.controller = Controller.Instance;
                this.index      = index;
            }
Пример #3
0
        public void clicked(int option)
        {
            this.child = option;
            OptionConversationNode onode = ((OptionConversationNode)node);

            if (option == onode.getChildCount()) // Timeout
            {
                // TODO Analytics for timeout
                return;
            }

            if (TrackerAsset.Instance.Started && !string.IsNullOrEmpty(onode.getXApiQuestion()))
            {
                holder.EndTracePending();
                isTracePending = true;
                xAPISuccess    = onode.getLine(option).getXApiCorrect();
                xAPIQuestion   = onode.getXApiQuestion();
                xAPIResponse   = onode.getLine(option).getText().Replace(",", " ");
                trace          = TrackerAsset.Instance.Alternative.Selected(xAPIQuestion, xAPIResponse, AlternativeTracker.Alternative.Question);
                Game.Instance.GameState.BeginChangeAmbit(trace);
                trace.Result.Duration = Time.realtimeSinceStartup - startTime;
                trace.SetPartial();
                Game.Instance.OnActionCanceled += ActionCancelled;
            }
        }
Пример #4
0
            public AddRemoveConversationNodeTool(int nodeType, ConversationNodeDataControl parent, int index)
            {
                this.parent = parent;

                ConversationNode child = null;

                if (nodeType == DIALOG_NODE)
                {
                    child = new DialogueConversationNode();
                }
                else if (nodeType == OPTION_NODE)
                {
                    child = new OptionConversationNode();
                }

                if (child != null)
                {
                    var parentRect = parent.getEditorRect();
                    child.setEditorX(parentRect.x + parentRect.width + 35);
                    child.setEditorY(parentRect.y);

                    this.childDataControl = parent.conversation.getNodeDataControl(child);
                    this.index            = index; // Insert at last
                    this.add = true;
                }
            }
    /*
     * @Override
     * public Object clone() throws CloneNotSupportedException
     * {
     *
     *  OptionConversationNode ocn = (OptionConversationNode) super.clone( );
     *  ocn.effectConsumed = effectConsumed;
     *  ocn.effects = ( effects != null ? (Effects) effects.clone( ) : null );
     *  /*		if (optionNodes != null) {
     *                          ocn.optionNodes = new List<ConversationNode>();
     *                          for (ConversationNode cn : optionNodes)
     *                                  ocn.optionNodes.add((ConversationNode) cn.clone());
     *                  }*/ /*
     *  ocn.optionNodes = new List<ConversationNode>( );
     *  if( options != null ) {
     *      ocn.options = new List<ConversationLine>( );
     *      for( ConversationLine cl : options )
     *          ocn.options.add( (ConversationLine) cl.clone( ) );
     *  }
     * ocn.random = random;
     *  ocn.keepShowing = keepShowing;
     *  ocn.showUserOption = showUserOption;
     *  return ocn;
     * }*/

    public override object Clone()
    {
        OptionConversationNode ocn = (OptionConversationNode)base.Clone();

        ocn.effectConsumed = effectConsumed;
        ocn.effects        = (effects != null ? (Effects)effects.Clone() : null);

        /*		if (optionNodes != null) {
         *                      ocn.optionNodes = new ArrayList<ConversationNode>();
         *                      for (ConversationNode cn : optionNodes)
         *                              ocn.optionNodes.add((ConversationNode) cn.clone());
         *              }*/
        ocn.optionNodes = new List <ConversationNode>();
        if (options != null)
        {
            ocn.options = new List <ConversationLine>();
            foreach (ConversationLine cl in options)
            {
                ocn.options.Add((ConversationLine)cl.Clone());
            }
        }
        ocn.random         = random;
        ocn.keepShowing    = keepShowing;
        ocn.showUserOption = showUserOption;
        return(ocn);
    }
        public void clicked(int option)
        {
            this.child = option;
            OptionConversationNode onode = ((OptionConversationNode)node);

            Tracker.T.alternative.Selected(onode.getXApiQuestion(), onode.getLine(option).getText().Replace(",", " "), onode.getLine(option).getXApiCorrect(), AlternativeTracker.Alternative.Question);
            Tracker.T.RequestFlush();
        }
Пример #7
0
    public OptionNodeEditor()
    {
        myNode = new OptionConversationNode();

        conditionsTex   = (Texture2D)Resources.Load("EAdventureData/img/icons/conditions-24x24", typeof(Texture2D));
        noConditionsTex = (Texture2D)Resources.Load("EAdventureData/img/icons/no-conditions-24x24", typeof(Texture2D));

        linkTex   = (Texture2D)Resources.Load("EAdventureData/img/icons/linkNode", typeof(Texture2D));
        noLinkTex = (Texture2D)Resources.Load("EAdventureData/img/icons/deleteNodeLink", typeof(Texture2D));

        effectTex   = (Texture2D)Resources.Load("EAdventureData/img/icons/effects/32x32/has-macro", typeof(Texture2D));
        noEffectTex = (Texture2D)Resources.Load("EAdventureData/img/icons/effects/32x32/macro", typeof(Texture2D));

        noBackgroundSkin = (GUISkin)Resources.Load("Editor/EditorNoBackgroundSkin", typeof(GUISkin));
        noBackgroundSkin.button.margin  = new RectOffset(1, 1, 1, 1);
        noBackgroundSkin.button.padding = new RectOffset(0, 0, 0, 0);
    }
Пример #8
0
        void OnGUI()
        {
            float guiscale = Screen.width / 800f;

            style.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
            style.button.fontSize = Mathf.RoundToInt(guiscale * 20);
            style.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
            optionlabel.fontSize  = Mathf.RoundToInt(guiscale * 36);
            style.GetStyle("talk_player").fontSize = Mathf.RoundToInt(guiscale * 20);
            //float rectwith = guiscale * 330;

            switch (guistate)
            {
            case guiState.ANSWERS_MENU:
                GUILayout.BeginArea(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f));
                GUILayout.BeginVertical();
                OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

                GUILayout.Label(GUIManager.Instance.Last, optionlabel);
                for (int i = 0; i < options.getLineCount(); i++)
                {
                    ConversationLine ono = options.getLine(i);
                    if (ConditionChecker.check(options.getLineConditions(i)))
                    {
                        if (GUILayout.Button((string)ono.getText(), style.button))
                        {
                            GameObject.Destroy(blur);
                            guioptions.clicked(i);

                            /*Tracker.T ().Choice (GUIManager.Instance.Last, ono.getText ());
                             * Tracker.T ().RequestFlush ();*/
                            Interacted();
                        }
                    }
                    ;
                }
                GUILayout.EndVertical();
                GUILayout.EndArea();
                break;

            default: break;
            }
        }
Пример #9
0
        public void clicked(int option)
        {
            this.child = option;
            OptionConversationNode onode = ((OptionConversationNode)node);

            if (option == onode.getChildCount()) // Timeout
            {
                // TODO Analytics for timeout
                return;
            }

            if (!string.IsNullOrEmpty(onode.getXApiQuestion()))
            {
                isTracePending = true;
                Game.Instance.GameState.BeginChangeAmbit();
                xAPISuccess  = onode.getLine(option).getXApiCorrect();
                xAPIQuestion = onode.getXApiQuestion();
                xAPIResponse = onode.getLine(option).getText().Replace(",", " ");
            }
        }
Пример #10
0
        protected void OnGUI()
        {
            switch (guistate)
            {
            case GUIState.BOOK:
                if (ShowingBook)
                {
                    bookDrawer.Draw(new Rect(Vector2.zero, new Vector2(Screen.width, Screen.height)));
                }
                break;

            case GUIState.ANSWERS_MENU:

                using (new GUIUtil.SkinScope(skin))
                {
                    float guiscale = Screen.width / 800f;
                    skin.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
                    skin.button.fontSize = Mathf.RoundToInt(guiscale * 20);
                    skin.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("optionLabel").fontSize      = Mathf.RoundToInt(guiscale * 36);
                    skin.GetStyle("talk_player").fontSize      = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("emptyProgressBar").fontSize = Mathf.RoundToInt(guiscale * 20);

                    using (new GUILayout.AreaScope(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f)))
                    {
                        using (new GUILayout.VerticalScope())
                        {
                            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

                            if (options.isKeepShowing())
                            {
                                var text = GUIManager.Instance.Last;
                                if (text[0] == '#')
                                {
                                    text = text.Remove(0, Mathf.Max(0, text.IndexOf(' ') + 1));
                                }

                                var textContent = new GUIContent(text);
                                var textRect    = GUILayoutUtility.GetRect(textContent, "optionLabel");

                                GUIUtil.DrawTextBorder(textRect, textContent, Color.black, "optionLabel");
                                GUIUtil.DrawText(textRect, textContent, ((GUIStyle)"optionLabel").normal.textColor, "optionLabel");
                            }
                            foreach (var i in order)
                            {
                                ConversationLine ono = options.getLine(i);
                                if (ConditionChecker.check(options.getLineConditions(i)) && GUILayout.Button(ono.getText()))
                                {
                                    OptionSelected(i);
                                }
                            }

                            if (doTimeOut)
                            {
                                if (Event.current.type == EventType.Repaint && elapsedTime > options.Timeout)
                                {
                                    OptionSelected(options.getChildCount() - 1);
                                }

                                var timeLeft     = Mathf.Max(0, options.Timeout - elapsedTime);
                                var timeLeftText = Mathf.Round(timeLeft * 10) / 10 + " s";
                                GUILayout.FlexibleSpace();
                                DrawProgressBar(GUILayoutUtility.GetRect(0, 0, "emptyProgressBar", GUILayout.ExpandWidth(true), GUILayout.Height(50)), timeLeftText, 1 - (elapsedTime / options.Timeout));
                            }
                        }
                    }
                }
                break;

            default: break;
            }
        }
Пример #11
0
        protected void OnGUI()
        {
            switch (guistate)
            {
            case GUIState.BOOK:
                if (ShowingBook)
                {
                    bookDrawer.Draw(new Rect(Vector2.zero, new Vector2(Screen.width, Screen.height)));
                }
                break;

            case GUIState.ANSWERS_MENU:

                using (new GUIUtil.SkinScope(skin))
                {
                    float guiscale = Screen.width / 800f;
                    skin.box.fontSize                          = Mathf.RoundToInt(guiscale * 20);
                    skin.button.fontSize                       = Mathf.RoundToInt(guiscale * 20);
                    skin.button.alignment                      = TextAnchor.MiddleCenter;
                    skin.button.imagePosition                  = ImagePosition.ImageAbove;
                    skin.button.stretchHeight                  = false;
                    skin.button.stretchWidth                   = true;
                    skin.label.fontSize                        = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("optionLabel").fontSize      = Mathf.RoundToInt(guiscale * 36);
                    skin.GetStyle("talk_player").fontSize      = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("emptyProgressBar").fontSize = Mathf.RoundToInt(guiscale * 20);

                    using (new GUILayout.AreaScope(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f)))
                    {
                        using (new GUILayout.VerticalScope())
                        {
                            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

                            if (options.isKeepShowing())
                            {
                                var text = GUIManager.Instance.Last;
                                if (text[0] == '#')
                                {
                                    text = text.Remove(0, Mathf.Max(0, text.IndexOf(' ') + 1));
                                }

                                var textContent = new GUIContent(text);
                                var textRect    = GUILayoutUtility.GetRect(textContent, "optionLabel");

                                GUIUtil.DrawTextBorder(textRect, textContent, Color.black, "optionLabel");
                                GUIUtil.DrawText(textRect, textContent, ((GUIStyle)"optionLabel").normal.textColor, "optionLabel");
                            }
                            foreach (var i in order)
                            {
                                ConversationLine ono = options.getLine(i);
                                var content          = new GUIContent(ono.getText());
                                var resources        = ono.getResources().Checked().FirstOrDefault();
                                auxLimitList.Clear();

                                if (resources != null && resources.existAsset("image") && !string.IsNullOrEmpty(resources.getAssetPath("image")))
                                {
                                    var imagePath = resources.getAssetPath("image");
                                    var image     = ResourceManager.getImage(imagePath);
                                    if (image)
                                    {
                                        content.image = image;
                                        if (image.height > 240)
                                        {
                                            auxLimitList.Add(GUILayout.Height(240));
                                        }
                                    }
                                }

                                if (ConditionChecker.check(options.getLineConditions(i)) && GUILayout.Button(content, auxLimitList.ToArray()))
                                {
                                    OptionSelected(i);
                                }
                            }

                            if (doTimeOut)
                            {
                                if (Event.current.type == EventType.Repaint && elapsedTime > options.Timeout)
                                {
                                    OptionSelected(options.getChildCount() - 1);
                                }

                                var timeLeft     = Mathf.Max(0, options.Timeout - elapsedTime);
                                var timeLeftText = Mathf.Round(timeLeft * 10) / 10 + " s";
                                GUILayout.FlexibleSpace();
                                DrawProgressBar(GUILayoutUtility.GetRect(0, 0, "emptyProgressBar", GUILayout.ExpandWidth(true), GUILayout.Height(50)), timeLeftText, 1 - (elapsedTime / options.Timeout));
                            }
                        }
                    }
                }
                break;

            default: break;
            }
        }
    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);
            }

            if (synthesizerVoice != null)
                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);
            }
            if (synthesizerVoice != null)
                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, x, y);
            currentNode.addChild(nuevoNodoOpcion);

            // Change the actual node for the option node recently created
            currentNode = nuevoNodoOpcion;
        }
        foreach (XmlElement el in options)
        {
            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);
        }
        foreach (XmlElement el in gosback)
        {
            currentNode.addChild(pastOptionNodes[pastOptionNodes.Count - 1]);
        }

        chapter.addConversation(new GraphConversation((TreeConversation)conversation));
    }
Пример #13
0
        protected void OnGUI()
        {
            if (loadingScreen != null)
            {
                loadingScreen.OnGUI();
            }


            switch (guistate)
            {
            case GUIState.BOOK:
                if (ShowingBook)
                {
                    bookDrawer.Draw(new Rect(Vector2.zero, new Vector2(Screen.width, Screen.height)));
                }
                break;

            case GUIState.ANSWERS_MENU:

                using (new GUIUtil.SkinScope(skin))
                {
                    float guiscale         = Screen.width / 800f;
                    var   buttonImageWidth = (200f / 600f) * Screen.height;
                    skin.box.fontSize                          = Mathf.RoundToInt(guiscale * 20);
                    skin.button.fontSize                       = Mathf.RoundToInt(guiscale * 20);
                    skin.button.alignment                      = TextAnchor.MiddleCenter;
                    skin.button.imagePosition                  = ImagePosition.ImageAbove;
                    skin.button.stretchHeight                  = false;
                    skin.button.stretchWidth                   = true;
                    skin.label.fontSize                        = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("optionLabel").fontSize      = Mathf.RoundToInt(guiscale * 36);
                    skin.GetStyle("talk_player").fontSize      = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("emptyProgressBar").fontSize = Mathf.RoundToInt(guiscale * 20);
                    OptionConversationNode options = (OptionConversationNode)guioptions.getNode();
                    var areawidth = Screen.width * 0.8f;
                    using (new GUILayout.AreaScope(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, areawidth, Screen.height * 0.8f)))
                    {
                        using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true)))
                        {
                            var restWidth        = 1f;
                            var initedHorizontal = false;

                            if (options.isKeepShowing() && GUIManager.Instance.Line != null)
                            {
                                var text = GUIManager.Instance.Line.getText();
                                if (text[0] == '#')
                                {
                                    text = text.Remove(0, Mathf.Max(0, text.IndexOf(' ') + 1));
                                }

                                var textContent = new GUIContent(text);
                                var textRect    = GUILayoutUtility.GetRect(textContent, "optionLabel");

                                GUIUtil.DrawTextBorder(textRect, textContent, Color.black, "optionLabel");
                                GUIUtil.DrawText(textRect, textContent, ((GUIStyle)"optionLabel").normal.textColor, "optionLabel");

                                var resources = GUIManager.Instance.Line.getResources().Checked().FirstOrDefault();
                                if (resources != null)
                                {
                                    var image = resources.existAsset("image") ? Game.Instance.ResourceManager.getImage(resources.getAssetPath("image")) : null;
                                    if (image)
                                    {
                                        GUILayout.BeginHorizontal();
                                        initedHorizontal = true;
                                        restWidth        = 0.7f;
                                        var imageRatio  = image.width / (float)image.height;
                                        var imageWidth  = areawidth * 0.28f;
                                        var imageHeight = Mathf.Min(imageWidth / imageRatio, Screen.height * 0.45f);
                                        using (new GUILayout.VerticalScope(GUILayout.Width(areawidth * 0.3f)))
                                        {
                                            GUILayout.FlexibleSpace();
                                            GUILayout.Box(image, GUILayout.Width(imageWidth), GUILayout.Height(imageHeight));
                                            GUILayout.FlexibleSpace();
                                        }
                                    }
                                }
                            }

                            using (new GUILayout.VerticalScope(GUILayout.Width(areawidth * restWidth)))
                            {
                                if (options.Horizontal)
                                {
                                    GUILayout.FlexibleSpace();
                                }
                                var elementsLeft = options.getLineCount();
                                while (elementsLeft > 0)
                                {
                                    if (options.Horizontal)
                                    {
                                        GUILayout.BeginHorizontal();
                                        GUILayout.FlexibleSpace();
                                    }
                                    else
                                    {
                                        GUILayout.BeginVertical();
                                    }
                                    var start     = options.getLineCount() - elementsLeft;
                                    var amount    = options.MaxElemsPerRow > 0 ? options.MaxElemsPerRow : options.getLineCount();
                                    var end       = Mathf.Clamp(start + amount, 0, options.getLineCount());
                                    var eachWidth = (areawidth * restWidth / (end - start)) - 20;
                                    for (int i = start; i < end; i++)
                                    {
                                        ConversationLine ono = options.getLine(order[i]);
                                        var content          = new GUIContent(ono.getText());
                                        var resources        = ono.getResources().Checked().FirstOrDefault();
                                        auxLimitList.Clear();
                                        if (end - start > 1 && options.Horizontal)
                                        {
                                            auxLimitList.Add(GUILayout.Width(eachWidth));
                                        }

                                        if (resources != null && resources.existAsset("image") && !string.IsNullOrEmpty(resources.getAssetPath("image")))
                                        {
                                            var imagePath = resources.getAssetPath("image");
                                            var image     = ResourceManager.getImage(imagePath);
                                            if (image)
                                            {
                                                content.image = image;

                                                /*if (image.height > buttonImageWidth)
                                                 * {*/
                                                auxLimitList.Add(GUILayout.Height(buttonImageWidth - 20));
                                                //}
                                            }
                                        }

                                        if (ConditionChecker.check(options.getLineConditions(order[i])) && GUILayout.Button(content, auxLimitList.ToArray()))
                                        {
                                            OptionSelected(order[i]);
                                        }
                                    }
                                    elementsLeft = options.getLineCount() - end;
                                    if (options.Horizontal)
                                    {
                                        GUILayout.FlexibleSpace();
                                        GUILayout.EndHorizontal();
                                    }
                                    else
                                    {
                                        GUILayout.EndVertical();
                                    }

                                    if (doTimeOut)
                                    {
                                        if (Event.current.type == EventType.Repaint && elapsedTime > options.Timeout)
                                        {
                                            OptionSelected(options.getChildCount() - 1);
                                        }

                                        var timeLeft     = Mathf.Max(0, options.Timeout - elapsedTime);
                                        var timeLeftText = Mathf.Round(timeLeft * 10) / 10 + " s";
                                        GUILayout.FlexibleSpace();
                                        DrawProgressBar(GUILayoutUtility.GetRect(0, 0, "emptyProgressBar", GUILayout.ExpandWidth(true), GUILayout.Height(50)), timeLeftText, 1 - (elapsedTime / options.Timeout));
                                    }
                                }

                                if (initedHorizontal)
                                {
                                    GUILayout.EndHorizontal();
                                }

                                if (options.Horizontal)
                                {
                                    GUILayout.FlexibleSpace();
                                }
                            }
                        }
                    }
                }
                break;

            default: break;
            }
        }
    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);
            }

            if (synthesizerVoice != null)
            {
                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);
            }
            if (synthesizerVoice != null)
            {
                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, x, y);
            currentNode.addChild(nuevoNodoOpcion);

            // Change the actual node for the option node recently created
            currentNode = nuevoNodoOpcion;
        }
        foreach (XmlElement el in options)
        {
            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);
        }
        foreach (XmlElement el in gosback)
        {
            currentNode.addChild(pastOptionNodes[pastOptionNodes.Count - 1]);
        }

        chapter.addConversation(new GraphConversation((TreeConversation)conversation));
    }
Пример #15
0
    void OnGUI()
    {
        float guiscale = Screen.width / 800f;

        style.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
        style.button.fontSize = Mathf.RoundToInt(guiscale * 20);
        style.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
        optionlabel.fontSize  = Mathf.RoundToInt(guiscale * 36);
        //style.label.fontSize = Mathf.RoundToInt(guiscale * 20);
        style.GetStyle("talk_player").fontSize = Mathf.RoundToInt(guiscale * 20);

        float rectwith = guiscale * 330;

        switch (guistate)
        {
        case guiState.TALK_PLAYER:
            /*GUILayout.BeginArea (new Rect ((Screen.width/2)-rectwith/2, 50, rectwith, 400));
             * GUILayout.BeginHorizontal ();
             * GUILayout.Box (guitext,style.GetStyle("talk_player"));
             * GUILayout.EndHorizontal ();
             * GUILayout.EndArea ();*/
            break;

        case guiState.TALK_CHARACTER:
            /*GUIStyle current = new GUIStyle(style.box);
             * if (this.guitalkerObject != null) {
             * position = Camera.current.WorldToScreenPoint (this.guitalkerObject.transform.position);
             * Color tmp = Color.black;
             * NPC cha = data.getChapters () [current_chapter].getCharacter (guitalker);
             *
             *
             * ColorUtility.TryParseHtmlString(
             *  cha.getTextFrontColor()
             *  ,out tmp);
             *
             * current.normal.textColor = tmp;
             * current.normal.background = BorderGenerator.generateFor (cha);
             * }else
             * position = new Vector2(Screen.width/2,100);
             *
             * if(position.x <= rectwith/2)
             * position.x = rectwith/2;
             * else if(position.x >= (Screen.width - rectwith/2) )
             * position.x = (Screen.width - rectwith/2);
             *
             * GUILayout.BeginArea (
             * new Rect (position.x-rectwith/2,
             *  Screen.height
             *  - position.y
             *  - (this.guitalkerObject.GetComponent<CharacterMB>().getHeight())*guiscale/2
             *  - current.CalcHeight(new GUIContent(guitext),rectwith), rectwith, 400)
             * );
             * GUILayout.BeginHorizontal ();
             * GUILayout.Box (guitext,current);
             * GUILayout.EndHorizontal ();
             * GUILayout.EndArea ();*/
            break;

        case guiState.ANSWERS_MENU:
            GUILayout.BeginArea(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f));
            GUILayout.BeginVertical();
            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

            GUILayout.Label(guitext, optionlabel);
            for (int i = 0; i < options.getLineCount(); i++)
            {
                ConversationLine ono = options.getLine(i);
                if (ConditionChecker.check(options.getLineConditions(i)))
                {
                    if (GUILayout.Button((string)ono.getText(), style.button))
                    {
                        GameObject.Destroy(blur);
                        guioptions.clicked(i);
                        Interacted();
                    }
                }
                ;
            }
            GUILayout.EndVertical();
            GUILayout.EndArea();
            break;

        case guiState.LOADING_GAME:
            break;

        case guiState.NOTHING:
            /*if(loader_state == loaderState.LOADING){
             *  GUILayout.BeginArea (new Rect (Screen.width*0.1f, Screen.height*0.1f, Screen.width*0.8f, Screen.height*0.8f));
             *  GUILayout.BeginVertical ();
             *  GUILayout.Label ("Cargando",style.label);
             *
             *  if(totals != null){
             *      GUILayout.Box ("Personajes: " + this.characters.Count + " de " + totals["Characters"],style.box);
             *      GUILayout.Box ("Objetos: " + this.objects.Count + " de " + totals["Objects"],style.box);
             *      GUILayout.Box ("Objetos de Atrezzo: " + this.atrezzos.Count + " de " + totals["Atrezzos"],style.box);
             *      GUILayout.Box ("Estados Globales: " + this.global_states.Count + " de " + totals["Global-States"],style.box);
             *      GUILayout.Box ("Grafos de Conversacion: " + this.graph_conversations.Count + " de " + totals["Graph-conversations"],style.box);
             *      GUILayout.Box ("Macros: " + this.macros.Count + " de " + totals["Macros"],style.box);
             *
             *      GUILayout.Box ("Escenas: " + this.scenes.Count + " de " + totals["Scene"],style.box);
             *  }
             *
             *
             *  GUILayout.EndVertical ();
             *  GUILayout.EndArea ();
             * }*/
            break;

        case guiState.GAME_SELECTION:
        /*GUILayout.BeginArea (new Rect (Screen.width*0.1f, Screen.height*0.1f, Screen.width*0.8f, Screen.height*0.8f));
         * GUILayout.BeginVertical ();
         * string[] games = Directory.GetDirectories("Games/");
         *
         * GUILayout.Label("eAdventure Loader v0.1",style.label);
         * foreach(string game in games){
         *  if(GUILayout.Button (game.Split('/')[1],style.button)){
         *      this.selected_game = game + "/";
         *      //this.startLoad();
         *  };
         * }
         * GUILayout.EndVertical ();
         * GUILayout.EndArea ();
         * break;*/
        default: break;
        }
    }
 public OptionNodeDataControl(ConversationDataControl conversation, ConversationNode conversationNode) : base(conversation, conversationNode)
 {
     this.optionConversationNode = conversationNode as OptionConversationNode;
     this.timeoutConditions      = new ConditionsController(optionConversationNode.TimeoutConditions);
 }
Пример #17
0
    /*
     * (non-Javadoc)
     *
     * @see conversationaleditor.xmlparser.ConversationParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a "conversation" we pick the name, so we can build the tree later
            if (qName.Equals("tree-conversation"))
            {
                // Store the name
                string conversationName = "";
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        conversationName = entry.Value.ToString();
                    }
                }

                // 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>();
            }

            // If it is a non-player character line, store the character name and audio path (if present)
            else if (qName.Equals("speak-char"))
            {
                // Set default name to "NPC"
                characterName = "NPC";
                audioPath     = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    // If there is a "idTarget" attribute, store it
                    if (entry.Key.Equals("idTarget"))
                    {
                        characterName = entry.Value.ToString();
                    }

                    // If there is a "uri" attribute, store it as audio path
                    if (entry.Key.Equals("uri"))
                    {
                        audioPath = entry.Value.ToString();
                    }
                    // If there is a "synthesize" attribute, store its value
                    if (entry.Key.Equals("synthesize"))
                    {
                        string response = entry.Value.ToString();
                        if (response.Equals("yes"))
                        {
                            synthesizerVoice = true;
                        }
                        else
                        {
                            synthesizerVoice = false;
                        }
                    }
                }
            }

            // If it is a player character line, store the audio path (if present)
            else if (qName.Equals("speak-player"))
            {
                audioPath = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    // If there is a "uri" attribute, store it as audio path
                    if (entry.Key.Equals("uri"))
                    {
                        audioPath = entry.Value.ToString();
                    }

                    // If there is a "synthesize" attribute, store its value
                    if (entry.Key.Equals("synthesize"))
                    {
                        string response = entry.Value.ToString();
                        if (response.Equals("yes"))
                        {
                            synthesizerVoice = true;
                        }
                        else
                        {
                            synthesizerVoice = false;
                        }
                    }
                }
            }

            // If it is a point with a set of possible responses, create a new OptionNode
            else if (qName.Equals("response"))
            {
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    //If there is a "random" attribute, store is the options will be random
                    if (entry.Key.Equals("random"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                        {
                            random = true;
                        }
                        else
                        {
                            random = false;
                        }
                    }
                    //If there is a "keepShowing" attribute, keep the previous conversation line showing
                    if (entry.Key.Equals("keepShowing"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                        {
                            keepShowing = true;
                        }
                        else
                        {
                            keepShowing = false;
                        }
                    }
                    //If there is a "showUserOption" attribute, identify if show the user response at option node
                    if (entry.Key.Equals("showUserOption"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                        {
                            showUserOption = true;
                        }
                        else
                        {
                            showUserOption = false;
                        }
                    }

                    //If there is a "showUserOption" attribute, identify if show the user response at option node
                    if (entry.Key.Equals("preListening"))
                    {
                        if (entry.Value.ToString().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,
                    if (entry.Key.Equals("x"))
                    {
                        x = int.Parse(entry.Value.ToString());
                    }

                    if (entry.Key.Equals("y"))
                    {
                        y = int.Parse(entry.Value.ToString());
                    }
                }
                // Create a new OptionNode, and link it to the current node
                ConversationNode nuevoNodoOpcion = new OptionConversationNode(random, keepShowing, showUserOption, preListening, x, y);
                currentNode.addChild(nuevoNodoOpcion);

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

            // If we are about to read an option, change the state of the recognizer, so we can read the line of the
            // option
            else if (qName.Equals("option"))
            {
                state = STATE_WAITING_OPTION;
            }

            // If it is an effect tag, create new effect, new subparser and switch state
            else if (qName.Equals("effect"))
            {
                currentEffects  = new Effects();
                effectSubParser = new EffectSubParser(currentEffects, chapter);
                subParsing      = SUBPARSING_EFFECT;
            }

            // If there is a go back, link the current node (which will be a DialogueNode) with the last OptionNode
            // stored
            else if (qName.Equals("go-back"))
            {
                currentNode.addChild(pastOptionNodes[pastOptionNodes.Count - 1]);
            }
        }

        // If an effect element is being subparsed, spread the call
        if (subParsing == SUBPARSING_EFFECT)
        {
            effectSubParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
Пример #18
0
 public OptionsPositionTool(OptionConversationNode optionNode, bool bottomPosition)
 {
     this.optionNode     = optionNode;
     this.bottomPosition = bottomPosition;
 }
    /*
     * (non-Javadoc)
     *
     * @see conversationaleditor.xmlparser.ConversationParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {

            // If it is a "conversation" we pick the name, so we can build the tree later
            if (qName.Equals("tree-conversation"))
            {
                // Store the name
                string conversationName = "";
                foreach (KeyValuePair<string, string> entry in attrs)
                    if (entry.Key.Equals("id"))
                        conversationName = entry.Value.ToString();

                // 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>();
            }

            // If it is a non-player character line, store the character name and audio path (if present)
            else if (qName.Equals("speak-char"))
            {
                // Set default name to "NPC"
                characterName = "NPC";
                audioPath = "";

                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    // If there is a "idTarget" attribute, store it
                    if (entry.Key.Equals("idTarget"))
                        characterName = entry.Value.ToString();

                    // If there is a "uri" attribute, store it as audio path
                    if (entry.Key.Equals("uri"))
                        audioPath = entry.Value.ToString();
                    // If there is a "synthesize" attribute, store its value
                    if (entry.Key.Equals("synthesize"))
                    {
                        string response = entry.Value.ToString();
                        if (response.Equals("yes"))
                            synthesizerVoice = true;
                        else
                            synthesizerVoice = false;
                    }
                }
            }

            // If it is a player character line, store the audio path (if present)
            else if (qName.Equals("speak-player"))
            {
                audioPath = "";

                foreach (KeyValuePair<string, string> entry in attrs)
                {

                    // If there is a "uri" attribute, store it as audio path
                    if (entry.Key.Equals("uri"))
                        audioPath = entry.Value.ToString();

                    // If there is a "synthesize" attribute, store its value
                    if (entry.Key.Equals("synthesize"))
                    {
                        string response = entry.Value.ToString();
                        if (response.Equals("yes"))
                            synthesizerVoice = true;
                        else
                            synthesizerVoice = false;
                    }
                }
            }

            // If it is a point with a set of possible responses, create a new OptionNode
            else if (qName.Equals("response"))
            {

                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    //If there is a "random" attribute, store is the options will be random
                    if (entry.Key.Equals("random"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                            random = true;
                        else
                            random = false;
                    }
                    //If there is a "keepShowing" attribute, keep the previous conversation line showing
                    if (entry.Key.Equals("keepShowing"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                            keepShowing = true;
                        else
                            keepShowing = false;
                    }
                    //If there is a "showUserOption" attribute, identify if show the user response at option node
                    if (entry.Key.Equals("showUserOption"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                            showUserOption = true;
                        else
                            showUserOption = false;
                    }

                    //If there is a "showUserOption" attribute, identify if show the user response at option node
                    if (entry.Key.Equals("preListening"))
                    {
                        if (entry.Value.ToString().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,
                    if (entry.Key.Equals("x"))
                    {
                        x = int.Parse(entry.Value.ToString());
                    }

                    if (entry.Key.Equals("y"))
                    {
                        y = int.Parse(entry.Value.ToString());
                    }
                }
                // Create a new OptionNode, and link it to the current node
                ConversationNode nuevoNodoOpcion = new OptionConversationNode(random, keepShowing, showUserOption, preListening, x, y);
                currentNode.addChild(nuevoNodoOpcion);

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

            // If we are about to read an option, change the state of the recognizer, so we can read the line of the
            // option
            else if (qName.Equals("option"))
            {
                state = STATE_WAITING_OPTION;

            }

            // If it is an effect tag, create new effect, new subparser and switch state
            else if (qName.Equals("effect"))
            {
                currentEffects = new Effects();
                effectSubParser = new EffectSubParser(currentEffects, chapter);
                subParsing = SUBPARSING_EFFECT;
            }

            // If there is a go back, link the current node (which will be a DialogueNode) with the last OptionNode
            // stored
            else if (qName.Equals("go-back"))
            {
                currentNode.addChild(pastOptionNodes[pastOptionNodes.Count - 1]);
            }
        }

        // If an effect element is being subparsed, spread the call
        if (subParsing == SUBPARSING_EFFECT)
        {
            effectSubParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }