Example #1
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 player tag, store the player in the game data
            if (qName.Equals("player"))
            {
                chapter.setPlayer(player);
            }

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

            // If it is a resources tag, add the resources to the player
            else if (qName.Equals("resources"))
            {
                player.addResources(currentResources);
            }
            // 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, add the condition to the resources, and switch the state
            if (qName.Equals("condition"))
            {
                currentResources.setConditions(currentConditions);
                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;
            }
        }
    }
    private ResourcesUni parseResources(XmlElement resources)
    {
        XmlNodeList assets, conditions;
        string      tmpArgVal = "";

        currentResources = new ResourcesUni();

        tmpArgVal = resources.GetAttribute("name");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            currentResources.setName(tmpArgVal);
        }

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

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

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


        return(currentResources);
    }
Example #3
0
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess     = element.SelectNodes("resources"),
            documentations = element.SelectNodes("documentations"),
            texts          = element.SelectNodes("text"),
            pagess         = element.SelectNodes("pages"),
            conditions,
            assets,
            pages,
            titles,
            bullets,
            imgs;

        string tmpArgVal;

        string bookId = "";
        string xPrevious = "", xNext = "", yPrevious = "", yNext = "";

        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            bookId = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("xPreviousPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            xPrevious = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("xNextPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            xNext = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("yPreviousPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            yPrevious = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("yNextPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            yNext = tmpArgVal;
        }

        book = new Book(bookId);

        if (xPrevious != "" && yPrevious != "")
        {
            try
            {
                int x = int.Parse(xPrevious);
                int y = int.Parse(yPrevious);
                book.setPreviousPageVector2(new Vector2(x, y));
            }
            catch (Exception e)
            {
                // Number in XML is wrong -> Do nothing
            }
        }
        if (xNext != "" && yNext != "")
        {
            try
            {
                int x = int.Parse(xNext);
                int y = int.Parse(yNext);
                book.setNextPageVector2(new Vector2(x, y));
            }
            catch (Exception e)
            {
                // Number in XML is wrong -> Do nothing
            }
        }

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();

            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(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);
            }

            book.addResources(currentResources);
        }
        foreach (XmlElement el in documentations)
        {
            string currentstring = el.InnerText;
            book.setDocumentation(currentstring.ToString().Trim());
        }

        foreach (XmlElement el in texts)
        {
            book.setType(Book.TYPE_PARAGRAPHS);
            string currentstring_ = el.InnerText;
            // Add the new text paragraph
            if (currentstring_ != null &&
                currentstring_.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
            {
                book.addParagraph(new BookParagraph(BookParagraph.TEXT,
                                                    currentstring_.ToString().Trim().Replace("\t", "")));
            }

            titles = el.SelectNodes("title");
            foreach (XmlElement ell in titles)
            {
                string currentstring = ell.InnerText;
                if (currentstring != null &&
                    currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                {
                    book.addParagraph(new BookParagraph(BookParagraph.TITLE,
                                                        currentstring.ToString().Trim().Replace("\t", "")));
                }
            }

            bullets = el.SelectNodes("bullet");
            foreach (XmlElement ell in bullets)
            {
                string currentstring = ell.InnerText;
                if (currentstring != null &&
                    currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                {
                    book.addParagraph(new BookParagraph(BookParagraph.BULLET,
                                                        currentstring.ToString().Trim().Replace("\t", "")));
                }
            }

            imgs = el.SelectNodes("img");
            foreach (XmlElement ell in imgs)
            {
                string currentstring = ell.InnerText;
                // Add the new text paragraph
                if (currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                {
                    book.addParagraph(new BookParagraph(BookParagraph.TEXT,
                                                        currentstring.ToString().Trim().Replace("\t", "")));
                    currentstring = string.Empty;
                }

                string path = "";
                tmpArgVal = ell.GetAttribute("src");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                // Add the new image paragraph
                book.addParagraph(new BookParagraph(BookParagraph.IMAGE, path));
            }
        }
        foreach (XmlElement el in pagess)
        {
            book.setType(Book.TYPE_PAGES);

            pages = el.SelectNodes("page");

            foreach (XmlElement ell in pages)
            {
                string uri          = "";
                int    type         = BookPage.TYPE_URL;
                int    margin       = 0;
                int    marginEnd    = 0;
                int    marginTop    = 0;
                int    marginBottom = 0;
                bool   scrollable   = false;

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

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("resource"))
                    {
                        type = BookPage.TYPE_RESOURCE;
                    }
                    if (tmpArgVal.Equals("image"))
                    {
                        type = BookPage.TYPE_IMAGE;
                    }
                }

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("resource"))
                    {
                        type = BookPage.TYPE_RESOURCE;
                    }
                    if (tmpArgVal.Equals("image"))
                    {
                        type = BookPage.TYPE_IMAGE;
                    }
                }

                tmpArgVal = ell.GetAttribute("scrollable");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("yes"))
                    {
                        scrollable = true;
                    }
                }

                tmpArgVal = ell.GetAttribute("margin");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        margin = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }

                tmpArgVal = ell.GetAttribute("marginEnd");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        marginEnd = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }

                tmpArgVal = ell.GetAttribute("marginTop");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        marginTop = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }

                tmpArgVal = ell.GetAttribute("marginBottom");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        marginBottom = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }


                book.addPage(uri, type, margin, marginEnd, marginTop, marginBottom, scrollable);
            }
        }


        chapter.addBook(book);
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            assets,
            conditions,
            textcolors = element.SelectNodes("textcolor"),
            bordercolos,
            frontcolors,
            voices = element.SelectNodes("voice"),
            descriptionss = element.SelectNodes("description");

        string tmpArgVal;

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

        if (element.SelectSingleNode("documentation") != null)
            player.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);
            }

            player.addResources(currentResources);
        }

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

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

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

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

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

                player.setTextFrontColor(color);
            }

            bordercolos = element.SelectNodes("bordercolor");
            foreach (XmlElement ell in bordercolos)
            {
                string color = "";

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

                player.setTextBorderColor(color);
            }
        }

        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;
            }

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

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

        chapter.setPlayer(player);
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            effects = element.SelectNodes("effect");

        string tmpArgVal;

        string atrezzoId = element.GetAttribute("id");
        atrezzo = new Atrezzo(atrezzoId);

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

        if (element.SelectSingleNode("documentation") != null)
            atrezzo.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);
            }

            atrezzo.addResources(currentResources);
        }

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

        foreach (XmlElement el in effects)
        {
            currentEffects = new Effects();
            new EffectSubParser_(currentEffects, chapter).ParseElement(el);
        }

        chapter.addAtrezzo(atrezzo);
    }
    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);
    }
Example #7
0
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            assets,
            conditions,
            effects,
            postseffects,
            notseffect,
            defaultsinitialsposition = element.SelectNodes("default-initial-position"),
            exits = element.SelectNodes("exits/exit"),
            exitslook,
            nextsscene = element.SelectNodes("next-scene"),
            points,
            objectsrefs    = element.SelectNodes("objects/object-ref"),
            charactersrefs = element.SelectNodes("characters/character-ref"),
            atrezzosrefs   = element.SelectNodes("atrezzo/atrezzo-ref"),
            activesareas   = element.SelectNodes("active-areas/active-area"),
            barriers       = element.SelectNodes("barrier"),
            trajectorys    = element.SelectNodes("trajectory");

        string tmpArgVal;

        string sceneId      = "";
        bool   initialScene = false;
        int    playerLayer  = -1;
        float  playerScale  = 1.0f;

        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            sceneId = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("start");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            initialScene = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("playerLayer");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            playerLayer = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("playerScale");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            playerScale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
        }

        scene = new Scene(sceneId);
        scene.setPlayerLayer(playerLayer);
        scene.setPlayerScale(playerScale);
        if (initialScene)
        {
            chapter.setTargetId(sceneId);
        }

        if (element.SelectSingleNode("name") != null)
        {
            scene.setName(element.SelectSingleNode("name").InnerText);
        }
        if (element.SelectSingleNode("documentation") != null)
        {
            scene.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);
            }

            scene.addResources(currentResources);
        }

        foreach (XmlElement el in defaultsinitialsposition)
        {
            int x = int.MinValue, y = int.MinValue;

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

            scene.setDefaultPosition(x, y);
        }

        foreach (XmlElement el in exits)
        {
            int    x = 0, y = 0, width = 0, height = 0;
            bool   rectangular = true;
            int    influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool   hasInfluence = false;
            string idTarget = "";
            int    destinyX = int.MinValue, destinyY = int.MinValue;
            int    transitionType = 0, transitionTime = 0;
            bool   notEffects = false;

            tmpArgVal = el.GetAttribute("rectangular");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                rectangular = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("width");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                width = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("height");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                height = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("destinyX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                destinyX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("destinyY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                destinyY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionType");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionType = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionTime");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionTime = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                notEffects = tmpArgVal.Equals("yes");
            }

            currentExit = new Exit(rectangular, x, y, width, height);
            currentExit.setNextSceneId(idTarget);
            currentExit.setDestinyX(destinyX);
            currentExit.setDestinyY(destinyY);
            currentExit.setTransitionTime(transitionTime);
            currentExit.setTransitionType(transitionType);
            currentExit.setHasNotEffects(notEffects);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentExit.setInfluenceArea(influenceArea);
            }

            exitslook = el.SelectNodes("exit-look");
            foreach (XmlElement ell in exitslook)
            {
                currentExitLook = new ExitLook();
                string text       = null;
                string cursorPath = null;
                string soundPath  = null;

                tmpArgVal = ell.GetAttribute("text");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    text = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("cursor-path");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    cursorPath = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("sound-path");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    soundPath = tmpArgVal;
                }

                currentExitLook.setCursorPath(cursorPath);
                currentExitLook.setExitText(text);
                if (soundPath != null)
                {
                    currentExitLook.setSoundPath(soundPath);
                }
                currentExit.setDefaultExitLook(currentExitLook);
            }

            if (el.SelectSingleNode("documentation") != null)
            {
                currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText);
            }

            points = el.SelectNodes("point");
            foreach (XmlElement ell in points)
            {
                int x_ = 0;
                int y_ = 0;

                tmpArgVal = ell.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x_ = int.Parse(tmpArgVal);
                }
                tmpArgVal = ell.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y_ = int.Parse(tmpArgVal);
                }
                currentPoint = new Vector2(x_, y_);
                currentExit.addPoint(currentPoint);
            }

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


            effects = el.SelectNodes("effect");
            foreach (XmlElement ell in effects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentExit.setEffects(currentEffects);
            }

            notseffect = el.SelectNodes("not-effect");
            foreach (XmlElement ell in notseffect)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentExit.setNotEffects(currentEffects);
            }

            postseffects = el.SelectNodes("post-effect");
            foreach (XmlElement ell in postseffects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentExit.setPostEffects(currentEffects);
            }


            if (currentExit.getNextScenes().Count > 0)
            {
                foreach (NextScene nextScene in currentExit.getNextScenes())
                {
                    Exit exit = (Exit)currentExit;
                    exit.setNextScenes(new List <NextScene>());
                    exit.setDestinyX(nextScene.getPositionX());
                    exit.setDestinyY(nextScene.getPositionY());
                    exit.setEffects(nextScene.getEffects());
                    exit.setPostEffects(nextScene.getPostEffects());
                    if (exit.getDefaultExitLook() == null)
                    {
                        exit.setDefaultExitLook(nextScene.getExitLook());
                    }
                    else
                    {
                        if (nextScene.getExitLook() != null)
                        {
                            if (nextScene.getExitLook().getExitText() != null &&
                                !nextScene.getExitLook().getExitText().Equals(""))
                            {
                                exit.getDefaultExitLook().setExitText(nextScene.getExitLook().getExitText());
                            }
                            if (nextScene.getExitLook().getCursorPath() != null &&
                                !nextScene.getExitLook().getCursorPath().Equals(""))
                            {
                                exit.getDefaultExitLook().setCursorPath(nextScene.getExitLook().getCursorPath());
                            }
                        }
                    }
                    exit.setHasNotEffects(false);
                    exit.setConditions(nextScene.getConditions());
                    exit.setNextSceneId(nextScene.getTargetId());
                    scene.addExit(exit);
                }
            }
            else
            {
                scene.addExit(currentExit);
            }
        }


        foreach (XmlElement el in nextsscene)
        {
            string idTarget = "";
            int    x = int.MinValue, y = int.MinValue;
            int    transitionType = 0, transitionTime = 0;


            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionType");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionType = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionTime");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionTime = int.Parse(tmpArgVal);
            }

            currentNextScene = new NextScene(idTarget, x, y);
            currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType);
            currentNextScene.setTransitionTime(transitionTime);

            currentNextScene.setExitLook(currentExitLook);


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

            effects = el.SelectNodes("effect");
            foreach (XmlElement ell in effects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setEffects(currentEffects);
            }
            postseffects = el.SelectNodes("post-effect");
            foreach (XmlElement ell in effects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setPostEffects(currentEffects);
            }
        }


        foreach (XmlElement el in objectsrefs)
        {
            string idTarget = "";
            int    x = 0, y = 0;
            float  scale = 0;
            int    layer = 0;
            int    influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool   hasInfluence = false;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("scale");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }

            // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is
            // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value
            // for layer
            if (layer == -1)
            {
                layer = 0;
            }

            currentElementReference = new ElementReference(idTarget, x, y, layer);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentElementReference.setInfluenceArea(influenceArea);
            }
            if (scale > 0.001 || scale < -0.001)
            {
                currentElementReference.setScale(scale);
            }

            if (el.SelectSingleNode("documentation") != null)
            {
                currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);
            }

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

            scene.addItemReference(currentElementReference);
        }

        foreach (XmlElement el in charactersrefs)
        {
            string idTarget = "";
            int    x = 0, y = 0;
            float  scale = 0;
            int    layer = 0;
            int    influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool   hasInfluence = false;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("scale");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }

            // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is
            // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value
            // for layer
            if (layer == -1)
            {
                layer = 0;
            }

            currentElementReference = new ElementReference(idTarget, x, y, layer);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentElementReference.setInfluenceArea(influenceArea);
            }
            if (scale > 0.001 || scale < -0.001)
            {
                currentElementReference.setScale(scale);
            }

            if (el.SelectSingleNode("documentation") != null)
            {
                currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);
            }

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

            scene.addCharacterReference(currentElementReference);
        }

        foreach (XmlElement el in atrezzosrefs)
        {
            string idTarget = "";
            int    x = 0, y = 0;
            float  scale = 0;
            int    layer = 0;
            int    influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool   hasInfluence = false;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("scale");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }


            // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is
            // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value
            // for layer
            if (layer == -1)
            {
                layer = 0;
            }

            currentElementReference = new ElementReference(idTarget, x, y, layer);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentElementReference.setInfluenceArea(influenceArea);
            }
            if (scale > 0.001 || scale < -0.001)
            {
                currentElementReference.setScale(scale);
            }

            if (el.SelectSingleNode("documentation") != null)
            {
                currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);
            }

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

            scene.addAtrezzoReference(currentElementReference);
        }

        foreach (XmlElement el in activesareas)
        {
            new ActiveAreaSubParser_(chapter, scene, scene.getActiveAreas().Count).ParseElement(el);
        }

        foreach (XmlElement el in barriers)
        {
            new BarrierSubParser_(chapter, scene, scene.getBarriers().Count).ParseElement(el);
        }

        foreach (XmlElement el in trajectorys)
        {
            new TrajectorySubParser_(chapter, scene).ParseElement(el);
        }



        if (scene != null)
        {
            TrajectoryFixer.fixTrajectory(scene);
        }
        chapter.addScene(scene);
    }
Example #8
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 an object tag, store the object in the game data
            if (qName.Equals("atrezzoobject"))
            {
                chapter.addAtrezzo(atrezzo);
            }

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

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

            // 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 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;
            }
        }
    }
Example #9
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a character tag, store the character in the game data
            if (qName.Equals("character"))
            {
                chapter.addCharacter(npc);
            }

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

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

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

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

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

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

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

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

        // If it is a description tag, create the new description (with its id)
        else if (subParsing == SUBPARSING_DESCRIPTION)
        {
            // Spread the call
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("description"))
            {
                this.descriptions.Add(description);
                subParsing = SUBPARSING_NONE;
            }
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess    = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            effects = element.SelectNodes("effect");

        string tmpArgVal;

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

        atrezzo = new Atrezzo(atrezzoId);

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

        if (element.SelectSingleNode("documentation") != null)
        {
            atrezzo.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);
            }

            atrezzo.addResources(currentResources);
        }

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

        foreach (XmlElement el in effects)
        {
            currentEffects = new Effects();
            new EffectSubParser_(currentEffects, chapter).ParseElement(el);
        }

        chapter.addAtrezzo(atrezzo);
    }
    private ResourcesUni parseResources(XmlElement resources)
    {
        XmlNodeList assets, conditions;
        string tmpArgVal = "";

        currentResources = new ResourcesUni();

        tmpArgVal = resources.GetAttribute("name");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            currentResources.setName(tmpArgVal);
        }

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

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

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

        return currentResources;
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            endsgame = element.SelectNodes("end-game"),
            nextsscene = element.SelectNodes("next-scene"),
            resourcess = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions = element.SelectNodes("condition"),
            effects = element.SelectNodes("effect"),
            postseffects = element.SelectNodes("post-effect");

        string tmpArgVal;

        string slidesceneId = "";
        bool initialScene = false;
        string idTarget = "";
        int x = int.MinValue, y = int.MinValue;
        int transitionType = 0, transitionTime = 0;
        string next = "go-back";
        bool canSkip = true;

        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            slidesceneId = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("start");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            initialScene = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("idTarget");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            idTarget = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("destinyX");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            x = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("destinyY");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            y = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("transitionType");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            transitionType = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("transitionTime");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            transitionTime = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("next");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            next = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("canSkip");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            canSkip = tmpArgVal.Equals("yes");
        }
        if (element.Name.Equals("slidescene"))
            cutscene = new Slidescene(slidesceneId);
        else
            cutscene = new Videoscene(slidesceneId);
        if (initialScene)
            chapter.setTargetId(slidesceneId);

        cutscene.setTargetId(idTarget);
        cutscene.setPositionX(x);
        cutscene.setPositionY(y);
        cutscene.setTransitionType((NextSceneEnumTransitionType) transitionType);
        cutscene.setTransitionTime(transitionTime);

        if(element.SelectSingleNode("name")!= null)
             cutscene.setName(element.SelectSingleNode("name").InnerText);
        if (element.SelectSingleNode("documentation") != null)
            cutscene.setDocumentation(element.SelectSingleNode("documentation").InnerText);

        foreach (XmlElement ell in effects)
        {
            currentEffects = new Effects();
            new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
            cutscene.setEffects(currentEffects);
        }

        if (cutscene is Videoscene)
            ((Videoscene) cutscene).setCanSkip(canSkip);

        if (next.Equals("go-back"))
        {
            cutscene.setNext(Cutscene.GOBACK);
        }
        else if (next.Equals("new-scene"))
        {
            cutscene.setNext(Cutscene.NEWSCENE);
        }
        else if (next.Equals("end-chapter"))
        {
            cutscene.setNext(Cutscene.ENDCHAPTER);
        }

        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);
            }

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

            cutscene.addResources(currentResources);
        }

        foreach (XmlElement el in endsgame)
        {
            cutscene.setNext(Cutscene.ENDCHAPTER);
        }

        foreach (XmlElement el in nextsscene)
        {
            string idTarget_ = "";
            int x_ = int.MinValue, y_ = int.MinValue;
            int transitionType_ = 0, transitionTime_ = 0;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget_ = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x_ = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y_ = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionType");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionType_ = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionTime");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionTime_ = int.Parse(tmpArgVal);
            }

            currentNextScene = new NextScene(idTarget_, x_, y_);
            currentNextScene.setTransitionType((NextSceneEnumTransitionType) transitionType_);
            currentNextScene.setTransitionTime(transitionTime_);
            XmlNodeList conditionss = el.SelectNodes("condition");
            foreach (XmlElement ell in conditionss)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentNextScene.setConditions(currentConditions);
            }

            XmlNodeList effectsss = el.SelectNodes("effect");
            foreach (XmlElement ell in effectsss)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setEffects(currentEffects);
            }

            XmlNodeList postseffectsss = el.SelectNodes("post-effect");
            foreach (XmlElement ell in postseffects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setPostEffects(currentEffects);
            }

            cutscene.addNextScene(currentNextScene);
        }

        chapter.addCutscene(cutscene);
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess    = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            actionss = element.SelectNodes("actions"),
            effects  = element.SelectNodes("effect");

        string tmpArgVal;

        string parsedObjectId     = "";
        bool   returnsWhenDragged = true;

        Item.BehaviourType behaviour = Item.BehaviourType.NORMAL;
        long resourceTransition      = 0;

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

        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            parsedObjectId = tmpArgVal;
        }

        tmpArgVal = element.GetAttribute("returnsWhenDragged");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            returnsWhenDragged = (tmpArgVal.Equals("yes") ? true : false);
        }

        tmpArgVal = element.GetAttribute("behaviour");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            if (tmpArgVal.Equals("normal"))
            {
                behaviour = Item.BehaviourType.NORMAL;
            }
            else if (tmpArgVal.Equals("atrezzo"))
            {
                behaviour = Item.BehaviourType.ATREZZO;
            }
            else if (tmpArgVal.Equals("first-action"))
            {
                behaviour = Item.BehaviourType.FIRST_ACTION;
            }
        }

        tmpArgVal = element.GetAttribute("resources-transition-time");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            resourceTransition = long.Parse(tmpArgVal);
        }

        parsedObject = new Item(parsedObjectId);
        parsedObject.setReturnsWhenDragged(returnsWhenDragged);

        parsedObject.setResourcesTransitionTime(resourceTransition);
        parsedObject.setBehaviour(behaviour);

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

        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);
            }

            parsedObject.addResources(currentResources);
        }

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

        chapter.addItem(parsedObject);
    }
Example #14
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 book tag, add the book to the game data
            if (qName.Equals("book"))
            {
                chapter.addBook(book);
            }

            // If it is a resources tag, add the resources to the book
            else if (qName.Equals("resources"))
            {
                book.addResources(currentResources);
            }

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

            // If it is a text tag, add the text to the book
            else if (qName.Equals("text"))
            {
                // Add the new text paragraph
                if (currentstring != null && currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                {
                    book.addParagraph(new BookParagraph(BookParagraph.TEXT, currentstring.ToString().Trim().Replace("\t", "")));
                }
            }

            // If it is a title tag, add the text to the book
            else if (qName.Equals("title"))
            {
                // Add the new title paragraph
                if (currentstring != null)
                {
                    book.addParagraph(new BookParagraph(BookParagraph.TITLE, currentstring.ToString().Trim().Replace("\t", "")));
                }
            }

            else if (qName.Equals("bullet"))
            {
                // Add the new bullet paragraph
                if (currentstring != null)
                {
                    book.addParagraph(new BookParagraph(BookParagraph.BULLET, currentstring.ToString().Trim().Replace("\t", "")));
                }
            }

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

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

            // If the condition is being closed, add the conditions to the resources
            if (qName.Equals("condition"))
            {
                currentResources.setConditions(currentConditions);
                subParsing = SUBPARSING_NONE;
            }
        }
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#endElement(java.lang.string, java.lang.string,
     *      java.lang.string)
     */
    public override void endElement(string namespaceURI, string sName, string qName)
    {
        Debug.Log("END: " + sName + " " + qName + " sub:" + subParsing + ", reading: " + reading);
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a scene tag, store the scene in the game data
            if (qName.Equals("scene"))
            {
                if (scene != null)
                {
                    TrajectoryFixer.fixTrajectory(scene);
                }
                chapter.addScene(scene);
            }

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

            // If it is a name tag, store the name in the scene
            else if (qName.Equals("name"))
            {
                scene.setName(currentstring.ToString().Trim());
            }

            // If it is a documentation tag, hold the documentation in the current element
            else if (qName.Equals("documentation"))
            {
                if (reading == READING_NONE)
                {
                    scene.setDocumentation(currentstring.ToString().Trim());
                }
                else if (reading == READING_EXIT)
                {
                    currentExit.setDocumentation(currentstring.ToString().Trim());
                }
                else if (reading == READING_ELEMENT_REFERENCE)
                {
                    currentElementReference.setDocumentation(currentstring.ToString().Trim());
                }
            }

            // If it is an exit tag, store the exit in the scene
            else if (qName.Equals("exit"))
            {
                if (currentExit.getNextScenes().Count > 0)
                {
                    foreach (NextScene nextScene in currentExit.getNextScenes())
                    {
                        Exit exit = (Exit)currentExit;
                        exit.setNextScenes(new List <NextScene>());
                        exit.setDestinyX(nextScene.getPositionX());
                        exit.setDestinyY(nextScene.getPositionY());
                        exit.setEffects(nextScene.getEffects());
                        exit.setPostEffects(nextScene.getPostEffects());
                        if (exit.getDefaultExitLook() == null)
                        {
                            exit.setDefaultExitLook(nextScene.getExitLook());
                        }
                        else
                        {
                            if (nextScene.getExitLook() != null)
                            {
                                if (nextScene.getExitLook().getExitText() != null && !nextScene.getExitLook().getExitText().Equals(""))
                                {
                                    exit.getDefaultExitLook().setExitText(nextScene.getExitLook().getExitText());
                                }
                                if (nextScene.getExitLook().getCursorPath() != null && !nextScene.getExitLook().getCursorPath().Equals(""))
                                {
                                    exit.getDefaultExitLook().setCursorPath(nextScene.getExitLook().getCursorPath());
                                }
                            }
                        }
                        exit.setHasNotEffects(false);
                        exit.setConditions(nextScene.getConditions());
                        exit.setNextSceneId(nextScene.getTargetId());
                        scene.addExit(exit);
                    }
                }
                else
                {
                    scene.addExit(currentExit);
                }
                //scene.addExit( currentExit );
                reading = READING_NONE;
            }

            // If it is an exit look tag, store the look in the exit
            else if (qName.Equals("exit-look"))
            {
                Debug.Log("559" + currentExitLook.getExitText());
                if (reading == READING_NEXT_SCENE)
                {
                    currentNextScene.setExitLook(currentExitLook);
                }
                else if (reading == READING_EXIT)
                {
                    currentExit.setDefaultExitLook(currentExitLook);
                }
            }

            // If it is a next-scene tag, store the next scene in the current exit
            else if (qName.Equals("next-scene"))
            {
                currentExit.addNextScene(currentNextScene);
                reading = READING_NONE;
            }

            else if (qName.Equals("point"))
            {
                currentExit.addPoint(currentPoint);
            }

            // If it is a object-ref tag, store the reference in the scene
            else if (qName.Equals("object-ref"))
            {
                Debug.Log("SceneReference End");
                scene.addItemReference(currentElementReference);
                reading = READING_NONE;
            }

            // If it is a character-ref tag, store the reference in the scene
            else if (qName.Equals("character-ref"))
            {
                Debug.Log("CharRef End");
                scene.addCharacterReference(currentElementReference);
                reading = READING_NONE;
            }
            // If it is a atrezzo-ref tag, store the reference in the scene
            else if (qName.Equals("atrezzo-ref"))
            {
                scene.addAtrezzoReference(currentElementReference);
                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"))
            {
                // If we are parsing resources, add the condition to the current resources
                if (reading == READING_RESOURCES)
                {
                    currentResources.setConditions(currentConditions);
                }

                // If we are parsing a next-scene, add the condition to the current next scene
                if (reading == READING_NEXT_SCENE)
                {
                    currentNextScene.setConditions(currentConditions);
                }

                // If we are parsing an element reference, add the condition to the current element reference
                if (reading == READING_ELEMENT_REFERENCE)
                {
                    currentElementReference.setConditions(currentConditions);
                }

                if (reading == READING_EXIT)
                {
                    currentExit.setConditions(currentConditions);
                }

                // Switch the 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, add the effects to the current next scene and switch the state
            if (qName.Equals("effect"))
            {
                if (reading == READING_NEXT_SCENE)
                {
                    currentNextScene.setEffects(currentEffects);
                }
                if (reading == READING_EXIT)
                {
                    currentExit.setEffects(currentEffects);
                }
                subParsing = SUBPARSING_NONE;
            }

            // If the effect tag is being closed, add the post-effects to the current next scene and switch the state
            if (qName.Equals("post-effect"))
            {
                if (reading == READING_NEXT_SCENE)
                {
                    currentNextScene.setPostEffects(currentEffects);
                }
                if (reading == READING_EXIT)
                {
                    currentExit.setPostEffects(currentEffects);
                }
                subParsing = SUBPARSING_NONE;
            }

            if (qName.Equals("not-effect"))
            {
                currentExit.setNotEffects(currentEffects);
                subParsing = SUBPARSING_NONE;
            }
        }

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

            if (qName.Equals("active-area"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }

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

            if (qName.Equals("barrier"))
            {
                subParsing = SUBPARSING_NONE;
            }
        }

        else if (subParsing == SUBPARSING_TRAJECTORY)
        {
            subParser.endElement(namespaceURI, sName, qName);
            if (qName.Equals("trajectory"))
            {
                subParsing = SUBPARSING_NONE;
                // next line is moved to TrayectorySubParser
                //scene.getTrajectory().deleteUnconnectedNodes();
            }
        }
    }
    /*
     * (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 slidescene tag, add it to the game data
            if (qName.Equals("slidescene") || qName.Equals("videoscene"))
            {
                chapter.addCutscene(cutscene);
            }

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

            // If it is a name tag, add the name to the slidescene
            else if (qName.Equals("name"))
            {
                cutscene.setName(currentstring.ToString().Trim());
            }

            // If it is a documentation tag, hold the documentation in the slidescene
            else if (qName.Equals("documentation"))
            {
                cutscene.setDocumentation(currentstring.ToString().Trim());
            }

            // If it is a next-scene tag, add the next scene to the slidescene
            else if (qName.Equals("next-scene"))
            {
                cutscene.addNextScene(currentNextScene);
                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"))
            {
                // If we are parsing a resources tag, add the conditions to the current resources
                if (reading == READING_RESOURCES)
                {
                    currentResources.setConditions(currentConditions);
                }

                // If we are parsing a next-scene tag, add the conditions to the current next scene
                if (reading == READING_NEXT_SCENE)
                {
                    currentNextScene.setConditions(currentConditions);
                }

                // Switch the 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, store the effect in the next scene and switch the state
            if (qName.Equals("effect"))
            {
                if (currentNextScene != null)
                {
                    currentNextScene.setEffects(currentEffects);
                }
                else
                {
                    Effects effects = cutscene.getEffects();
                    foreach (AbstractEffect effect in currentEffects.getEffects())
                    {
                        effects.add(effect);
                    }
                }
                subParsing = SUBPARSING_NONE;
            }

            // If the effect tag is being closed, add the post-effects to the current next scene and switch the state
            if (qName.Equals("post-effect"))
            {
                if (currentNextScene != null)
                {
                    currentNextScene.setPostEffects(currentEffects);
                }
                else
                {
                    Effects effects = cutscene.getEffects();
                    foreach (AbstractEffect effect in currentEffects.getEffects())
                    {
                        effects.add(effect);
                    }
                }
                //currentNextScene.setPostEffects( currentEffects );

                subParsing = SUBPARSING_NONE;
            }
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions,
            actionss = element.SelectNodes("actions"),
            effects = element.SelectNodes("effect");

        string tmpArgVal;

        string parsedObjectId = "";
        bool returnsWhenDragged = true;

        Item.BehaviourType behaviour = Item.BehaviourType.NORMAL;
        long resourceTransition = 0;

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

        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            parsedObjectId = tmpArgVal;
        }

        tmpArgVal = element.GetAttribute("returnsWhenDragged");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            returnsWhenDragged = (tmpArgVal.Equals("yes") ? true : false);
        }

        tmpArgVal = element.GetAttribute("behaviour");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            if (tmpArgVal.Equals("normal"))
            {
                behaviour = Item.BehaviourType.NORMAL;
            }
            else if (tmpArgVal.Equals("atrezzo"))
            {
                behaviour = Item.BehaviourType.ATREZZO;
            }
            else if (tmpArgVal.Equals("first-action"))
            {
                behaviour = Item.BehaviourType.FIRST_ACTION;
            }
        }

        tmpArgVal = element.GetAttribute("resources-transition-time");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            resourceTransition = long.Parse(tmpArgVal);
        }

        parsedObject = new Item(parsedObjectId);
        parsedObject.setReturnsWhenDragged(returnsWhenDragged);

        parsedObject.setResourcesTransitionTime(resourceTransition);
        parsedObject.setBehaviour(behaviour);

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

        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);
            }

            parsedObject.addResources(currentResources);
        }

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

        chapter.addItem(parsedObject);
    }
    /*
     * (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)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            assets,
            conditions,
            effects,
            postseffects,
            notseffect,
            defaultsinitialsposition = element.SelectNodes("default-initial-position"),
            exits = element.SelectNodes("exits/exit"),
            exitslook,
            nextsscene = element.SelectNodes("next-scene"),
            points,
            objectsrefs = element.SelectNodes("objects/object-ref"),
            charactersrefs = element.SelectNodes("characters/character-ref"),
            atrezzosrefs = element.SelectNodes("atrezzo/atrezzo-ref"),
            activesareas = element.SelectNodes("active-areas/active-area"),
            barriers = element.SelectNodes("barrier"),
            trajectorys = element.SelectNodes("trajectory");

        string tmpArgVal;

        string sceneId = "";
        bool initialScene = false;
        int playerLayer = -1;
        float playerScale = 1.0f;

        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            sceneId = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("start");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            initialScene = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("playerLayer");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            playerLayer = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("playerScale");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            playerScale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
        }

        scene = new Scene(sceneId);
        scene.setPlayerLayer(playerLayer);
        scene.setPlayerScale(playerScale);
        if (initialScene)
            chapter.setTargetId(sceneId);

        if (element.SelectSingleNode("name") != null)
            scene.setName(element.SelectSingleNode("name").InnerText);
        if (element.SelectSingleNode("documentation") != null)
            scene.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);
            }

            scene.addResources(currentResources);
        }

        foreach (XmlElement el in defaultsinitialsposition)
        {
            int x = int.MinValue, y = int.MinValue;

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

            scene.setDefaultPosition(x, y);
        }

        foreach (XmlElement el in exits)
        {
            int x = 0, y = 0, width = 0, height = 0;
            bool rectangular = true;
            int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool hasInfluence = false;
            string idTarget = "";
            int destinyX = int.MinValue, destinyY = int.MinValue;
            int transitionType = 0, transitionTime = 0;
            bool notEffects = false;

            tmpArgVal = el.GetAttribute("rectangular");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                rectangular = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("width");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                width = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("height");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                height = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("destinyX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                destinyX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("destinyY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                destinyY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionType");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionType = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionTime");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionTime = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("not-effects");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                notEffects = tmpArgVal.Equals("yes");
            }

            currentExit = new Exit(rectangular, x, y, width, height);
            currentExit.setNextSceneId(idTarget);
            currentExit.setDestinyX(destinyX);
            currentExit.setDestinyY(destinyY);
            currentExit.setTransitionTime(transitionTime);
            currentExit.setTransitionType(transitionType);
            currentExit.setHasNotEffects(notEffects);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentExit.setInfluenceArea(influenceArea);
            }

            exitslook = el.SelectNodes("exit-look");
            foreach (XmlElement ell in exitslook)
            {
                currentExitLook = new ExitLook();
                string text = null;
                string cursorPath = null;
                string soundPath = null;

                tmpArgVal = ell.GetAttribute("text");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    text = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("cursor-path");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    cursorPath = tmpArgVal;
                }
                tmpArgVal = ell.GetAttribute("sound-path");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    soundPath = tmpArgVal;
                }

                currentExitLook.setCursorPath(cursorPath);
                currentExitLook.setExitText(text);
                if (soundPath != null)
                {
                    currentExitLook.setSoundPath(soundPath);
                }
                currentExit.setDefaultExitLook(currentExitLook);
            }

            if (el.SelectSingleNode("documentation") != null)
                currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText);

            points = el.SelectNodes("point");
            foreach (XmlElement ell in points)
            {
                int x_ = 0;
                int y_ = 0;

                tmpArgVal = ell.GetAttribute("x");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    x_ = int.Parse(tmpArgVal);
                }
                tmpArgVal = ell.GetAttribute("y");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    y_ = int.Parse(tmpArgVal);
                }
                currentPoint = new Vector2(x_, y_);
                currentExit.addPoint(currentPoint);
            }

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

            effects = el.SelectNodes("effect");
            foreach (XmlElement ell in effects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentExit.setEffects(currentEffects);
            }

            notseffect = el.SelectNodes("not-effect");
            foreach (XmlElement ell in notseffect)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentExit.setNotEffects(currentEffects);
            }

            postseffects = el.SelectNodes("post-effect");
            foreach (XmlElement ell in postseffects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentExit.setPostEffects(currentEffects);
            }

            if (currentExit.getNextScenes().Count > 0)
            {
                foreach (NextScene nextScene in currentExit.getNextScenes())
                {

                    Exit exit = (Exit) currentExit;
                    exit.setNextScenes(new List<NextScene>());
                    exit.setDestinyX(nextScene.getPositionX());
                    exit.setDestinyY(nextScene.getPositionY());
                    exit.setEffects(nextScene.getEffects());
                    exit.setPostEffects(nextScene.getPostEffects());
                    if (exit.getDefaultExitLook() == null)
                        exit.setDefaultExitLook(nextScene.getExitLook());
                    else
                    {
                        if (nextScene.getExitLook() != null)
                        {
                            if (nextScene.getExitLook().getExitText() != null &&
                                !nextScene.getExitLook().getExitText().Equals(""))
                                exit.getDefaultExitLook().setExitText(nextScene.getExitLook().getExitText());
                            if (nextScene.getExitLook().getCursorPath() != null &&
                                !nextScene.getExitLook().getCursorPath().Equals(""))
                                exit.getDefaultExitLook().setCursorPath(nextScene.getExitLook().getCursorPath());
                        }
                    }
                    exit.setHasNotEffects(false);
                    exit.setConditions(nextScene.getConditions());
                    exit.setNextSceneId(nextScene.getTargetId());
                    scene.addExit(exit);
                }
            }
            else
            {
                scene.addExit(currentExit);
            }
        }

        foreach (XmlElement el in nextsscene)
        {
            string idTarget = "";
            int x = int.MinValue, y = int.MinValue;
            int transitionType = 0, transitionTime = 0;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionType");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionType = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionTime");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionTime = int.Parse(tmpArgVal);
            }

            currentNextScene = new NextScene(idTarget, x, y);
            currentNextScene.setTransitionType((NextSceneEnumTransitionType) transitionType);
            currentNextScene.setTransitionTime(transitionTime);

            currentNextScene.setExitLook(currentExitLook);

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

            effects = el.SelectNodes("effect");
            foreach (XmlElement ell in effects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setEffects(currentEffects);
            }
            postseffects = el.SelectNodes("post-effect");
            foreach (XmlElement ell in effects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setPostEffects(currentEffects);
            }

        }

        foreach (XmlElement el in objectsrefs)
        {
            string idTarget = "";
            int x = 0, y = 0;
            float scale = 0;
            int layer = 0;
            int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool hasInfluence = false;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("scale");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }

            // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is
            // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value
            // for layer
            if (layer == -1)
                layer = 0;

            currentElementReference = new ElementReference(idTarget, x, y, layer);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentElementReference.setInfluenceArea(influenceArea);
            }
            if (scale > 0.001 || scale < -0.001)
                currentElementReference.setScale(scale);

            if (el.SelectSingleNode("documentation") != null)
                currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);

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

            scene.addItemReference(currentElementReference);
        }

        foreach (XmlElement el in charactersrefs)
        {
            string idTarget = "";
            int x = 0, y = 0;
            float scale = 0;
            int layer = 0;
            int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool hasInfluence = false;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("scale");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }

            // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is
            // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value
            // for layer
            if (layer == -1)
                layer = 0;

            currentElementReference = new ElementReference(idTarget, x, y, layer);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentElementReference.setInfluenceArea(influenceArea);
            }
            if (scale > 0.001 || scale < -0.001)
                currentElementReference.setScale(scale);

            if (el.SelectSingleNode("documentation") != null)
                currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);

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

            scene.addCharacterReference(currentElementReference);
        }

        foreach (XmlElement el in atrezzosrefs)
        {
            string idTarget = "";
            int x = 0, y = 0;
            float scale = 0;
            int layer = 0;
            int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0;
            bool hasInfluence = false;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("scale");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture);
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("hasInfluenceArea");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                hasInfluence = tmpArgVal.Equals("yes");
            }
            tmpArgVal = el.GetAttribute("layer");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                layer = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceX");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceX = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceY");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceY = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceWidth");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceWidth = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("influenceHeight");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                influenceHeight = int.Parse(tmpArgVal);
            }

            // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is
            // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value
            // for layer
            if (layer == -1)
                layer = 0;

            currentElementReference = new ElementReference(idTarget, x, y, layer);
            if (hasInfluence)
            {
                InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                currentElementReference.setInfluenceArea(influenceArea);
            }
            if (scale > 0.001 || scale < -0.001)
                currentElementReference.setScale(scale);

            if (el.SelectSingleNode("documentation") != null)
                currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText);

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

            scene.addAtrezzoReference(currentElementReference);
        }

        foreach (XmlElement el in activesareas)
        {
            new ActiveAreaSubParser_(chapter, scene, scene.getActiveAreas().Count).ParseElement(el);
        }

        foreach (XmlElement el in barriers)
        {
            new BarrierSubParser_(chapter, scene, scene.getBarriers().Count).ParseElement(el);
        }

        foreach (XmlElement el in trajectorys)
        {
            new TrajectorySubParser_(chapter, scene).ParseElement(el);
        }

        if (scene != null)
        {
            TrajectoryFixer.fixTrajectory(scene);
        }
        chapter.addScene(scene);
    }
Example #20
0
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            endsgame      = element.SelectNodes("end-game"),
            nextsscene    = element.SelectNodes("next-scene"),
            resourcess    = element.SelectNodes("resources"),
            descriptionss = element.SelectNodes("description"),
            assets,
            conditions   = element.SelectNodes("condition"),
            effects      = element.SelectNodes("effect"),
            postseffects = element.SelectNodes("post-effect");

        string tmpArgVal;

        string slidesceneId = "";
        bool   initialScene = false;
        string idTarget = "";
        int    x = int.MinValue, y = int.MinValue;
        int    transitionType = 0, transitionTime = 0;
        string next    = "go-back";
        bool   canSkip = true;


        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            slidesceneId = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("start");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            initialScene = tmpArgVal.Equals("yes");
        }
        tmpArgVal = element.GetAttribute("idTarget");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            idTarget = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("destinyX");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            x = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("destinyY");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            y = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("transitionType");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            transitionType = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("transitionTime");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            transitionTime = int.Parse(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("next");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            next = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("canSkip");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            canSkip = tmpArgVal.Equals("yes");
        }
        if (element.Name.Equals("slidescene"))
        {
            cutscene = new Slidescene(slidesceneId);
        }
        else
        {
            cutscene = new Videoscene(slidesceneId);
        }
        if (initialScene)
        {
            chapter.setTargetId(slidesceneId);
        }

        cutscene.setTargetId(idTarget);
        cutscene.setPositionX(x);
        cutscene.setPositionY(y);
        cutscene.setTransitionType((NextSceneEnumTransitionType)transitionType);
        cutscene.setTransitionTime(transitionTime);

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

        foreach (XmlElement ell in effects)
        {
            currentEffects = new Effects();
            new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
            cutscene.setEffects(currentEffects);
        }


        if (cutscene is Videoscene)
        {
            ((Videoscene)cutscene).setCanSkip(canSkip);
        }

        if (next.Equals("go-back"))
        {
            cutscene.setNext(Cutscene.GOBACK);
        }
        else if (next.Equals("new-scene"))
        {
            cutscene.setNext(Cutscene.NEWSCENE);
        }
        else if (next.Equals("end-chapter"))
        {
            cutscene.setNext(Cutscene.ENDCHAPTER);
        }

        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);
            }

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

            cutscene.addResources(currentResources);
        }

        foreach (XmlElement el in endsgame)
        {
            cutscene.setNext(Cutscene.ENDCHAPTER);
        }

        foreach (XmlElement el in nextsscene)
        {
            string idTarget_ = "";
            int    x_ = int.MinValue, y_ = int.MinValue;
            int    transitionType_ = 0, transitionTime_ = 0;

            tmpArgVal = el.GetAttribute("idTarget");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                idTarget_ = tmpArgVal;
            }
            tmpArgVal = el.GetAttribute("x");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                x_ = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("y");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                y_ = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionType");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionType_ = int.Parse(tmpArgVal);
            }
            tmpArgVal = el.GetAttribute("transitionTime");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                transitionTime_ = int.Parse(tmpArgVal);
            }

            currentNextScene = new NextScene(idTarget_, x_, y_);
            currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType_);
            currentNextScene.setTransitionTime(transitionTime_);
            XmlNodeList conditionss = el.SelectNodes("condition");
            foreach (XmlElement ell in conditionss)
            {
                currentConditions = new Conditions();
                new ConditionSubParser_(currentConditions, chapter).ParseElement(ell);
                currentNextScene.setConditions(currentConditions);
            }

            XmlNodeList effectsss = el.SelectNodes("effect");
            foreach (XmlElement ell in effectsss)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setEffects(currentEffects);
            }

            XmlNodeList postseffectsss = el.SelectNodes("post-effect");
            foreach (XmlElement ell in postseffects)
            {
                currentEffects = new Effects();
                new EffectSubParser_(currentEffects, chapter).ParseElement(ell);
                currentNextScene.setPostEffects(currentEffects);
            }

            cutscene.addNextScene(currentNextScene);
        }

        chapter.addCutscene(cutscene);
    }
Example #21
0
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            assets,
            conditions,
            textcolors = element.SelectNodes("textcolor"),
            bordercolos,
            frontcolors,
            voices        = element.SelectNodes("voice"),
            descriptionss = element.SelectNodes("description");

        string tmpArgVal;

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

        if (element.SelectSingleNode("documentation") != null)
        {
            player.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);
            }

            player.addResources(currentResources);
        }

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

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

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

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

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

                player.setTextFrontColor(color);
            }

            bordercolos = element.SelectNodes("bordercolor");
            foreach (XmlElement ell in bordercolos)
            {
                string color = "";

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

                player.setTextBorderColor(color);
            }
        }

        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;
                }
            }

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


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

        chapter.setPlayer(player);
    }
    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)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            documentations = element.SelectNodes("documentations"),
            texts = element.SelectNodes("text"),
            pagess = element.SelectNodes("pages"),
            conditions,
            assets,
            pages,
            titles,
            bullets,
            imgs;

        string tmpArgVal;

        string bookId = "";
        string xPrevious = "", xNext = "", yPrevious = "", yNext = "";

        tmpArgVal = element.GetAttribute("id");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            bookId = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("xPreviousPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            xPrevious = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("xNextPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            xNext = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("yPreviousPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            yPrevious = tmpArgVal;
        }
        tmpArgVal = element.GetAttribute("yNextPage");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            yNext = tmpArgVal;
        }

        book = new Book(bookId);

        if (xPrevious != "" && yPrevious != "")
        {
            try
            {
                int x = int.Parse(xPrevious);
                int y = int.Parse(yPrevious);
                book.setPreviousPageVector2(new Vector2(x, y));
            }
            catch (Exception e)
            {
                // Number in XML is wrong -> Do nothing
            }
        }
        if (xNext != "" && yNext != "")
        {
            try
            {
                int x = int.Parse(xNext);
                int y = int.Parse(yNext);
                book.setNextPageVector2(new Vector2(x, y));
            }
            catch (Exception e)
            {
                // Number in XML is wrong -> Do nothing
            }
        }

        foreach (XmlElement el in resourcess)
        {
            currentResources = new ResourcesUni();

            tmpArgVal = el.GetAttribute("name");
            if (!string.IsNullOrEmpty(tmpArgVal))
            {
                currentResources.setName(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);
            }

            book.addResources(currentResources);
        }
        foreach (XmlElement el in documentations)
        {
            string currentstring = el.InnerText;
            book.setDocumentation(currentstring.ToString().Trim());
        }

        foreach (XmlElement el in texts)
        {
            book.setType(Book.TYPE_PARAGRAPHS);
            string currentstring_ = el.InnerText;
            // Add the new text paragraph
            if (currentstring_ != null &&
                currentstring_.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                book.addParagraph(new BookParagraph(BookParagraph.TEXT,
                    currentstring_.ToString().Trim().Replace("\t", "")));

            titles = el.SelectNodes("title");
            foreach (XmlElement ell in titles)
            {
                string currentstring = ell.InnerText;
                if (currentstring != null &&
                    currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                    book.addParagraph(new BookParagraph(BookParagraph.TITLE,
                        currentstring.ToString().Trim().Replace("\t", "")));
            }

            bullets = el.SelectNodes("bullet");
            foreach (XmlElement ell in bullets)
            {
                string currentstring = ell.InnerText;
                if (currentstring != null &&
                    currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                    book.addParagraph(new BookParagraph(BookParagraph.BULLET,
                        currentstring.ToString().Trim().Replace("\t", "")));
            }

            imgs = el.SelectNodes("img");
            foreach (XmlElement ell in imgs)
            {
                string currentstring = ell.InnerText;
                // Add the new text paragraph
                if (currentstring.ToString().Trim().Replace("\t", "").Replace("\n", "").Length > 0)
                {
                    book.addParagraph(new BookParagraph(BookParagraph.TEXT,
                        currentstring.ToString().Trim().Replace("\t", "")));
                    currentstring = string.Empty;
                }

                string path = "";
                tmpArgVal = ell.GetAttribute("src");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    path = tmpArgVal;
                }
                // Add the new image paragraph
                book.addParagraph(new BookParagraph(BookParagraph.IMAGE, path));
            }
        }
        foreach (XmlElement el in pagess)
        {
            book.setType(Book.TYPE_PAGES);

            pages = el.SelectNodes("page");

            foreach (XmlElement ell in pages)
            {
                string uri = "";
                int type = BookPage.TYPE_URL;
                int margin = 0;
                int marginEnd = 0;
                int marginTop = 0;
                int marginBottom = 0;
                bool scrollable = false;

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

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("resource"))
                        type = BookPage.TYPE_RESOURCE;
                    if (tmpArgVal.Equals("image"))
                        type = BookPage.TYPE_IMAGE;
                }

                tmpArgVal = ell.GetAttribute("type");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("resource"))
                        type = BookPage.TYPE_RESOURCE;
                    if (tmpArgVal.Equals("image"))
                        type = BookPage.TYPE_IMAGE;
                }

                tmpArgVal = ell.GetAttribute("scrollable");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    if (tmpArgVal.Equals("yes"))
                        scrollable = true;
                }

                tmpArgVal = ell.GetAttribute("margin");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        margin = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }

                tmpArgVal = ell.GetAttribute("marginEnd");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        marginEnd = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }

                tmpArgVal = ell.GetAttribute("marginTop");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        marginTop = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }

                tmpArgVal = ell.GetAttribute("marginBottom");
                if (!string.IsNullOrEmpty(tmpArgVal))
                {
                    try
                    {
                        marginBottom = int.Parse(tmpArgVal);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }

                book.addPage(uri, type, margin, marginEnd, marginTop, marginBottom, scrollable);
            }
        }

        chapter.addBook(book);
    }