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);
    }
    public override void ParseElement(XmlElement element)
    {
        string     tmpArgVal;
        XmlElement tmpXmlEl;

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

        foreach (XmlElement action in element.ChildNodes)
        {
            //First we parse the elements every action haves:
            tmpArgVal = action.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = action.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("click-effects");

            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateClickEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentIdTarget = tmpArgVal;
            }

            currentConditions   = new Conditions();
            currentEffects      = new Effects();
            currentNotEffects   = new Effects();
            currentClickEffects = new Effects();
            tmpXmlEl            = (XmlElement)action.SelectSingleNode("condition");
            if (tmpXmlEl != null)
            {
                new ConditionSubParser_(currentConditions, chapter).ParseElement(tmpXmlEl);
            }
            tmpXmlEl = (XmlElement)action.SelectSingleNode("effect");
            if (tmpXmlEl != null)
            {
                new EffectSubParser_(currentEffects, chapter).ParseElement(tmpXmlEl);
            }

            tmpXmlEl = (XmlElement)action.SelectSingleNode("click-effect");
            if (tmpXmlEl != null)
            {
                new EffectSubParser_(currentClickEffects, chapter).ParseElement(tmpXmlEl);
            }

            tmpXmlEl = (XmlElement)action.SelectSingleNode("not-effect");
            if (tmpXmlEl != null)
            {
                new EffectSubParser_(currentNotEffects, chapter).ParseElement(tmpXmlEl);
            }

            //Then we instantiate the correct action by name.
            //We also parse the elements that are unique of that action.
            Action currentAction = new Action(0);
            switch (action.Name)
            {
            case "examines":        currentAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects); break;

            case "grabs":           currentAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects); break;

            case "use":             currentAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects); break;

            case "talk-to":         currentAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects); break;

            case "use-with":        currentAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;

            case "give-to":         currentAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;

            case "drag-to":         currentAction = new Action(Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;

            case "custom":
            case "custom-interact":
                CustomAction customAction = new CustomAction((action.Name == "custom") ? Action.CUSTOM : Action.CUSTOM_INTERACT);

                tmpArgVal = action.GetAttribute("name");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    currentName = tmpArgVal;
                }
                customAction.setName(currentName);

                tmpXmlEl = (XmlElement)action.SelectSingleNode("resources");
                if (tmpXmlEl != null)
                {
                    customAction.addResources(parseResources(tmpXmlEl));
                }

                currentAction = customAction;
                break;
            }

            //Finally we set al the attributes to the action;
            currentAction.setConditions(currentConditions);
            currentAction.setEffects(currentEffects);
            currentAction.setNotEffects(currentNotEffects);
            currentAction.setKeepDistance(currentKeepDistance);
            currentAction.setNeedsGoTo(currentNeedsGoTo);
            currentAction.setActivatedNotEffects(activateNotEffects);
            currentAction.setClickEffects(currentClickEffects);
            currentAction.setActivatedClickEffects(activateClickEffects);

            this.element.addAction(currentAction);
        }



        /*foreach (XmlElement el in examines)
         * {
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *
         *  Action examineAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects);
         *  examineAction.setKeepDistance(currentKeepDistance);
         *  examineAction.setNeedsGoTo(currentNeedsGoTo);
         *  examineAction.setActivatedNotEffects(activateNotEffects);
         *  examineAction.setActivatedClickEffects(activateClickEffects);
         *  this.element.addAction(examineAction);
         * }
         * foreach (XmlElement el in grabs)
         * {
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *
         *  Action grabAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects);
         *  grabAction.setKeepDistance(currentKeepDistance);
         *  grabAction.setNeedsGoTo(currentNeedsGoTo);
         *  grabAction.setActivatedNotEffects(activateNotEffects);
         *  grabAction.setActivatedClickEffects(activateClickEffects);
         *  this.element.addAction(grabAction);
         * }
         * foreach (XmlElement el in uses)
         * {
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *
         *  Action useAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects);
         *  useAction.setNeedsGoTo(currentNeedsGoTo);
         *  useAction.setKeepDistance(currentKeepDistance);
         *  useAction.setActivatedNotEffects(activateNotEffects);
         *  useAction.setActivatedClickEffects(activateClickEffects);
         *  this.element.addAction(useAction);
         * }
         * foreach (XmlElement el in talksto)
         * {
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *
         *  Action talkToAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects);
         *  talkToAction.setNeedsGoTo(currentNeedsGoTo);
         *  talkToAction.setKeepDistance(currentKeepDistance);
         *  talkToAction.setActivatedNotEffects(activateNotEffects);
         *  talkToAction.setActivatedClickEffects(activateClickEffects);
         *  this.element.addAction(talkToAction);
         * }
         *
         *
         * foreach (XmlElement el in useswith)
         * {
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("click-effects");
         *
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateClickEffects = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("idTarget");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentIdTarget = tmpArgVal;
         *  }
         *
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *
         *  Action useWithAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects,
         *      currentNotEffects, currentClickEffects);
         *  useWithAction.setKeepDistance(currentKeepDistance);
         *  useWithAction.setNeedsGoTo(currentNeedsGoTo);
         *  useWithAction.setActivatedNotEffects(activateNotEffects);
         *  useWithAction.setActivatedClickEffects(activateClickEffects);
         *  this.element.addAction(useWithAction);
         * }
         *
         *
         * foreach (XmlElement el in dragsto)
         * {
         *  tmpArgVal = el.GetAttribute("idTarget");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentIdTarget = tmpArgVal;
         *  }
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("click-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateClickEffects = tmpArgVal.Equals("yes");
         *  }
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *
         *  Action useWithAction = new Action(Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects,
         *      currentNotEffects, currentClickEffects);
         *  useWithAction.setKeepDistance(currentKeepDistance);
         *  useWithAction.setNeedsGoTo(currentNeedsGoTo);
         *  useWithAction.setActivatedNotEffects(activateNotEffects);
         *  useWithAction.setActivatedClickEffects(activateClickEffects);
         *  this.element.addAction(useWithAction);
         * }
         *
         *
         * foreach (XmlElement el in givesto)
         * {
         *  tmpArgVal = el.GetAttribute("idTarget");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentIdTarget = tmpArgVal;
         *  }
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("click-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateClickEffects = tmpArgVal.Equals("yes");
         *  }
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *
         *  Action giveToAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects,
         *      currentNotEffects, currentClickEffects);
         *  giveToAction.setKeepDistance(currentKeepDistance);
         *  giveToAction.setNeedsGoTo(currentNeedsGoTo);
         *  giveToAction.setActivatedNotEffects(activateNotEffects);
         *  giveToAction.setActivatedClickEffects(activateClickEffects);
         *  this.element.addAction(giveToAction);
         * }
         *
         *
         * foreach (XmlElement el in customs)
         * {
         *  tmpArgVal = el.GetAttribute("idTarget");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentIdTarget = tmpArgVal;
         *  }
         *  tmpArgVal = el.GetAttribute("name");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentName = tmpArgVal;
         *  }
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("click-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateClickEffects = tmpArgVal.Equals("yes");
         *  }
         *
         *
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *  tmpXmlEl = el.SelectSingleNode ("condition");
         *  if (tmpXmlEl != null)
         *      new ConditionSubParser_ (currentConditions, chapter).ParseElement (tmpXmlEl);
         *
         *  tmpXmlEl = el.SelectSingleNode ("effect");
         *  if (tmpXmlEl != null)
         *      new EffectSubParser_ (currentEffects, chapter).ParseElement (tmpXmlEl);
         *
         *  tmpXmlEl = el.SelectSingleNode ("click-effect");
         *  if (tmpXmlEl != null)
         *      new EffectSubParser_ (currentClickEffects, chapter).ParseElement (tmpXmlEl);
         *
         *  tmpXmlEl = el.SelectSingleNode ("not-effect");
         *  if (tmpXmlEl != null)
         *      new EffectSubParser_ (currentNotEffects, chapter).ParseElement (tmpXmlEl);
         *
         *  currentCustomAction = new CustomAction(Action.CUSTOM);
         *
         *  currentCustomAction.setName(currentName);
         *  currentCustomAction.setConditions(currentConditions);
         *  currentCustomAction.setEffects(currentEffects);
         *  currentCustomAction.setNotEffects(currentNotEffects);
         *  currentCustomAction.setKeepDistance(currentKeepDistance);
         *  currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
         *  currentCustomAction.setActivatedNotEffects(activateNotEffects);
         *  currentCustomAction.setClickEffects(currentClickEffects);
         *  currentCustomAction.setActivatedClickEffects(activateClickEffects);
         *  XmlElement res = (XmlElement) el.SelectSingleNode ("resources");
         *  if (res != null)
         *      currentCustomAction.addResources(parseResources(res));
         *  this.element.addAction(currentCustomAction);
         *  currentCustomAction = null;
         * }
         *
         * foreach (XmlElement el in customsinteract)
         * {
         *  tmpArgVal = el.GetAttribute("idTarget");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentIdTarget = tmpArgVal;
         *  }
         *  tmpArgVal = el.GetAttribute("name");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentName = tmpArgVal;
         *  }
         *  tmpArgVal = el.GetAttribute("needsGoTo");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentNeedsGoTo = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("keepDistance");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      currentKeepDistance = int.Parse(tmpArgVal);
         *  }
         *  tmpArgVal = el.GetAttribute("not-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateNotEffects = tmpArgVal.Equals("yes");
         *  }
         *  tmpArgVal = el.GetAttribute("click-effects");
         *  if (!string.IsNullOrEmpty(tmpArgVal))
         *  {
         *      activateClickEffects = tmpArgVal.Equals("yes");
         *  }
         *  currentConditions = new Conditions();
         *  currentEffects = new Effects();
         *  currentNotEffects = new Effects();
         *  currentClickEffects = new Effects();
         *  currentCustomAction = new CustomAction(Action.CUSTOM_INTERACT);
         *
         *  currentCustomAction.setConditions(currentConditions);
         *  currentCustomAction.setEffects(currentEffects);
         *  currentCustomAction.setNotEffects(currentNotEffects);
         *  currentCustomAction.setName(currentName);
         *  currentCustomAction.setTargetId(currentIdTarget);
         *  currentCustomAction.setKeepDistance(currentKeepDistance);
         *  currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
         *  currentCustomAction.setActivatedNotEffects(activateNotEffects);
         *  currentCustomAction.setClickEffects(currentClickEffects);
         *  currentCustomAction.setActivatedClickEffects(activateClickEffects);
         *
         *  XmlElement res = (XmlElement) el.SelectSingleNode ("resources");
         *  if (res != null)
         *      currentCustomAction.addResources(parseResources(res));
         *
         *  this.element.addAction(currentCustomAction);
         *  currentCustomAction = null;
         * }
         *
         * foreach (XmlElement el in effects)
         * {
         *  currentEffects = new Effects();
         *  new EffectSubParser_(currentEffects, chapter).ParseElement(el);
         * }
         * foreach (XmlElement el in notseffect)
         * {
         *  currentNotEffects = new Effects();
         *  new EffectSubParser_(currentNotEffects, chapter).ParseElement(el);
         * }
         * foreach (XmlElement el in effects)
         * {
         *  currentClickEffects = new Effects();
         *  new EffectSubParser_(currentClickEffects, chapter).ParseElement(el);
         * }*/
    }
    /*
     * (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;
            }
        }
    }
Пример #4
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)
    {
        string tmpArgVal;
        XmlElement tmpXmlEl;

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

        foreach (XmlElement action in element.ChildNodes) {
            //First we parse the elements every action haves:
            tmpArgVal = action.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = action.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("click-effects");

            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateClickEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = action.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentIdTarget = tmpArgVal;
            }

            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();
            tmpXmlEl = (XmlElement) action.SelectSingleNode ("condition");
            if (tmpXmlEl != null)
                new ConditionSubParser_ (currentConditions, chapter).ParseElement (tmpXmlEl);
            tmpXmlEl = (XmlElement) action.SelectSingleNode ("effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentEffects, chapter).ParseElement (tmpXmlEl);

            tmpXmlEl = (XmlElement) action.SelectSingleNode ("click-effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentClickEffects, chapter).ParseElement (tmpXmlEl);

            tmpXmlEl = (XmlElement) action.SelectSingleNode ("not-effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentNotEffects, chapter).ParseElement (tmpXmlEl);

            //Then we instantiate the correct action by name.
            //We also parse the elements that are unique of that action.
            Action currentAction = new Action(0);
            switch (action.Name) {
            case "examines":        currentAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects); break;
            case "grabs":           currentAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects); break;
            case "use":             currentAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects); break;
            case "talk-to":         currentAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects); break;
            case "use-with":        currentAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
            case "give-to":         currentAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
            case "drag-to":         currentAction = new Action (Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break;
            case "custom":
            case "custom-interact":
                CustomAction customAction = new CustomAction ((action.Name == "custom") ? Action.CUSTOM : Action.CUSTOM_INTERACT);

                tmpArgVal = action.GetAttribute ("name");
                if (!string.IsNullOrEmpty (tmpArgVal)) {
                    currentName = tmpArgVal;
                }
                customAction.setName (currentName);

                tmpXmlEl = (XmlElement) action.SelectSingleNode ("resources");
                if (tmpXmlEl != null)
                    customAction.addResources (parseResources (tmpXmlEl));

                currentAction = customAction;
                break;
            }

            //Finally we set al the attributes to the action;
            currentAction.setConditions(currentConditions);
            currentAction.setEffects(currentEffects);
            currentAction.setNotEffects(currentNotEffects);
            currentAction.setKeepDistance(currentKeepDistance);
            currentAction.setNeedsGoTo(currentNeedsGoTo);
            currentAction.setActivatedNotEffects(activateNotEffects);
            currentAction.setClickEffects(currentClickEffects);
            currentAction.setActivatedClickEffects(activateClickEffects);

            this.element.addAction(currentAction);
        }

        /*foreach (XmlElement el in examines)
        {
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();

            Action examineAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects);
            examineAction.setKeepDistance(currentKeepDistance);
            examineAction.setNeedsGoTo(currentNeedsGoTo);
            examineAction.setActivatedNotEffects(activateNotEffects);
            examineAction.setActivatedClickEffects(activateClickEffects);
            this.element.addAction(examineAction);
        }
        foreach (XmlElement el in grabs)
        {
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();

            Action grabAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects);
            grabAction.setKeepDistance(currentKeepDistance);
            grabAction.setNeedsGoTo(currentNeedsGoTo);
            grabAction.setActivatedNotEffects(activateNotEffects);
            grabAction.setActivatedClickEffects(activateClickEffects);
            this.element.addAction(grabAction);
        }
        foreach (XmlElement el in uses)
        {
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();

            Action useAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects);
            useAction.setNeedsGoTo(currentNeedsGoTo);
            useAction.setKeepDistance(currentKeepDistance);
            useAction.setActivatedNotEffects(activateNotEffects);
            useAction.setActivatedClickEffects(activateClickEffects);
            this.element.addAction(useAction);
        }
        foreach (XmlElement el in talksto)
        {
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();

            Action talkToAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects);
            talkToAction.setNeedsGoTo(currentNeedsGoTo);
            talkToAction.setKeepDistance(currentKeepDistance);
            talkToAction.setActivatedNotEffects(activateNotEffects);
            talkToAction.setActivatedClickEffects(activateClickEffects);
            this.element.addAction(talkToAction);
        }

        foreach (XmlElement el in useswith)
        {
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("click-effects");

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

            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();

            Action useWithAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects,
                currentNotEffects, currentClickEffects);
            useWithAction.setKeepDistance(currentKeepDistance);
            useWithAction.setNeedsGoTo(currentNeedsGoTo);
            useWithAction.setActivatedNotEffects(activateNotEffects);
            useWithAction.setActivatedClickEffects(activateClickEffects);
            this.element.addAction(useWithAction);
        }

        foreach (XmlElement el in dragsto)
        {
            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentIdTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("click-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateClickEffects = tmpArgVal.Equals("yes");
            }
            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();

            Action useWithAction = new Action(Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects,
                currentNotEffects, currentClickEffects);
            useWithAction.setKeepDistance(currentKeepDistance);
            useWithAction.setNeedsGoTo(currentNeedsGoTo);
            useWithAction.setActivatedNotEffects(activateNotEffects);
            useWithAction.setActivatedClickEffects(activateClickEffects);
            this.element.addAction(useWithAction);
        }

        foreach (XmlElement el in givesto)
        {
            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentIdTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("click-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateClickEffects = tmpArgVal.Equals("yes");
            }
            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();

            Action giveToAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects,
                currentNotEffects, currentClickEffects);
            giveToAction.setKeepDistance(currentKeepDistance);
            giveToAction.setNeedsGoTo(currentNeedsGoTo);
            giveToAction.setActivatedNotEffects(activateNotEffects);
            giveToAction.setActivatedClickEffects(activateClickEffects);
            this.element.addAction(giveToAction);
        }

        foreach (XmlElement el in customs)
        {
            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentIdTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentName = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("click-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateClickEffects = tmpArgVal.Equals("yes");
            }

            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();
            tmpXmlEl = el.SelectSingleNode ("condition");
            if (tmpXmlEl != null)
                new ConditionSubParser_ (currentConditions, chapter).ParseElement (tmpXmlEl);

            tmpXmlEl = el.SelectSingleNode ("effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentEffects, chapter).ParseElement (tmpXmlEl);

            tmpXmlEl = el.SelectSingleNode ("click-effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentClickEffects, chapter).ParseElement (tmpXmlEl);

            tmpXmlEl = el.SelectSingleNode ("not-effect");
            if (tmpXmlEl != null)
                new EffectSubParser_ (currentNotEffects, chapter).ParseElement (tmpXmlEl);

            currentCustomAction = new CustomAction(Action.CUSTOM);

            currentCustomAction.setName(currentName);
            currentCustomAction.setConditions(currentConditions);
            currentCustomAction.setEffects(currentEffects);
            currentCustomAction.setNotEffects(currentNotEffects);
            currentCustomAction.setKeepDistance(currentKeepDistance);
            currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
            currentCustomAction.setActivatedNotEffects(activateNotEffects);
            currentCustomAction.setClickEffects(currentClickEffects);
            currentCustomAction.setActivatedClickEffects(activateClickEffects);
            XmlElement res = (XmlElement) el.SelectSingleNode ("resources");
            if (res != null)
                currentCustomAction.addResources(parseResources(res));
            this.element.addAction(currentCustomAction);
            currentCustomAction = null;
        }

        foreach (XmlElement el in customsinteract)
        {
            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentIdTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentName = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("needsGoTo");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentNeedsGoTo = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("keepDistance");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentKeepDistance = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateNotEffects = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("click-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                activateClickEffects = tmpArgVal.Equals("yes");
            }
            currentConditions = new Conditions();
            currentEffects = new Effects();
            currentNotEffects = new Effects();
            currentClickEffects = new Effects();
            currentCustomAction = new CustomAction(Action.CUSTOM_INTERACT);

            currentCustomAction.setConditions(currentConditions);
            currentCustomAction.setEffects(currentEffects);
            currentCustomAction.setNotEffects(currentNotEffects);
            currentCustomAction.setName(currentName);
            currentCustomAction.setTargetId(currentIdTarget);
            currentCustomAction.setKeepDistance(currentKeepDistance);
            currentCustomAction.setNeedsGoTo(currentNeedsGoTo);
            currentCustomAction.setActivatedNotEffects(activateNotEffects);
            currentCustomAction.setClickEffects(currentClickEffects);
            currentCustomAction.setActivatedClickEffects(activateClickEffects);

            XmlElement res = (XmlElement) el.SelectSingleNode ("resources");
            if (res != null)
                currentCustomAction.addResources(parseResources(res));

            this.element.addAction(currentCustomAction);
            currentCustomAction = null;
        }

        foreach (XmlElement el in effects)
        {
            currentEffects = new Effects();
            new EffectSubParser_(currentEffects, chapter).ParseElement(el);
        }
        foreach (XmlElement el in notseffect)
        {
            currentNotEffects = new Effects();
            new EffectSubParser_(currentNotEffects, chapter).ParseElement(el);
        }
        foreach (XmlElement el in effects)
        {
            currentClickEffects = new Effects();
            new EffectSubParser_(currentClickEffects, chapter).ParseElement(el);
        }*/
    }
    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);
    }