private void performAddBook(object sender, string bookId)
        {
            // If some value was typed and the identifier is valid
            if (!controller.isElementIdValid(bookId))
            {
                bookId = controller.makeElementValid(bookId);
            }

            // Add thew new book
            Book newBook = new Book(bookId);

            newBook.setType(Book.TYPE_PARAGRAPHS);

            // Set default background
            ResourcesUni resources = new ResourcesUni();

            resources.addAsset("background", SpecialAssetPaths.ASSET_DEFAULT_BOOK_IMAGE);
            resources.addAsset("arrowLeftNormal", SpecialAssetPaths.ASSET_DEFAULT_ARROW_NORMAL);
            resources.addAsset("arrowLeftOver", SpecialAssetPaths.ASSET_DEFAULT_ARROW_OVER);
            newBook.addResources(resources);

            BookDataControl newDataControl = new BookDataControl(newBook);

            booksList.Add(newBook);
            booksDataControlList.Add(newDataControl);
            controller.IdentifierSummary.addId <Book>(bookId);
        }
Example #2
0
    public GUIProvider(AdventureData data)
    {
        this.guitype = data.getGUIType();


        ResourcesUni auxResource;

        buttons = new Dictionary <int, ResourcesUni> ();

        //We add a resource for each button parsed in descriptor file
        foreach (CustomButton cb in data.getButtons())
        {
            if (buttons.ContainsKey(ActionNameWrapper.IDs [cb.getAction()]))
            {
                buttons [ActionNameWrapper.IDs [cb.getAction()]].addAsset(new Asset(cb.getType(), cb.getPath()));
            }
            else
            {
                auxResource = new ResourcesUni();
                auxResource.addAsset(new Asset(cb.getType(), cb.getPath()));
                buttons.Add(ActionNameWrapper.IDs [cb.getAction()], auxResource);
            }
        }

        //For each button that isn on descriptor file we try to find the default assets;
        Texture2D auxTexture;

        foreach (KeyValuePair <int, string> button in ActionNameWrapper.Names)
        {
            if (!buttons.ContainsKey(button.Key))
            {
                if (DefaultActionAssetWrapper.Assets.ContainsKey(button.Key))
                {
                    string selected = "";
                    foreach (string name in DefaultActionAssetWrapper.Assets[button.Key])
                    {
                        auxTexture = ResourceManager.Instance.getImage(GUIProvider.DEFAULT_ASSET_DIRECTORY + name + ".png");

                        if (auxTexture != null)
                        {
                            selected = name;
                            break;
                        }
                    }

                    if (selected != "")
                    {
                        auxResource = new ResourcesUni();
                        auxResource.addAsset(DescriptorData.NORMAL_BUTTON, GUIProvider.DEFAULT_ASSET_DIRECTORY + selected + ".png");
                        auxResource.addAsset(DescriptorData.HIGHLIGHTED_BUTTON, GUIProvider.DEFAULT_ASSET_DIRECTORY + selected + "Highlighted.png");
                        auxResource.addAsset(DescriptorData.PRESSED_BUTTON, GUIProvider.DEFAULT_ASSET_DIRECTORY + selected + "Pressed.png");
                        buttons.Add(button.Key, auxResource);
                    }
                }
            }
        }
    }
    public GUIProvider(AdventureData data)
    {
        this.guitype = data.getGUIType ();
        this.data = data;

        ResourcesUni auxResource;
        buttons = new Dictionary<int, ResourcesUni> ();
        cursores = new Dictionary<string, Texture2D>();

        //We add a resource for each button parsed in descriptor file
        foreach (CustomButton cb in data.getButtons()) {
            if (buttons.ContainsKey (ActionNameWrapper.IDs [cb.getAction ()])) {
                buttons [ActionNameWrapper.IDs [cb.getAction ()]].addAsset (new Asset (cb.getType (), cb.getPath ()));
            }else{
                auxResource = new ResourcesUni ();
                auxResource.addAsset (new Asset (cb.getType (), cb.getPath ()));
                buttons.Add (ActionNameWrapper.IDs [cb.getAction ()], auxResource);
            }
        }

        //For each button that isn on descriptor file we try to find the default assets;
        Texture2D auxTexture;
        foreach (KeyValuePair<int,string> button in ActionNameWrapper.Names) {
            if (!buttons.ContainsKey (button.Key)) {
                if (DefaultActionAssetWrapper.Assets.ContainsKey (button.Key)) {
                    string selected = "";
                    foreach (string name in DefaultActionAssetWrapper.Assets[button.Key]) {
                        auxTexture = ResourceManager.Instance.getImage (GUIProvider.DEFAULT_ASSET_DIRECTORY + name + ".png");

                        if (auxTexture != null) {
                            selected = name;
                            break;
                        }
                    }

                    if (selected != "") {
                        auxResource = new ResourcesUni ();
                        auxResource.addAsset (DescriptorData.NORMAL_BUTTON, GUIProvider.DEFAULT_ASSET_DIRECTORY + selected + ".png");
                        auxResource.addAsset (DescriptorData.HIGHLIGHTED_BUTTON, GUIProvider.DEFAULT_ASSET_DIRECTORY + selected + "Highlighted.png");
                        auxResource.addAsset (DescriptorData.PRESSED_BUTTON, GUIProvider.DEFAULT_ASSET_DIRECTORY + selected + "Pressed.png");
                        buttons.Add (button.Key, auxResource);
                    }
                }
            }
        }

        if(data.getCursors().Count == 0)
            loadDefaultCursors ();
    }
Example #4
0
        public override bool addElement(int type, string bookId)
        {
            bool elementAdded = false;

            if (type == Controller.BOOK)
            {
                int bookType = -1;
                //TODO: tmp, delete this line
                bookType = 0;
                //TODO: implement
                //BookTypesDialog bookTypesDialog = new BookTypesDialog(Book.TYPE_PARAGRAPHS);
                //bookType = bookTypesDialog.getOptionSelected();

                if (bookType != -1)
                {
                    // Show a dialog asking for the book id
                    if (bookId == null || bookId.Equals(""))
                    {
                        bookId = controller.showInputDialog(TC.get("Operation.AddBookTitle"), TC.get("Operation.AddBookMessage"), TC.get("Operation.AddBookDefaultValue"));
                    }

                    // If some value was typed and the identifier is valid
                    if (!controller.isElementIdValid(bookId))
                    {
                        bookId = controller.makeElementValid(bookId);
                    }

                    // Add thew new book
                    Book newBook = new Book(bookId);
                    newBook.setType(bookType);

                    // Set default background
                    ResourcesUni resources = new ResourcesUni();
                    resources.addAsset("background", SpecialAssetPaths.ASSET_DEFAULT_BOOK_IMAGE);
                    resources.addAsset("arrowLeftNormal", SpecialAssetPaths.ASSET_DEFAULT_ARROW_NORMAL);
                    resources.addAsset("arrowLeftOver", SpecialAssetPaths.ASSET_DEFAULT_ARROW_OVER);
                    newBook.addResources(resources);

                    BookDataControl newDataControl = new BookDataControl(newBook);
                    booksList.Add(newBook);
                    booksDataControlList.Add(newDataControl);
                    controller.getIdentifierSummary().addBookId(bookId);
                    //controller.dataModified( );
                    elementAdded = true;
                }
            }

            return(elementAdded);
        }
Example #5
0
    protected static ResourcesUni createResources(ExitLook exitLook)
    {
        ResourcesUni resources = new ResourcesUni();

        resources.addAsset(CURSOR_STR, exitLook.getCursorPath());
        return(resources);
    }
    public override bool undoTool()
    {
        // Restores the resources object with the information stored in oldResoures
        //try
        //{
        ResourcesUni temp = resources;

        resources.clearAssets();
        string[] oldResourceTypes = oldResourcesUni.getAssetTypes();
        foreach (string type in oldResourceTypes)
        {
            resources.addAsset(type, oldResourcesUni.getAssetPath(type));
        }

        // Update older data
        oldResourcesUni.clearAssets();
        oldResourceTypes = temp.getAssetTypes();
        foreach (string type in oldResourceTypes)
        {
            oldResourcesUni.addAsset(type, temp.getAssetPath(type));
        }
        //			controller.reloadPanel();
        return(true);
        //}
        //catch (CloneNotSupportedException e)
        //{
        //    e.printStackTrace();
        //    return false;
        //}
    }
Example #7
0
        protected static ResourcesUni createResources(ConversationLine line)
        {
            ResourcesUni resources = new ResourcesUni();

            if (line.getAudioPath() != null)
            {
                resources.addAsset(AUDIO_STR, line.getAudioPath());
            }
            return(resources);
        }
Example #8
0
    protected static ResourcesUni createResources(HasSound objectWithSound)
    {
        ResourcesUni resources = new ResourcesUni();

        string soundPath = objectWithSound.getSoundPath();

        if (soundPath != null)
        {
            resources.addAsset(AUDIO_STR, soundPath);
        }
        return(resources);
    }
Example #9
0
        protected static ResourcesUni createResources(AdventureData adventureData, int t)
        {
            string       type       = DescriptorData.getCursorTypeString(t);
            ResourcesUni resources  = new ResourcesUni();
            bool         introduced = false;

            for (int i = 0; i < adventureData.getCursors().Count; i++)
            {
                if (adventureData.getCursors()[i].getType().Equals(type) && adventureData.getCursors()[i].getPath() != null)
                {
                    resources.addAsset(type, adventureData.getCursors()[i].getPath());
                    introduced = true;
                    break;
                }
            }

            if (!introduced)
            {
                resources.addAsset(type, null);
            }

            return(resources);
        }
Example #10
0
        protected static ResourcesUni createResources(AdventureData adventureData, string action, string type)
        {
            ResourcesUni resources  = new ResourcesUni();
            bool         introduced = false;

            for (int i = 0; i < adventureData.getButtons().Count; i++)
            {
                CustomButton customButton = adventureData.getButtons()[i];
                if (customButton.getType().Equals(type) && customButton.getAction().Equals(action))
                {
                    resources.addAsset(action + "#" + type, customButton.getPath());
                    introduced = true;
                    break;
                }
            }

            if (!introduced)
            {
                resources.addAsset(action + "#" + type, /*"NULL"*/ null);
            }

            return(resources);
        }
    protected static ResourcesUni createResources(AdventureData adventureData, string type)
    {
        ResourcesUni resources  = new ResourcesUni();
        bool         introduced = false;

        for (int i = 0; i < adventureData.getArrows().Count; i++)
        {
            CustomArrow customArrow = adventureData.getArrows()[i];
            if (customArrow.getType().Equals(type))
            {
                resources.addAsset(type, customArrow.getPath());
                introduced = true;
                break;
            }
        }

        if (!introduced)
        {
            resources.addAsset(type, null);
        }

        return(resources);
    }
        protected static ResourcesUni createResources(HasDescriptionSound descriptionSound, int type)
        {
            ResourcesUni resources = new ResourcesUni();

            string selectedName;

            switch ((HasDescriptionSoundEnum)type)
            {
            case HasDescriptionSoundEnum.NAME_PATH:
                selectedName = descriptionSound.getNameSoundPath();
                if (selectedName != null)
                {
                    resources.addAsset(AUDIO_STR, selectedName);
                }
                return(resources);

            case HasDescriptionSoundEnum.DESCRIPTION_PATH:
                selectedName = descriptionSound.getDescriptionSoundPath();
                if (selectedName != null)
                {
                    resources.addAsset(AUDIO_STR, selectedName);
                }
                return(resources);

            case HasDescriptionSoundEnum.DETAILED_DESCRIPTION_PATH:
                selectedName = descriptionSound.getDetailedDescriptionSoundPath();
                if (selectedName != null)
                {
                    resources.addAsset(AUDIO_STR, selectedName);
                }
                return(resources);

            default:
                return(resources);
            }
        }
    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 #14
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a object tag, create the new object (with its id)
            if (qName.Equals("atrezzoobject"))
            {
                string atrezzoId = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        atrezzoId = entry.Value.ToString();
                    }
                }

                atrezzo = new Atrezzo(atrezzoId);

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

            // If it is a resources tag, create the new resources and switch the state
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }

                reading = READING_RESOURCES;
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                // If the asset is not an special one
                //				if( !AssetsController.isAssetSpecial( path ) )
                currentResources.addAsset(type, path);
            }

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

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

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

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            //string id = this.atrezzo.getId( );
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
Example #15
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a player tag, create the player
            if (qName.Equals("player"))
            {
                player       = new Player();
                descriptions = new List <Description>();
                player.setDescriptions(descriptions);
            }

            // If it is a resources tag, create new resources
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }
            }

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

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                // If the asset is not an special one
                //if( !AssetsController.isAssetSpecial( path ) )
                currentResources.addAsset(type, path);
            }

            // If it is a frontcolor or bordercolor tag, pick the color
            else if (qName.Equals("frontcolor") || qName.Equals("bordercolor"))
            {
                string color = "";

                // Pick the color
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("color"))
                    {
                        color = entry.Value.ToString();
                    }
                }

                // Set the color in the player
                if (qName.Equals("frontcolor"))
                {
                    player.setTextFrontColor(color);
                }
                if (qName.Equals("bordercolor"))
                {
                    player.setTextBorderColor(color);
                }
            }

            else if (qName.Equals("textcolor"))
            {
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("showsSpeechBubble"))
                    {
                        player.setShowsSpeechBubbles(entry.Value.ToString().Equals("yes"));
                    }
                    if (entry.Key.Equals("bubbleBkgColor"))
                    {
                        player.setBubbleBkgColor(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("bubbleBorderColor"))
                    {
                        player.setBubbleBorderColor(entry.Value.ToString());
                    }
                }
            }

            // If it is a voice tag, take the voice and the always synthesizer option
            else if (qName.Equals("voice"))
            {
                string voice = string.Empty;
                string response;
                bool   alwaysSynthesizer = false;

                // Pick the voice and synthesizer option
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        voice = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("synthesizeAlways"))
                    {
                        response = entry.Value.ToString();
                        if (response.Equals("yes"))
                        {
                            alwaysSynthesizer = true;
                        }
                    }
                }
                player.setAlwaysSynthesizer(alwaysSynthesizer);
                player.setVoice(voice);
            }

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

        // If a condition is being subparsed, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    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 #17
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);
    }
 /**
  * This method change the assets path without using a tool for it. That is necessary when old animations are changed at LO generation
  */
 public void changeAssetPath(int index, string path)
 {
     resources.deleteAsset(assetsInformation[index].name);
     resources.addAsset(assetsInformation[index].name, path);
 }
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        if (qName.Equals("frame"))
        {
            foreach (KeyValuePair <string, string> entry in attrs)
            {
                if (entry.Key.Equals("uri"))
                {
                    frame.setUri(entry.Value.ToString());
                }
                if (entry.Key.Equals("type"))
                {
                    if (entry.Value.ToString().Equals("image"))
                    {
                        frame.setType(Frame.TYPE_IMAGE);
                    }
                    if (entry.Value.ToString().Equals("video"))
                    {
                        frame.setType(Frame.TYPE_VIDEO);
                    }
                }
                if (entry.Key.Equals("time"))
                {
                    frame.setTime(long.Parse(entry.Value.ToString()));
                }
                if (entry.Key.Equals("waitforclick"))
                {
                    frame.setWaitforclick(entry.Value.ToString().Equals("yes"));
                }
                if (entry.Key.Equals("soundUri"))
                {
                    frame.setSoundUri(entry.Value.ToString());
                }
                if (entry.Key.Equals("maxSoundTime"))
                {
                    frame.setMaxSoundTime(int.Parse(entry.Value.ToString()));
                }
            }
        }

        if (qName.Equals("resources"))
        {
            currentResources = new ResourcesUni();

            foreach (KeyValuePair <string, string> entry in attrs)
            {
                if (entry.Key.Equals("name"))
                {
                    currentResources.setName(entry.Value.ToString());
                }
            }
        }

        if (qName.Equals("asset"))
        {
            string type = "";
            string path = "";

            foreach (KeyValuePair <string, string> entry in attrs)
            {
                if (entry.Key.Equals("type"))
                {
                    type = entry.Value.ToString();
                }
                if (entry.Key.Equals("uri"))
                {
                    path = entry.Value.ToString();
                }
            }

            // If the asset is not an special one
            //if( !AssetsController.isAssetSpecial( path ) )
            currentResources.addAsset(type, path);
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            resourcess = element.SelectNodes("resources"),
            assets = element.SelectNodes("next-scene");

        string tmpArgVal;

        tmpArgVal = element.GetAttribute("uri");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setUri(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("type");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            if (tmpArgVal.Equals("image"))
                frame.setType(Frame.TYPE_IMAGE);
            if (tmpArgVal.Equals("video"))
                frame.setType(Frame.TYPE_VIDEO);
        }
        tmpArgVal = element.GetAttribute("time");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setTime(long.Parse(tmpArgVal));
        }
        tmpArgVal = element.GetAttribute("waitforclick");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setWaitforclick(tmpArgVal.Equals("yes"));
        }
        tmpArgVal = element.GetAttribute("soundUri");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setSoundUri(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("maxSoundTime");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setMaxSoundTime(int.Parse(tmpArgVal));
        }

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

        frame.addResources(currentResources);
    }
    public void Parse(string path_)
    {
        XmlDocument xmld = new XmlDocument();
        xmld.Load(path_);

        XmlElement element = xmld.DocumentElement;

        XmlNodeList
            frames = element.SelectNodes("/animation/frame"),
            transitions = element.SelectNodes("/animation/transition"),
            resources = element.SelectNodes("/animation/resources"),
            assets;

        string tmpArgVal;

        XmlNode animationNode = element.SelectSingleNode("/animation");

        tmpArgVal = animationNode.Attributes["id"].Value;
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            animation = new Animation(tmpArgVal, factory);
            animation.getFrames().Clear();
            animation.getTransitions().Clear();
        }

        tmpArgVal = animationNode.Attributes["slides"].Value;
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            if (tmpArgVal.Equals("yes"))
                animation.setSlides(true);
            else
                animation.setSlides(false);
        }

        tmpArgVal = animationNode.Attributes["usetransitions"].Value;
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            if (tmpArgVal.Equals("yes"))
                animation.setUseTransitions(true);
            else
                animation.setUseTransitions(false);
        }

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

        foreach (XmlElement el in frames)
        {
            new FrameSubParser_(animation).ParseElement(el);
        }
        foreach (XmlElement el in transitions)
        {
            new TransitionSubParser_(animation).ParseElement(el);
        }

        foreach (XmlElement el in resources)
        {
            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);
            }

            animation.addResources(currentResources);
        }
    }
    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,
            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 #24
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"),
            assets     = element.SelectNodes("next-scene");

        string tmpArgVal;

        tmpArgVal = element.GetAttribute("uri");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setUri(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("type");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            if (tmpArgVal.Equals("image"))
            {
                frame.setType(Frame.TYPE_IMAGE);
            }
            if (tmpArgVal.Equals("video"))
            {
                frame.setType(Frame.TYPE_VIDEO);
            }
        }
        tmpArgVal = element.GetAttribute("time");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setTime(long.Parse(tmpArgVal));
        }
        tmpArgVal = element.GetAttribute("waitforclick");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setWaitforclick(tmpArgVal.Equals("yes"));
        }
        tmpArgVal = element.GetAttribute("soundUri");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setSoundUri(tmpArgVal);
        }
        tmpArgVal = element.GetAttribute("maxSoundTime");
        if (!string.IsNullOrEmpty(tmpArgVal))
        {
            frame.setMaxSoundTime(int.Parse(tmpArgVal));
        }

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

        frame.addResources(currentResources);
    }
    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);
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.XmlAttribute)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is an examine, use or grab tag, create new conditions and effects
            if (qName.Equals("examine") || qName.Equals("grab") || qName.Equals("use") || qName.Equals("talk-to"))
            {
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("needsGoTo"))
                    {
                        currentNeedsGoTo = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("keepDistance"))
                    {
                        currentKeepDistance = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("not-effects"))
                    {
                        activateNotEffects = entry.Value.ToString().Equals("yes");
                    }
                }
                currentConditions    = new Conditions();
                currentEffects       = new Effects();
                currentNotEffects    = new Effects();
                currentClickEffects  = new Effects();
                currentDocumentation = null;
                reading = READING_ACTION;
            }

            // If it is an use-with or give-to tag, create new conditions and effects, and store the idTarget
            else if (qName.Equals("use-with") || qName.Equals("give-to") || qName.Equals("drag-to"))
            {
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("idTarget"))
                    {
                        currentIdTarget = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("needsGoTo"))
                    {
                        currentNeedsGoTo = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("keepDistance"))
                    {
                        currentKeepDistance = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("not-effects"))
                    {
                        activateNotEffects = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("click-effects"))
                    {
                        activateClickEffects = entry.Value.ToString().Equals("yes");
                    }
                }
                currentConditions    = new Conditions();
                currentEffects       = new Effects();
                currentNotEffects    = new Effects();
                currentClickEffects  = new Effects();
                currentDocumentation = null;
                reading = READING_ACTION;
            }

            else if (qName.Equals("custom") || qName.Equals("custom-interact"))
            {
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("idTarget"))
                    {
                        currentIdTarget = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("name"))
                    {
                        currentName = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("needsGoTo"))
                    {
                        currentNeedsGoTo = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("keepDistance"))
                    {
                        currentKeepDistance = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("not-effects"))
                    {
                        activateNotEffects = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("click-effects"))
                    {
                        activateClickEffects = entry.Value.ToString().Equals("yes");
                    }
                }

                currentConditions    = new Conditions();
                currentEffects       = new Effects();
                currentNotEffects    = new Effects();
                currentClickEffects  = new Effects();
                currentDocumentation = null;
                if (qName.Equals("custom"))
                {
                    currentCustomAction = new CustomAction(Action.CUSTOM);
                }
                else
                {
                    currentCustomAction = new CustomAction(Action.CUSTOM_INTERACT);
                }
                reading = READING_ACTION;
            }

            // If it is a resources tag, create the new resources and switch the state
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }

                reading = READING_RESOURCES;
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                // If the asset is not an special one
                //				if( !AssetsController.isAssetSpecial( path ) )
                currentResources.addAsset(type, path);
            }

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

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

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

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            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 #29
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"),
            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);
    }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        Debug.Log("START: " + sName + " " + qName + " sub:" + subParsing + ", reading: " + reading);
        // If no element is being parsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a scene tag, create a new scene with its id
            if (qName.Equals("scene"))
            {
                string sceneId      = "";
                bool   initialScene = false;
                int    playerLayer  = -1;
                float  playerScale  = 1.0f;

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        sceneId = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("start"))
                    {
                        initialScene = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("playerLayer"))
                    {
                        playerLayer = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("playerScale"))
                    {
                        playerScale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture);
                    }
                }

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

            // If it is a resources tag, create the new resources
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }

                reading = READING_RESOURCES;
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                currentResources.addAsset(type, path);
            }

            // If it is a default-initial-position tag, store it in the scene
            else if (qName.Equals("default-initial-position"))
            {
                int x = int.MinValue, y = int.MinValue;

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

                scene.setDefaultPosition(x, y);
            }

            // If it is an exit tag, create the new exit
            else if (qName.Equals("exit"))
            {
                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;

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

                    if (entry.Key.Equals("idTarget"))
                    {
                        idTarget = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("destinyX"))
                    {
                        destinyX = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("destinyY"))
                    {
                        destinyY = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("transitionType"))
                    {
                        transitionType = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("transitionTime"))
                    {
                        transitionTime = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("not-effects"))
                    {
                        notEffects = entry.Value.ToString().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);
                }
                reading = READING_EXIT;
            }

            else if (qName.Equals("exit-look"))
            {
                currentExitLook = new ExitLook();
                string text       = null;
                string cursorPath = null;
                string soundPath  = null;
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("text"))
                    {
                        text = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("cursor-path"))
                    {
                        cursorPath = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("sound-path"))
                    {
                        soundPath = entry.Value.ToString();
                    }
                }
                currentExitLook.setCursorPath(cursorPath);
                currentExitLook.setExitText(text);
                if (soundPath != null)
                {
                    currentExitLook.setSoundPath(soundPath);
                }
                //  Debug.Log("311" + currentExitLook.getExitText());
            }

            // If it is a next-scene tag, create the new next scene
            else if (qName.Equals("next-scene"))
            {
                string idTarget = "";
                int    x = int.MinValue, y = int.MinValue;
                int    transitionType = 0, transitionTime = 0;

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

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

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

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

                currentPoint = new Vector2(x, y);
            }

            // If it is a object-ref or character-ref, create the new element reference
            else if (qName.Equals("object-ref") || qName.Equals("character-ref") || qName.Equals("atrezzo-ref"))
            {
                Debug.Log("SceneReference Start");
                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;

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("idTarget"))
                    {
                        idTarget = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("x"))
                    {
                        x = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("y"))
                    {
                        y = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("scale"))
                    {
                        scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture);
                    }
                    if (entry.Key.Equals("layer"))
                    {
                        layer = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("hasInfluenceArea"))
                    {
                        hasInfluence = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("influenceX"))
                    {
                        influenceX = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("influenceY"))
                    {
                        influenceY = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("influenceWidth"))
                    {
                        influenceWidth = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("influenceHeight"))
                    {
                        influenceHeight = int.Parse(entry.Value.ToString());
                    }
                }

                // 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);
                }
                reading = READING_ELEMENT_REFERENCE;
            }

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

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

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

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

            // If it is a post-effect tag, create the new effect, the subparser and switch the state
            else if (qName.Equals("active-area"))
            {
                subParsing = SUBPARSING_ACTIVE_AREA;
                subParser  = new ActiveAreaSubParser(chapter, scene, scene.getActiveAreas().Count);
            }

            // If it is a post-effect tag, create the new effect, the subparser and switch the state
            else if (qName.Equals("barrier"))
            {
                subParsing = SUBPARSING_BARRIER;
                subParser  = new BarrierSubParser(chapter, scene, scene.getBarriers().Count);
            }

            else if (qName.Equals("trajectory"))
            {
                subParsing = SUBPARSING_TRAJECTORY;
                subParser  = new TrajectorySubParser(chapter, scene);
            }
        }

        // If it is subparsing an effect or condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
        /**
         * Contructor.
         *
         * @param resources
         *            Resources of the data control structure
         * @param resourcesType
         *            Type of the resources
         */
        public ResourcesDataControl(ResourcesUni resources, int resourcesType)
        {
            this.resources     = resources;
            this.resourcesType = resourcesType;

            // Initialize the assetsInformation, depending on the assets type
            switch (resourcesType)
            {
            case Controller.SCENE:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionSceneBackground", "background", true, AssetsConstants.CATEGORY_BACKGROUND, AssetsController.FILTER_JPG), new AssetInformation("Resources.DescriptionSceneForeground", "foreground", false, AssetsConstants.CATEGORY_BACKGROUND, AssetsController.FILTER_PNG), /*new AssetInformation( TextConstants.getText( "Resources.DescriptionSceneHardMap" ), "hardmap", false, AssetsController.CATEGORY_BACKGROUND, AssetsController.FILTER_PNG ), */ new AssetInformation("Resources.DescriptionSceneMusic", "bgmusic", false, AssetsConstants.CATEGORY_AUDIO, AssetsController.FILTER_NONE) };

                if (!resources.existAsset("background"))
                {
                    resources.addAsset("background", SpecialAssetPaths.ASSET_EMPTY_BACKGROUND);
                }
                break;

            case Controller.CUTSCENE_SLIDES:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionSlidesceneSlides", "slides", true, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_JPG), new AssetInformation("Resources.DescriptionSceneMusic", "bgmusic", false, AssetsConstants.CATEGORY_AUDIO, AssetsController.FILTER_NONE) };

                if (!resources.existAsset("slides"))
                {
                    resources.addAsset("slides", SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                }
                break;

            case Controller.ACTION_CUSTOM:
            case Controller.ACTION_CUSTOM_INTERACT:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionButtonNormal", "buttonNormal", true, AssetsConstants.CATEGORY_BUTTON, AssetsController.FILTER_PNG), new AssetInformation("Resources.DescriptionButtonOver", "buttonOver", true, AssetsConstants.CATEGORY_BUTTON, AssetsController.FILTER_PNG), new AssetInformation("Resources.DescriptionButtonSound", "buttonSound", false, AssetsConstants.CATEGORY_AUDIO, AssetsController.FILTER_NONE) /*, new AssetInformation( "Resources.DescriptionButtonPressed" , "buttonPressed", true, AssetsConstants.CATEGORY_BUTTON, AssetsController.FILTER_PNG )*/, new AssetInformation("Resources.DescriptionActionAnimation", "actionAnimation", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_NONE), new AssetInformation("Resources.DescriptionActionAnimationLeft", "actionAnimationLeft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_NONE) };
                assetsGroups      = new int[][] { new int[] { 0, 1, 2 }, new int[] { 3, 4 } };
                groupsInfo        = new string[] { "Resources.Button", "Resources.Animations" };

                // For each asset, if it has not been declared attach the empty animation
                string[] assets = new string[] { "buttonNormal", "buttonOver", "buttonPressed" };
                foreach (string asset in assets)
                {
                    if (!resources.existAsset(asset))
                    {
                        resources.addAsset(asset, SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                    }
                }

                break;

            case Controller.CUTSCENE_VIDEO:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionVideoscenes", "video", true, AssetsConstants.CATEGORY_VIDEO, AssetsController.FILTER_NONE) };
                break;

            case Controller.BOOK:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionBookBackground", "background", true, AssetsConstants.CATEGORY_BACKGROUND, AssetsController.FILTER_JPG),
                                                             new AssetInformation("Resources.ArrowLeftNormal", "arrowLeftNormal", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.ArrowRightNormal", "arrowRightNormal", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.ArrowLeftOver", "arrowLeftOver", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.ArrowRightOver", "arrowRightOver", false, AssetsConstants.CATEGORY_ARROW_BOOK, AssetsController.FILTER_PNG) };

                if (!resources.existAsset("background"))
                {
                    resources.addAsset("background", SpecialAssetPaths.ASSET_EMPTY_BACKGROUND);
                }
                break;

            case Controller.ITEM:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionItemImage", "image", true, AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE), new AssetInformation("Resources.DescriptionItemIcon", "icon", false, AssetsConstants.CATEGORY_ICON, AssetsController.FILTER_NONE)
                                                             , new AssetInformation("Resources.DescriptionItemImageOver", "imageover", false, AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE) };
                imageIconMap = new Dictionary <string, string>();
                imageIconMap.Add("icon", "image");
                if (!resources.existAsset("image"))
                {
                    resources.addAsset("image", SpecialAssetPaths.ASSET_EMPTY_IMAGE);
                }
                if (!resources.existAsset("icon"))
                {
                    resources.addAsset("icon", SpecialAssetPaths.ASSET_EMPTY_ICON);
                }
                break;

            case Controller.PLAYER:
            case Controller.NPC:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionCharacterAnimationStandUp", "standup", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationStandDown", "standdown", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             //check if is 3rd or 1st person game to set the asset as necessary
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationStandRight", "standright", Controller.Instance.PlayTransparent?false:true, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationStandLeft", "standleft", Controller.Instance.PlayTransparent?false:true, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),

                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakUp", "speakup", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakDown", "speakdown", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakRight", "speakright", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationSpeakLeft", "speakleft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationUseRight", "useright", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationUseLeft", "useleft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkUp", "walkup", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkDown", "walkdown", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkRight", "walkright", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG),
                                                             new AssetInformation("Resources.DescriptionCharacterAnimationWalkLeft", "walkleft", false, AssetsConstants.CATEGORY_ANIMATION, AssetsController.FILTER_PNG) };
                assetsGroups = new int[][] { new int[] { 0, 1, 2, 3 }, new int[] { 4, 5, 6, 7 }, new int[] { 8, 9 }, new int[] { 10, 11, 12, 13 } };
                groupsInfo   = new string[] { "Resources.StandingAnimations", "Resources.SpeakingAnimations", "Resources.UsingAnimations", "Resources.WalkingAnimations" };

                foreach (string asset in new string[]
                {
                    "standup", "standdown", "standright", "standleft", "speakup", "speakdown", "speakright", "speakleft",
                    "useright", "useleft", "walkup", "walkdown", "walkright", "walkleft"
                })
                {
                    if (!resources.existAsset(asset))
                    {
                        resources.addAsset(asset, SpecialAssetPaths.ASSET_EMPTY_ANIMATION);
                    }
                }

                break;

            case Controller.ATREZZO:
                assetsInformation = new AssetInformation[] { new AssetInformation("Resources.DescriptionItemImage", "image", true, AssetsConstants.CATEGORY_IMAGE, AssetsController.FILTER_NONE) };
                if (!resources.existAsset("image"))
                {
                    resources.addAsset("image", SpecialAssetPaths.ASSET_EMPTY_IMAGE);
                }
                break;
            }

            // Create subcontrollers
            conditionsController = new ConditionsController(resources.getConditions(), Controller.RESOURCES, "");
        }
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a slidescene tag, create a new slidescene with its id
            if (qName.Equals("slidescene") || qName.Equals("videoscene"))
            {
                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;

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        slidesceneId = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("start"))
                    {
                        initialScene = entry.Value.ToString().Equals("yes");
                    }
                    if (entry.Key.Equals("idTarget"))
                    {
                        idTarget = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("destinyX"))
                    {
                        x = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("destinyY"))
                    {
                        y = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("transitionType"))
                    {
                        transitionType = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("transitionTime"))
                    {
                        transitionTime = int.Parse(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("next"))
                    {
                        next = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("canSkip"))
                    {
                        canSkip = entry.Value.ToString().Equals("yes");
                    }
                }

                if (qName.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 (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);
                }
            }

            // If it is a resources tag, create new resources
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }

                reading = READING_RESOURCES;
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                currentResources.addAsset(type, path);
            }

            // If it is an end-game tag, store it in the slidescene
            else if (qName.Equals("end-game"))
            {
                cutscene.setNext(Cutscene.ENDCHAPTER);
            }

            // If it is a next-scene tag, create the new next scene
            else if (qName.Equals("next-scene"))
            {
                string idTarget = "";
                int    x = int.MinValue, y = int.MinValue;
                int    transitionType = 0, transitionTime = 0;

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

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

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

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

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

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    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 #35
0
    /*
     * (non-Javadoc)
     *
     * @see es.eucm.eadventure.engine.loader.subparsers.SubParser#startElement(java.lang.string, java.lang.string,
     *      java.lang.string, org.xml.sax.Attributes)
     */
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a character tag, store the id of the character
            if (qName.Equals("character"))
            {
                string characterId = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        characterId = entry.Value.ToString();
                    }
                }

                npc = new NPC(characterId);

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

            // If it is a resources tag, create the new resources, and switch the element being parsed
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }

                reading = READING_RESOURCES;
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                // If the asset is not an special one
                //if( !AssetsController.isAssetSpecial( path ) )
                currentResources.addAsset(type, path);
            }

            // If it is a frontcolor or bordercolor tag, pick the color
            else if (qName.Equals("frontcolor") || qName.Equals("bordercolor"))
            {
                string color = "";

                // Pick the color
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("color"))
                    {
                        color = entry.Value.ToString();
                    }
                }

                // Set the color in the npc
                if (qName.Equals("frontcolor"))
                {
                    npc.setTextFrontColor(color);
                }
                if (qName.Equals("bordercolor"))
                {
                    npc.setTextBorderColor(color);
                }
            }

            else if (qName.Equals("textcolor"))
            {
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("showsSpeechBubble"))
                    {
                        npc.setShowsSpeechBubbles(entry.Value.ToString().Equals("yes"));
                    }
                    if (entry.Key.Equals("bubbleBkgColor"))
                    {
                        npc.setBubbleBkgColor(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("bubbleBorderColor"))
                    {
                        npc.setBubbleBorderColor(entry.Value.ToString());
                    }
                }
            }

            // If it is a conversation reference tag, store the destination id, and switch the element being parsed
            else if (qName.Equals("conversation-ref"))
            {
                string idTarget = "";

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

                conversationReference = new ConversationReference(idTarget);
                reading = READING_CONVERSATION_REFERENCE;
            }

            // If it is a condition tag, create a new subparser
            else if (qName.Equals("condition"))
            {
                currentConditions = new Conditions();
                subParser         = new ConditionSubParser(currentConditions, chapter);
                subParsing        = SUBPARSING_CONDITION;
            }
            // If it is a voice tag, take the voice and the always synthesizer option
            else if (qName.Equals("voice"))
            {
                string voice = "";
                string response;
                bool   alwaysSynthesizer = false;

                // Pick the voice and synthesizer option
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        voice = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("synthesizeAlways"))
                    {
                        response = entry.Value.ToString();
                        if (response.Equals("yes"))
                        {
                            alwaysSynthesizer = true;
                        }
                    }
                }
                npc.setAlwaysSynthesizer(alwaysSynthesizer);
                npc.setVoice(voice);
            }

            else if (qName.Equals("actions"))
            {
                subParser  = new ActionsSubParser(chapter, npc);
                subParsing = SUBPARSING_ACTIONS;
            }

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

        // If a condition or action is being subparsed, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
Example #36
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 #37
0
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        // If no element is being subparsed
        // Debug.Log(namespaceURI + " " + sName + " " + qName + "\nAttrs:\n" + CollectionPrinter.PrintCollection(attrs));
        if (subParsing == SUBPARSING_NONE)
        {
            // If it is a object tag, create the new parsedObject (with its id)
            if (qName.Equals("object"))
            {
                string parsedObjectId     = "";
                bool   returnsWhenDragged = true;

                //Two lines added:v1.4
                Item.BehaviourType behaviour = Item.BehaviourType.NORMAL;
                long resourceTransition      = 0;

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        parsedObjectId = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("returnsWhenDragged"))
                    {
                        returnsWhenDragged = (entry.Value.ToString().Equals("yes") ? true : false);
                    }
                    if (entry.Key.Equals("behaviour"))
                    {
                        if (entry.Value.ToString().Equals("normal"))
                        {
                            behaviour = Item.BehaviourType.NORMAL;
                        }
                        else if (entry.Value.ToString().Equals("atrezzo"))
                        {
                            behaviour = Item.BehaviourType.ATREZZO;
                        }
                        else if (entry.Value.ToString().Equals("first-action"))
                        {
                            behaviour = Item.BehaviourType.FIRST_ACTION;
                        }
                    }
                    if (entry.Key.Equals("resources-transition-time"))
                    {
                        resourceTransition = long.Parse(entry.Value.ToString());
                    }
                }

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

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

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

            // If it is a resources tag, create the new resources and switch the state
            else if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }

                reading = READING_RESOURCES;

                //Debug.Log("RESOURCES, PARSUJE: " + parsedObject);
            }

            // If it is an asset tag, read it and add it to the current resources
            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                // If the asset is not an special one
                //				if( !AssetsController.isAssetSpecial( path ) )
                currentResources.addAsset(type, path);
            }

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


            else if (qName.Equals("actions"))
            {
                subParser  = new ActionsSubParser(chapter, parsedObject);
                subParsing = SUBPARSING_ACTIONS;
            }

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

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

        // If it is reading an effect or a condition, spread the call
        if (subParsing != SUBPARSING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    public override void ParseElement(XmlElement element)
    {
        XmlNodeList
            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 startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs)
    {
        if (this.reading == READING_NONE)
        {
            if (qName.Equals("animation"))
            {
                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                    {
                        animation = new Animation(entry.Value.ToString(), factory);
                        animation.getFrames().Clear();
                        animation.getTransitions().Clear();
                    }

                    if (entry.Key.Equals("slides"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                        {
                            animation.setSlides(true);
                        }
                        else
                        {
                            animation.setSlides(false);
                        }
                    }

                    if (entry.Key.Equals("usetransitions"))
                    {
                        if (entry.Value.ToString().Equals("yes"))
                        {
                            animation.setUseTransitions(true);
                        }
                        else
                        {
                            animation.setUseTransitions(false);
                        }
                    }
                }
            }

            if (qName.Equals("documentation"))
            {
                currentstring = string.Empty;
            }

            if (qName.Equals("resources"))
            {
                currentResources = new ResourcesUni();

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("name"))
                    {
                        currentResources.setName(entry.Value.ToString());
                    }
                }
            }

            else if (qName.Equals("asset"))
            {
                string type = "";
                string path = "";

                foreach (KeyValuePair <string, string> entry in attrs)
                {
                    if (entry.Key.Equals("type"))
                    {
                        type = entry.Value.ToString();
                    }
                    if (entry.Key.Equals("uri"))
                    {
                        path = entry.Value.ToString();
                    }
                }

                currentResources.addAsset(type, path);
            }

            if (qName.Equals("frame"))
            {
                subParser = new FrameSubParser(animation);
                reading   = READING_FRAME;
            }

            if (qName.Equals("transition"))
            {
                subParser = new TransitionSubParser(animation);
                reading   = READING_TRANSITION;
            }
        }
        if (reading != READING_NONE)
        {
            subParser.startElement(namespaceURI, sName, qName, attrs);
        }
    }
    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);
    }