public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            frontcolors,
            bordercolors,
            textcolors = element.SelectNodes("textcolor"),
            conversationsref = element.SelectNodes("conversation-ref"),
            voices = element.SelectNodes("voice"),
            actionss = element.SelectNodes("actions");

        string tmpArgVal;

        string characterId = element.GetAttribute("id");

        npc = new NPC(characterId);

        descriptions = new List<Description>();
        npc.setDescriptions(descriptions);

        if (element.SelectSingleNode("documentation") != null)
            npc.setDocumentation(element.SelectSingleNode("documentation").InnerText);

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();
            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(el.GetAttribute(tmpArgVal));
            }

            assets = el.SelectNodes("asset");
            foreach (XmlElement ell in assets)
            {
                string type = "";
                string path = "";

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    type = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                currentResources.addAsset(type, path);
            }

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentResources.setConditions(currentConditions);
            }

            npc.addResources(currentResources);
        }

        foreach (XmlElement el in textcolors)
        {
            tmpArgVal = el.GetAttribute("showsSpeechBubble");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setShowsSpeechBubbles(tmpArgVal.Equals("yes"));
            }

            tmpArgVal = el.GetAttribute("bubbleBkgColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBkgColor(tmpArgVal);
            }

            tmpArgVal = el.GetAttribute("bubbleBorderColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBorderColor(tmpArgVal);
            }

            frontcolors = el.SelectNodes("frontcolor");
            foreach (XmlElement ell in frontcolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextFrontColor(color);
            }

            bordercolors = el.SelectNodes("bordercolor");
            foreach (XmlElement ell in bordercolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextBorderColor(color);
            }
        }

        foreach (XmlElement el in conversationsref)
        {
            string idTarget = "";

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }

            conversationReference = new ConversationReference(idTarget);

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);

                conversationReference.setConditions(currentConditions);
            }

            conversationReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);

            Action action = new Action(Action.TALK_TO);
            action.setConditions(conversationReference.getConditions());
            action.setDocumentation(conversationReference.getDocumentation());
            TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
            action.getEffects().add(effect);
            npc.addAction(action);
        }

        foreach (XmlElement el in voices)
        {
            string voice = "";
            string response;
            bool alwaysSynthesizer = false;

            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                voice = tmpArgVal;
            }

            tmpArgVal = el.GetAttribute("synthesizeAlways");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                response = tmpArgVal;
                if (response.Equals("yes"))
                    alwaysSynthesizer = true;
            }

            npc.setAlwaysSynthesizer(alwaysSynthesizer);
            npc.setVoice(voice);
        }

        foreach (XmlElement el in actionss)
        {
            new ActionsSubParser_(chapter, npc).ParseElement(el);
        }

        foreach (XmlElement el in descriptionss)
        {
            description = new Description();
            new DescriptionsSubParser_(description, chapter).ParseElement(el);
            this.descriptions.Add(description);
        }

        chapter.addCharacter(npc);
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a resources tag, add it to the object
            if (qName.Equals("resources"))
            {
                if (reading == READING_RESOURCES)
                {
                    currentCustomAction.addResources(currentResources);
                    reading = READING_NONE;
                }
            }

            // If it is a documentation tag, hold the documentation in the current element
            else if (qName.Equals("documentation"))
            {
                currentDocumentation = currentstring.ToString().Trim();
            }

            // If it is a examine tag, store the new action in the object
            else if (qName.Equals("examine"))
            {
                Action examineAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects);
                examineAction.setDocumentation(currentDocumentation);
                examineAction.setKeepDistance(currentKeepDistance);
                examineAction.setNeedsGoTo(currentNeedsGoTo);
                examineAction.setActivatedNotEffects(activateNotEffects);
                examineAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(examineAction);
                reading = READING_NONE;
            }

            // If it is a grab tag, store the new action in the object
            else if (qName.Equals("grab"))
            {
                Action grabAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects);
                grabAction.setDocumentation(currentDocumentation);
                grabAction.setKeepDistance(currentKeepDistance);
                grabAction.setNeedsGoTo(currentNeedsGoTo);
                grabAction.setActivatedNotEffects(activateNotEffects);
                grabAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(grabAction);
                reading = READING_NONE;
            }

            // If it is an use tag, store the new action in the object
            else if (qName.Equals("use"))
            {
                Action useAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects);
                useAction.setDocumentation(currentDocumentation);
                useAction.setNeedsGoTo(currentNeedsGoTo);
                useAction.setKeepDistance(currentKeepDistance);
                useAction.setActivatedNotEffects(activateNotEffects);
                useAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(useAction);
                reading = READING_NONE;
            }

            // If it is an use tag, store the new action in the object
            else if (qName.Equals("talk-to"))
            {
                Action talkToAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects);
                talkToAction.setDocumentation(currentDocumentation);
                talkToAction.setNeedsGoTo(currentNeedsGoTo);
                talkToAction.setKeepDistance(currentKeepDistance);
                talkToAction.setActivatedNotEffects(activateNotEffects);
                talkToAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(talkToAction);
                reading = READING_NONE;
            }

            // If it is an use-with tag, store the new action in the object
            else if (qName.Equals("use-with"))
            {
                Action useWithAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects);
                useWithAction.setDocumentation(currentDocumentation);
                useWithAction.setKeepDistance(currentKeepDistance);
                useWithAction.setNeedsGoTo(currentNeedsGoTo);
                useWithAction.setActivatedNotEffects(activateNotEffects);
                useWithAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(useWithAction);
                reading = READING_NONE;
            }

            // If it is an use-with tag, store the new action in the object
            else if (qName.Equals("drag-to"))
            {
                Action useWithAction = new Action(Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects);
                useWithAction.setDocumentation(currentDocumentation);
                useWithAction.setKeepDistance(currentKeepDistance);
                useWithAction.setNeedsGoTo(currentNeedsGoTo);
                useWithAction.setActivatedNotEffects(activateNotEffects);
                useWithAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(useWithAction);
                reading = READING_NONE;
            }

            // If it is a give-to tag, store the new action in the object
            else if (qName.Equals("give-to"))
            {
                Action giveToAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects);
                giveToAction.setDocumentation(currentDocumentation);
                giveToAction.setKeepDistance(currentKeepDistance);
                giveToAction.setNeedsGoTo(currentNeedsGoTo);
                giveToAction.setActivatedNotEffects(activateNotEffects);
                giveToAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(giveToAction);
                reading = READING_NONE;
            }

            // If it is a custom tag, store the new custom action in the object
            else if (qName.Equals("custom"))
            {
                currentCustomAction.setName(currentName);
                currentCustomAction.setConditions(currentConditions);
                currentCustomAction.setEffects(currentEffects);
                currentCustomAction.setNotEffects(currentNotEffects);
                currentCustomAction.setDocumentation(currentDocumentation);
                currentCustomAction.setKeepDistance(currentKeepDistance);
                currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
                currentCustomAction.setActivatedNotEffects(activateNotEffects);
                currentCustomAction.setClickEffects(currentClickEffects);
                currentCustomAction.setActivatedClickEffects(activateClickEffects);
                //				customAction.addResources(currentResources);
                element.addAction(currentCustomAction);
                currentCustomAction = null;
                reading             = READING_NONE;
            }

            // If it is a custom-interact tag, store the new custom interact action in the object
            else if (qName.Equals("custom-interact"))
            {
                currentCustomAction.setConditions(currentConditions);
                currentCustomAction.setEffects(currentEffects);
                currentCustomAction.setNotEffects(currentNotEffects);
                currentCustomAction.setName(currentName);
                currentCustomAction.setTargetId(currentIdTarget);
                currentCustomAction.setDocumentation(currentDocumentation);
                currentCustomAction.setKeepDistance(currentKeepDistance);
                currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
                currentCustomAction.setActivatedNotEffects(activateNotEffects);
                currentCustomAction.setClickEffects(currentClickEffects);
                currentCustomAction.setActivatedClickEffects(activateClickEffects);
                //				customAction.addResources(currentResources);
                element.addAction(currentCustomAction);
                currentCustomAction = null;
                reading             = READING_NONE;
            }

            // Reset the current string
            currentstring = string.Empty;
        }

        // If a condition is being subparsed
        else if (subParsing == SUBPARSING_CONDITION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);

            // If the condition tag is being closed
            if (qName.Equals("condition"))
            {
                // Store the conditions in the resources
                if (reading == READING_RESOURCES)
                {
                    currentResources.setConditions(currentConditions);
                }

                // Switch state
                subParsing = SUBPARSING_NONE;
            }
        }

        // If an effect is being subparsed
        else if (subParsing == SUBPARSING_EFFECT)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);

            // If the effect tag is being closed, switch the state
            if (qName.Equals("effect"))
            {
                subParsing = SUBPARSING_NONE;
            }
            // If the not-effect tag is being closed, switch the state
            else if (qName.Equals("not-effect"))
            {
                subParsing = SUBPARSING_NONE;
            }
            // If the not-effect tag is being closed, switch the state
            else if (qName.Equals("click-effect"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {

            // If it is a resources tag, add it to the object
            if (qName.Equals("resources"))
            {
                if (reading == READING_RESOURCES)
                {
                    currentCustomAction.addResources(currentResources);
                    reading = READING_NONE;
                }
            }

            // If it is a documentation tag, hold the documentation in the current element
            else if (qName.Equals("documentation"))
            {
                currentDocumentation = currentstring.ToString().Trim();
            }

            // If it is a examine tag, store the new action in the object
            else if (qName.Equals("examine"))
            {
                Action examineAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects);
                examineAction.setDocumentation(currentDocumentation);
                examineAction.setKeepDistance(currentKeepDistance);
                examineAction.setNeedsGoTo(currentNeedsGoTo);
                examineAction.setActivatedNotEffects(activateNotEffects);
                examineAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(examineAction);
                reading = READING_NONE;
            }

            // If it is a grab tag, store the new action in the object
            else if (qName.Equals("grab"))
            {
                Action grabAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects);
                grabAction.setDocumentation(currentDocumentation);
                grabAction.setKeepDistance(currentKeepDistance);
                grabAction.setNeedsGoTo(currentNeedsGoTo);
                grabAction.setActivatedNotEffects(activateNotEffects);
                grabAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(grabAction);
                reading = READING_NONE;
            }

            // If it is an use tag, store the new action in the object
            else if (qName.Equals("use"))
            {
                Action useAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects);
                useAction.setDocumentation(currentDocumentation);
                useAction.setNeedsGoTo(currentNeedsGoTo);
                useAction.setKeepDistance(currentKeepDistance);
                useAction.setActivatedNotEffects(activateNotEffects);
                useAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(useAction);
                reading = READING_NONE;
            }

            // If it is an use tag, store the new action in the object
            else if (qName.Equals("talk-to"))
            {
                Action talkToAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects);
                talkToAction.setDocumentation(currentDocumentation);
                talkToAction.setNeedsGoTo(currentNeedsGoTo);
                talkToAction.setKeepDistance(currentKeepDistance);
                talkToAction.setActivatedNotEffects(activateNotEffects);
                talkToAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(talkToAction);
                reading = READING_NONE;
            }

            // If it is an use-with tag, store the new action in the object
            else if (qName.Equals("use-with"))
            {
                Action useWithAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects);
                useWithAction.setDocumentation(currentDocumentation);
                useWithAction.setKeepDistance(currentKeepDistance);
                useWithAction.setNeedsGoTo(currentNeedsGoTo);
                useWithAction.setActivatedNotEffects(activateNotEffects);
                useWithAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(useWithAction);
                reading = READING_NONE;
            }

            // If it is an use-with tag, store the new action in the object
            else if (qName.Equals("drag-to"))
            {
                Action useWithAction = new Action(Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects);
                useWithAction.setDocumentation(currentDocumentation);
                useWithAction.setKeepDistance(currentKeepDistance);
                useWithAction.setNeedsGoTo(currentNeedsGoTo);
                useWithAction.setActivatedNotEffects(activateNotEffects);
                useWithAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(useWithAction);
                reading = READING_NONE;
            }

            // If it is a give-to tag, store the new action in the object
            else if (qName.Equals("give-to"))
            {
                Action giveToAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects);
                giveToAction.setDocumentation(currentDocumentation);
                giveToAction.setKeepDistance(currentKeepDistance);
                giveToAction.setNeedsGoTo(currentNeedsGoTo);
                giveToAction.setActivatedNotEffects(activateNotEffects);
                giveToAction.setActivatedClickEffects(activateClickEffects);
                element.addAction(giveToAction);
                reading = READING_NONE;
            }

            // If it is a custom tag, store the new custom action in the object
            else if (qName.Equals("custom"))
            {
                currentCustomAction.setName(currentName);
                currentCustomAction.setConditions(currentConditions);
                currentCustomAction.setEffects(currentEffects);
                currentCustomAction.setNotEffects(currentNotEffects);
                currentCustomAction.setDocumentation(currentDocumentation);
                currentCustomAction.setKeepDistance(currentKeepDistance);
                currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
                currentCustomAction.setActivatedNotEffects(activateNotEffects);
                currentCustomAction.setClickEffects(currentClickEffects);
                currentCustomAction.setActivatedClickEffects(activateClickEffects);
                //				customAction.addResources(currentResources);
                element.addAction(currentCustomAction);
                currentCustomAction = null;
                reading = READING_NONE;
            }

            // If it is a custom-interact tag, store the new custom interact action in the object
            else if (qName.Equals("custom-interact"))
            {
                currentCustomAction.setConditions(currentConditions);
                currentCustomAction.setEffects(currentEffects);
                currentCustomAction.setNotEffects(currentNotEffects);
                currentCustomAction.setName(currentName);
                currentCustomAction.setTargetId(currentIdTarget);
                currentCustomAction.setDocumentation(currentDocumentation);
                currentCustomAction.setKeepDistance(currentKeepDistance);
                currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
                currentCustomAction.setActivatedNotEffects(activateNotEffects);
                currentCustomAction.setClickEffects(currentClickEffects);
                currentCustomAction.setActivatedClickEffects(activateClickEffects);
                //				customAction.addResources(currentResources);
                element.addAction(currentCustomAction);
                currentCustomAction = null;
                reading = READING_NONE;
            }

            // Reset the current string
            currentstring = string.Empty;
        }

        // If a condition is being subparsed
        else if (subParsing == SUBPARSING_CONDITION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);

            // If the condition tag is being closed
            if (qName.Equals("condition"))
            {
                // Store the conditions in the resources
                if (reading == READING_RESOURCES)
                    currentResources.setConditions(currentConditions);

                // Switch state
                subParsing = SUBPARSING_NONE;
            }
        }

        // If an effect is being subparsed
        else if (subParsing == SUBPARSING_EFFECT)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);

            // If the effect tag is being closed, switch the state
            if (qName.Equals("effect"))
            {
                subParsing = SUBPARSING_NONE;
            }
            // If the not-effect tag is being closed, switch the state
            else if (qName.Equals("not-effect"))
            {
                subParsing = SUBPARSING_NONE;
            }
            // If the not-effect tag is being closed, switch the state
            else if (qName.Equals("click-effect"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {

            // If it is a character tag, store the character in the game data
            if (qName.Equals("character"))
            {
                chapter.addCharacter(npc);
            }

            // If it is a documentation tag, hold the documentation in the character
            else if (qName.Equals("documentation"))
            {
                if (reading == READING_NONE)
                    npc.setDocumentation(currentstring.ToString().Trim());
                else if (reading == READING_CONVERSATION_REFERENCE)
                    conversationReference.setDocumentation(currentstring.ToString().Trim());
            }

            // If it is a resources tag, add the resources in the character
            else if (qName.Equals("resources"))
            {
                npc.addResources(currentResources);
                reading = READING_NONE;
            }

            // If it is a conversation reference tag, add the reference to the character
            else if (qName.Equals("conversation-ref"))
            {

                //npc.addConversationReference( conversationReference );
                Action action = new Action(Action.TALK_TO);
                action.setConditions(conversationReference.getConditions());
                action.setDocumentation(conversationReference.getDocumentation());
                TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
                action.getEffects().add(effect);
                npc.addAction(action);
                reading = READING_NONE;
            }

            // Reset the current string
            currentstring = "";
        }

        // If a condition is being subparsed
        else if (subParsing == SUBPARSING_CONDITION)
        {

            // Spread the end element call
            subParser.endElement(namespaceURI, sName, qName);

            // If the condition is being closed
            if (qName.Equals("condition"))
            {
                // Add the condition to the resources
                if (reading == READING_RESOURCES)
                    currentResources.setConditions(currentConditions);

                // Add the condition to the conversation reference
                if (reading == READING_CONVERSATION_REFERENCE)
                    conversationReference.setConditions(currentConditions);

                // Stop subparsing
                subParsing = SUBPARSING_NONE;
            }
        }
        else if (subParsing == SUBPARSING_ACTIONS)
        {
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("actions"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }

        // If it is a description tag, create the new description (with its id)
        else if (subParsing == SUBPARSING_DESCRIPTION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("description"))
            {
                this.descriptions.Add(description);
                subParsing = SUBPARSING_NONE;
            }
        }
    }
Пример #5
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a character tag, store the character in the game data
            if (qName.Equals("character"))
            {
                chapter.addCharacter(npc);
            }

            // If it is a documentation tag, hold the documentation in the character
            else if (qName.Equals("documentation"))
            {
                if (reading == READING_NONE)
                {
                    npc.setDocumentation(currentstring.ToString().Trim());
                }
                else if (reading == READING_CONVERSATION_REFERENCE)
                {
                    conversationReference.setDocumentation(currentstring.ToString().Trim());
                }
            }

            // If it is a resources tag, add the resources in the character
            else if (qName.Equals("resources"))
            {
                npc.addResources(currentResources);
                reading = READING_NONE;
            }

            // If it is a conversation reference tag, add the reference to the character
            else if (qName.Equals("conversation-ref"))
            {
                //npc.addConversationReference( conversationReference );
                Action action = new Action(Action.TALK_TO);
                action.setConditions(conversationReference.getConditions());
                action.setDocumentation(conversationReference.getDocumentation());
                TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
                action.getEffects().add(effect);
                npc.addAction(action);
                reading = READING_NONE;
            }

            // Reset the current string
            currentstring = "";
        }

        // If a condition is being subparsed
        else if (subParsing == SUBPARSING_CONDITION)
        {
            // Spread the end element call
            subParser.endElement(namespaceURI, sName, qName);

            // If the condition is being closed
            if (qName.Equals("condition"))
            {
                // Add the condition to the resources
                if (reading == READING_RESOURCES)
                {
                    currentResources.setConditions(currentConditions);
                }

                // Add the condition to the conversation reference
                if (reading == READING_CONVERSATION_REFERENCE)
                {
                    conversationReference.setConditions(currentConditions);
                }

                // Stop subparsing
                subParsing = SUBPARSING_NONE;
            }
        }
        else if (subParsing == SUBPARSING_ACTIONS)
        {
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("actions"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }

        // If it is a description tag, create the new description (with its id)
        else if (subParsing == SUBPARSING_DESCRIPTION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("description"))
            {
                this.descriptions.Add(description);
                subParsing = SUBPARSING_NONE;
            }
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess    = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            frontcolors,
            bordercolors,
            textcolors       = element.SelectNodes("textcolor"),
            conversationsref = element.SelectNodes("conversation-ref"),
            voices           = element.SelectNodes("voice"),
            actionss         = element.SelectNodes("actions");

        string tmpArgVal;

        string characterId = element.GetAttribute("id");

        npc = new NPC(characterId);

        descriptions = new List <Description>();
        npc.setDescriptions(descriptions);

        if (element.SelectSingleNode("documentation") != null)
        {
            npc.setDocumentation(element.SelectSingleNode("documentation").InnerText);
        }

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();
            tmpArgVal        = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(el.GetAttribute(tmpArgVal));
            }

            assets = el.SelectNodes("asset");
            foreach (XmlElement ell in assets)
            {
                string type = "";
                string path = "";

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    type = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("uri");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                currentResources.addAsset(type, path);
            }

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentResources.setConditions(currentConditions);
            }

            npc.addResources(currentResources);
        }


        foreach (XmlElement el in textcolors)
        {
            tmpArgVal = el.GetAttribute("showsSpeechBubble");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setShowsSpeechBubbles(tmpArgVal.Equals("yes"));
            }

            tmpArgVal = el.GetAttribute("bubbleBkgColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBkgColor(tmpArgVal);
            }

            tmpArgVal = el.GetAttribute("bubbleBorderColor");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                npc.setBubbleBorderColor(tmpArgVal);
            }

            frontcolors = el.SelectNodes("frontcolor");
            foreach (XmlElement ell in frontcolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextFrontColor(color);
            }

            bordercolors = el.SelectNodes("bordercolor");
            foreach (XmlElement ell in bordercolors)
            {
                string color = "";

                tmpArgVal = ell.GetAttribute("color");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    color = tmpArgVal;
                }

                npc.setTextBorderColor(color);
            }
        }


        foreach (XmlElement el in conversationsref)
        {
            string idTarget = "";

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }

            conversationReference = new ConversationReference(idTarget);

            conditions = el.SelectNodes("condition");
            foreach (XmlElement ell in conditions)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);

                conversationReference.setConditions(currentConditions);
            }

            conversationReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);

            Action action = new Action(Action.TALK_TO);
            action.setConditions(conversationReference.getConditions());
            action.setDocumentation(conversationReference.getDocumentation());
            TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId());
            action.getEffects().add(effect);
            npc.addAction(action);
        }

        foreach (XmlElement el in voices)
        {
            string voice = "";
            string response;
            bool   alwaysSynthesizer = false;

            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                voice = tmpArgVal;
            }

            tmpArgVal = el.GetAttribute("synthesizeAlways");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                response = tmpArgVal;
                if (response.Equals("yes"))
                {
                    alwaysSynthesizer = true;
                }
            }

            npc.setAlwaysSynthesizer(alwaysSynthesizer);
            npc.setVoice(voice);
        }

        foreach (XmlElement el in actionss)
        {
            new ActionsSubParser_(chapter, npc).ParseElement(el);
        }

        foreach (XmlElement el in descriptionss)
        {
            description = new Description();
            new DescriptionsSubParser_(description, chapter).ParseElement(el);
            this.descriptions.Add(description);
        }

        chapter.addCharacter(npc);
    }