/*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a object tag, create the new object (with its id)
            if (qName.Equals("active-area"))
            {
                int    x = 0, y = 0, width = 0, height = 0;
                string id = null;
                bool   rectangular = true;
                int    influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
                bool   hasInfluence = false;

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("rectangular"))
                    {
                        rectangular = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("x"))
                    {
                        x = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("y"))
                    {
                        y = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("width"))
                    {
                        width = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("height"))
                    {
                        height = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("id"))
                    {
                        id = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("hasInfluenceArea"))
                    {
                        hasInfluence = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("influenceX"))
                    {
                        influenceX = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("influenceY"))
                    {
                        influenceY = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("influenceWidth"))
                    {
                        influenceWidth = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("influenceHeight"))
                    {
                        influenceHeight = int.Parse(entry.Value.ToString());
                    }
                }

                activeArea = new ActiveArea((id == null ? generateId() : id), rectangular, x, y, width, height);
                if (hasInfluence)
                {
                    InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                    activeArea.setInfluenceArea(influenceArea);
                }
                descriptions = new List <Description>();
                activeArea.setDescriptions(descriptions);
            }

            else if (qName.Equals("point"))
            {
                if (activeArea != null)
                {
                    int x = 0, y = 0;

                    foreach (KeyValuePair <string, string> entry in attrs)
                    {
                        if (entry.Key.Equals("x"))
                        {
                            x = int.Parse(entry.Value.ToString());
                        }
                        if (entry.Key.Equals("y"))
                        {
                            y = int.Parse(entry.Value.ToString());
                        }
                    }

                    Vector2 point = new Vector2(x, y);
                    activeArea.addVector2(point);
                }
            }

            // If it is a description tag, create the new description (with its id)
            else if (qName.Equals("description"))
            {
                description = new Description();
                subParser   = new DescriptionsSubParser(description, chapter);
                subParsing  = SUBPARSING_DESCRIPTION;
            }
            else if (qName.Equals("actions"))
            {
                subParser  = new ActionsSubParser(chapter, activeArea);
                subParsing = SUBPARSING_ACTIONS;
            }

            // If it is a condition tag, create new conditions and switch the state
            else if (qName.Equals("condition"))
            {
                currentConditions = new Conditions();
                subParser         = new ConditionSubParser(currentConditions, chapter);
                subParsing        = SUBPARSING_CONDITION;
            }

            // If it is a effect tag, create new effects and switch the state
            else if (qName.Equals("effect"))
            {
                subParser  = new EffectSubParser(currentEffects, chapter);
                subParsing = SUBPARSING_EFFECT;
            }
        }

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a object tag, create the new object (with its id)
            if (qName.Equals("active-area"))
            {

                int x = 0, y = 0, width = 0, height = 0;
                string id = null;
                bool rectangular = true;
                int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
                bool hasInfluence = false;

                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    if (entry.Key.Equals("rectangular"))
                        rectangular = entry.Value.ToString().Equals("yes");
                    if (entry.Key.Equals("x"))
                        x = int.Parse(entry.Value.ToString());
                    if (entry.Key.Equals("y"))
                        y = int.Parse(entry.Value.ToString());
                    if (entry.Key.Equals("width"))
                        width = int.Parse(entry.Value.ToString());
                    if (entry.Key.Equals("height"))
                        height = int.Parse(entry.Value.ToString());
                    if (entry.Key.Equals("id"))
                        id = entry.Value.ToString();
                    if (entry.Key.Equals("hasInfluenceArea"))
                        hasInfluence = entry.Value.ToString().Equals("yes");
                    if (entry.Key.Equals("influenceX"))
                        influenceX = int.Parse(entry.Value.ToString());
                    if (entry.Key.Equals("influenceY"))
                        influenceY = int.Parse(entry.Value.ToString());
                    if (entry.Key.Equals("influenceWidth"))
                        influenceWidth = int.Parse(entry.Value.ToString());
                    if (entry.Key.Equals("influenceHeight"))
                        influenceHeight = int.Parse(entry.Value.ToString());

                }

                activeArea = new ActiveArea((id == null ? generateId() : id), rectangular, x, y, width, height);
                if (hasInfluence)
                {
                    InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                    activeArea.setInfluenceArea(influenceArea);
                }
                descriptions = new List<Description>();
                activeArea.setDescriptions(descriptions);
            }

            else if (qName.Equals("point"))
            {
                if (activeArea != null)
                {
                    int x = 0, y = 0;

                    foreach (KeyValuePair<string, string> entry in attrs)
                    {
                        if (entry.Key.Equals("x"))
                            x = int.Parse(entry.Value.ToString());
                        if (entry.Key.Equals("y"))
                            y = int.Parse(entry.Value.ToString());
                    }

                    Vector2 point = new Vector2(x, y);
                    activeArea.addVector2(point);
                }
            }

            // If it is a description tag, create the new description (with its id)
            else if (qName.Equals("description"))
            {
                description = new Description();
                subParser = new DescriptionsSubParser(description, chapter);
                subParsing = SUBPARSING_DESCRIPTION;
            }
            else if (qName.Equals("actions"))
            {
                subParser = new ActionsSubParser(chapter, activeArea);
                subParsing = SUBPARSING_ACTIONS;
            }

            // If it is a condition tag, create new conditions and switch the state
            else if (qName.Equals("condition"))
            {
                currentConditions = new Conditions();
                subParser = new ConditionSubParser(currentConditions, chapter);
                subParsing = SUBPARSING_CONDITION;
            }

            // If it is a effect tag, create new effects and switch the state
            else if (qName.Equals("effect"))
            {
                subParser = new EffectSubParser(currentEffects, chapter);
                subParsing = SUBPARSING_EFFECT;
            }
        }

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            points = element.SelectNodes("point"),
            descriptionss = element.SelectNodes("description"),
            actionss = element.SelectNodes("actions"),
            conditions = element.SelectNodes("condition");
            //,
              //effects = element.SelectNodes("effect");

        string tmpArgVal;

        int x = 0, y = 0, width = 0, height = 0;
        string id = null;
        bool rectangular = true;
        int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
        bool hasInfluence = false;

        tmpArgVal = element.GetAttribute("rectangular");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            rectangular = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("x");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            x = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("y");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            y = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("width");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            width = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("height");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            height = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            id = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("hasInfluenceArea");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            hasInfluence = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("influenceX");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceX = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("influenceY");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceY = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("influenceWidth");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceWidth = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("influenceHeight");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceHeight = int.Parse(tmpArgVal);
        }

        activeArea = new ActiveArea((id == null ? generateId() : id), rectangular, x, y, width, height);
        if (hasInfluence)
        {
            InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
            activeArea.setInfluenceArea(influenceArea);
        }

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

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

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

        foreach (XmlElement el in points)
        {
            if (activeArea != null)
            {
                int x_ = 0, y_ = 0;

                tmpArgVal = el.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x_ = int.Parse(tmpArgVal);
                }
                tmpArgVal = el.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y_ = int.Parse(tmpArgVal);
                }

                Vector2 point = new Vector2(x_, y_);
                activeArea.addVector2(point);
            }
        }

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

        foreach (XmlElement el in conditions)
        {
            currentConditions = new Conditions();
            new ConditionSubParser_(currentConditions, chapter).ParseElement(el);
            this.activeArea.setConditions(currentConditions);
        }
        scene.addActiveArea(activeArea);
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            points        = element.SelectNodes("point"),
            descriptionss = element.SelectNodes("description"),
            actionss      = element.SelectNodes("actions"),
            conditions    = element.SelectNodes("condition");
        //,
        //effects = element.SelectNodes("effect");

        string tmpArgVal;


        int    x = 0, y = 0, width = 0, height = 0;
        string id = null;
        bool   rectangular = true;
        int    influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
        bool   hasInfluence = false;

        tmpArgVal = element.GetAttribute("rectangular");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            rectangular = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("x");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            x = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("y");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            y = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("width");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            width = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("height");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            height = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            id = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("hasInfluenceArea");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            hasInfluence = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("influenceX");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceX = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("influenceY");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceY = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("influenceWidth");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceWidth = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("influenceHeight");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            influenceHeight = int.Parse(tmpArgVal);
        }

        activeArea = new ActiveArea((id == null ? generateId() : id), rectangular, x, y, width, height);
        if (hasInfluence)
        {
            InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
            activeArea.setInfluenceArea(influenceArea);
        }

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

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

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

        foreach (XmlElement el in points)
        {
            if (activeArea != null)
            {
                int x_ = 0, y_ = 0;

                tmpArgVal = el.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x_ = int.Parse(tmpArgVal);
                }
                tmpArgVal = el.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y_ = int.Parse(tmpArgVal);
                }

                Vector2 point = new Vector2(x_, y_);
                activeArea.addVector2(point);
            }
        }

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

        foreach (XmlElement el in conditions)
        {
            currentConditions = new Conditions();
            new ConditionSubParser_(currentConditions, chapter).ParseElement(el);
            this.activeArea.setConditions(currentConditions);
        }
        scene.addActiveArea(activeArea);
    }