Ejemplo n.º 1
0
    /*
     * (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;
            }
        }
    }