예제 #1
0
        public override bool addElement(int type, string id)
        {
            Action newAction = null;

            switch (type)
            {
            case Controller.ACTION_EXAMINE:
                newAction = new Action(Action.EXAMINE);

                break;

            case Controller.ACTION_USE:
                newAction = new Action(Action.USE);
                break;

            case Controller.ACTION_GRAB:
                var item = parent as ItemDataControl;
                newAction = new Action(Action.GRAB)
                {
                    Effects = new Effects()
                    {
                        new RemoveElementEffect(item.getId()),
                        new GenerateObjectEffect(item.getId())
                    }
                };
                break;

            case Controller.ACTION_TALK_TO:

                string[] conversations = controller.IdentifierSummary.getIds <Conversation>();
                if (id != null && conversations.Contains(id))
                {
                    newAction = new Action(Action.TALK_TO);
                    newAction.getEffects().Add(new TriggerConversationEffect(id));
                }
                else
                {
                    var options         = conversations.ToList();
                    var newConversation = "--- New ---";
                    options.Insert(0, newConversation);
                    controller.ShowInputDialog(TC.get("TalkToAction.MessageSelectConversation"), TC.get("TalkToAction.MessageSelectConversation"), options.ToArray(), (nothing, conversationId) =>
                    {
                        var action = new Action(Action.TALK_TO);
                        if (conversationId == newConversation)
                        {
                            var conversationList = controller.SelectedChapterDataControl.getConversationsList();
                            conversationList.addElement(Controller.CONVERSATION_GRAPH, null, false, this, (sender, newConversationId) =>
                            {
                                action.getEffects().Add(new TriggerConversationEffect(newConversationId));
                                performAddAction(action);
                                if (controller.ShowStrictConfirmDialog("Open conversation?", "Do you want to open the new conversation?"))
                                {
                                    controller.SelectElement(conversationList.getConversations().Last());
                                }
                            });
                        }
                        else
                        {
                            action.getEffects().Add(new TriggerConversationEffect(conversationId));
                            performAddAction(action);
                        }
                    });
                    return(true);
                }

                break;

            // For these tree the creation pipeline is the same
            case Controller.ACTION_USE_WITH:
            case Controller.ACTION_DRAG_TO:
            case Controller.ACTION_GIVE_TO:

                string        message    = "";
                int           actionType = -1;
                System.Type[] validTypes = { };

                // Select the elements, the action, and the popup message
                switch (type)
                {
                case Controller.ACTION_DRAG_TO:
                    validTypes = new System.Type[] { typeof(Item), typeof(ActiveArea), typeof(NPC) };
                    actionType = Action.DRAG_TO;
                    message    = TC.get("CustomAction.MessageSelectInteraction");
                    break;

                case Controller.ACTION_USE_WITH:
                    validTypes = new System.Type[] { typeof(Item), typeof(ActiveArea) };
                    actionType = Action.USE_WITH;
                    message    = TC.get("Action.MessageSelectItem");
                    break;

                case Controller.ACTION_GIVE_TO:
                    validTypes = new System.Type[] { typeof(NPC) };
                    message    = TC.get("Action.MessageSelectNPC");
                    actionType = Action.GIVE_TO;
                    break;
                }

                // If the list has elements, show the dialog with the options
                auxCreateInteractiveAction(message, actionType, validTypes, (selectedTarget) =>
                {
                    var action     = new Action(actionType, selectedTarget);
                    var parentItem = parent as ItemDataControl;
                    if (parentItem != null && controller.ShowStrictConfirmDialog("Consume item?", "Do you want the item to be removed from the inventory in the action?"))
                    {
                        action.Effects.Add(new ConsumeObjectEffect(parentItem.getId()));
                    }
                    return(action);
                });
                break;
            }


            if (type == Controller.ACTION_CUSTOM_INTERACT)
            {
                controller.ShowInputDialog(TC.get("CustomAction.GetNameTitle"), TC.get("CustomAction.GetNameMessage"), (sender, name) =>
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        name = "NONAME_" + Random.Range(0, 1000);
                    }

                    string[] options = { TC.get("Element.Action"), TC.get("Element.Interaction") };
                    controller.ShowInputDialog(TC.get("CustomAction.SelectTypeMessage"), TC.get("CustomAction.SelectTypeTitle"), options, (sender2, optionSelected) =>
                    {
                        switch (System.Array.IndexOf(options, optionSelected))
                        {
                        case 0:
                            {
                                var customAction = new CustomAction(Action.CUSTOM);
                                customAction.setName(name);
                                performAddAction(customAction);
                            }
                            break;

                        case 1:
                            auxCreateInteractiveAction(TC.get("CustomAction.MessageSelectInteraction"),
                                                       Action.CUSTOM_INTERACT, new System.Type[] { typeof(Item), typeof(ActiveArea), typeof(NPC) },
                                                       (selectedTarget) =>
                            {
                                var customAction = new CustomAction(Action.CUSTOM_INTERACT, selectedTarget);
                                customAction.setName(name);
                                return(customAction);
                            });
                            break;
                        }
                    });
                });
            }
            else if (type == Controller.ACTION_CUSTOM)
            {
                controller.ShowInputDialog(TC.get("CustomAction.GetNameTitle"), TC.get("CustomAction.GetNameMessage"), (sender, name) =>
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        name = "NONAME_" + Random.Range(0, 1000);
                    }

                    var customAction = new CustomAction(Action.CUSTOM);
                    customAction.setName(name);
                    performAddAction(customAction);
                });
            }

            // If an action was added, create a controller and store it
            if (newAction != null)
            {
                performAddAction(newAction);
            }

            return(newAction != null);
        }
    /*
     * (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;
            }
        }
    }
    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)
    {
        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);
        }*/
    }