Ejemplo n.º 1
0
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            string time        = element.GetAttribute("time");
            string displayName = ExString.Default(element.GetAttribute("displayName"), "timer");

            bool usesEndCondition = ExString.EqualsDefault(element.GetAttribute("usesEndCondition"), "yes", true);
            bool runsInLoop       = ExString.EqualsDefault(element.GetAttribute("runsInLoop"), "yes", true);
            bool multipleStarts   = ExString.EqualsDefault(element.GetAttribute("multipleStarts"), "yes", true);
            bool showTime         = ExString.EqualsDefault(element.GetAttribute("showTime"), "yes", false);
            bool countDown        = ExString.EqualsDefault(element.GetAttribute("countDown"), "yes", false);
            bool showWhenStopped  = ExString.EqualsDefault(element.GetAttribute("showWhenStopped"), "yes", false);

            Timer timer = new Timer(long.Parse(time));

            timer.setRunsInLoop(runsInLoop);
            timer.setUsesEndCondition(usesEndCondition);
            timer.setMultipleStarts(multipleStarts);
            timer.setShowTime(showTime);
            timer.setDisplayName(displayName);
            timer.setCountDown(countDown);
            timer.setShowWhenStopped(showWhenStopped);

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

            timer.setInitCond(DOMParserUtility.DOMParse <Conditions>(element.SelectSingleNode("init-condition"), parameters) ?? new Conditions());
            timer.setEndCond(DOMParserUtility.DOMParse <Conditions>(element.SelectSingleNode("end-condition"), parameters) ?? new Conditions());
            timer.setEffects(DOMParserUtility.DOMParse <Effects>(element.SelectSingleNode("effect"), parameters) ?? new Effects());
            timer.setPostEffects(DOMParserUtility.DOMParse <Effects>(element.SelectSingleNode("post-effect"), parameters) ?? new Effects());

            return(timer);
        }
Ejemplo n.º 2
0
        protected override AdventureData ParseXml(XmlDocument doc)
        {
            XmlElement element     = doc.DocumentElement,
                       descriptor  = (XmlElement)element.SelectSingleNode("/game-descriptor"),
                       title       = (XmlElement)descriptor.SelectSingleNode("title"),
                       description = (XmlElement)descriptor.SelectSingleNode("description");

            // Basic attributes
            content.setVersionNumber(ExString.Default(descriptor.GetAttribute("versionNumber"), "0"));
            content.setTitle(title.InnerText ?? "");
            content.setDescription(description.InnerText ?? "");

            // Sub nodes
            XmlElement configuration    = (XmlElement)descriptor.SelectSingleNode("configuration"),
                       contents         = (XmlElement)descriptor.SelectSingleNode("contents"),
                       extensionObjects = (XmlElement)descriptor.SelectSingleNode("extension-objects");

            ParseConfiguration(content, configuration, incidences);
            ParseContents(content, contents, resourceManager, incidences);

            if (extensionObjects != null)
            {
                foreach (var el in extensionObjects.ChildNodes)
                {
                    object parsed = DOMParserUtility.DOMParse(el as XmlElement);
                    if (parsed != null)
                    {
                        var t = GroupableTypeAttribute.GetGroupType(parsed.GetType());
                        content.getObjects(t).Add(parsed);
                    }
                }
            }

            return(base.content);
        }
        private static void ParseConfiguration(AdventureData adventureData, XmlElement configuration, List<Incidence> incidences)
        {
            if (configuration == null)
            {
                return;
            }

            // Keep showing text until user clicks
            var isKeepShowing = ExString.EqualsDefault(configuration.GetAttribute("keepShowing"), "yes", false);
            adventureData.setKeepShowing(isKeepShowing);

            // Use keys to navigate in the scene
            var isKeyboardNavigation = ExString.EqualsDefault(configuration.GetAttribute("keyboard-navigation"), "enabled", false);
            adventureData.setKeyboardNavigation(isKeyboardNavigation);

            // Default click action for scene elements
            var defaultClickAction = ExString.Default(configuration.GetAttribute("defaultClickAction"), "showDetails");
            switch (defaultClickAction)
            {
                case "showDetails": adventureData.setDeafultClickAction(DescriptorData.DefaultClickAction.SHOW_DETAILS); break;
                case "showActions": adventureData.setDeafultClickAction(DescriptorData.DefaultClickAction.SHOW_ACTIONS); break;
                default: incidences.Add(Incidence.createDescriptorIncidence("Unknown defaultClickAction type: " + defaultClickAction, null)); break;
            }

            // Perspective for rendering
            var perspective = ExString.Default(configuration.GetAttribute("perspective"), "regular");
            switch (perspective)
            {
                case "regular": adventureData.setPerspective(DescriptorData.Perspective.REGULAR); break;
                case "isometric": adventureData.setPerspective(DescriptorData.Perspective.ISOMETRIC); break;
                default: incidences.Add(Incidence.createDescriptorIncidence("Unknown perspective type: " + perspective, null)); break;
            }

            // Drag behaviour configuration
            var dragBehaviour = ExString.Default(configuration.GetAttribute("dragBehaviour"), "considerNonTargets");
            switch (dragBehaviour)
            {
                case "considerNonTargets": adventureData.setDragBehaviour(DescriptorData.DragBehaviour.CONSIDER_NON_TARGETS); break;
                case "ignoreNonTargets": adventureData.setDragBehaviour(DescriptorData.DragBehaviour.IGNORE_NON_TARGETS); break;
                default: incidences.Add(Incidence.createDescriptorIncidence("Unknown dragBehaviour type: " + dragBehaviour, null)); break;
            }

            // Auto Save
            var isAutoSave = ExString.EqualsDefault(configuration.GetAttribute("autosave"), "yes", true);
            adventureData.setAutoSave(isAutoSave);

            // Save on suspend
            var isSaveOnSuspend = ExString.EqualsDefault(configuration.GetAttribute("save-on-suspend"), "yes", true);
            adventureData.setSaveOnSuspend(isSaveOnSuspend);

            // Sub nodes
            XmlElement gui          = (XmlElement)configuration.SelectSingleNode("gui"),
                mode                = (XmlElement)configuration.SelectSingleNode("mode"),
                graphics            = (XmlElement)configuration.SelectSingleNode("graphics");

            ParseGui(adventureData, gui, incidences);
            ParseMode(adventureData, mode);
            ParseGraphics(adventureData, graphics, incidences);
        }
        private static void ParseGui(AdventureData adventureData, XmlElement gui, List<Incidence> incidences)
        {
            if (gui == null)
            {
                return;
            }

            var guiType = ExString.Default(gui.GetAttribute("type"), "contextual");
            switch (guiType)
            {
                case "traditional": adventureData.setGUIType(DescriptorData.GUI_TRADITIONAL); break;
                case "contextual":  adventureData.setGUIType(DescriptorData.GUI_CONTEXTUAL);  break;
                default: incidences.Add(Incidence.createDescriptorIncidence("Unknown GUIType type: " + guiType, null)); break;
            }
            
            var isCustomized = ExString.EqualsDefault(gui.GetAttribute("customized"), "yes", false);
            adventureData.setGUI(adventureData.getGUIType(), isCustomized);

            var inventoryPosition = ExString.Default(gui.GetAttribute("inventoryPosition"), "top_bottom");
            switch (inventoryPosition)
            {
                case "none": adventureData.setInventoryPosition(DescriptorData.INVENTORY_NONE); break;
                case "top_bottom": adventureData.setInventoryPosition(DescriptorData.INVENTORY_TOP_BOTTOM); break;
                case "top": adventureData.setInventoryPosition(DescriptorData.INVENTORY_TOP); break;
                case "bottom": adventureData.setInventoryPosition(DescriptorData.INVENTORY_BOTTOM); break;
                case "fixed_top": adventureData.setInventoryPosition(DescriptorData.INVENTORY_FIXED_TOP); break;
                case "fixed_bottom": adventureData.setInventoryPosition(DescriptorData.INVENTORY_FIXED_BOTTOM); break;
                default: incidences.Add(Incidence.createDescriptorIncidence("Unknown inventoryPosition type: " + inventoryPosition, null)); break;
            }

            XmlNodeList cursors = gui.SelectNodes("cursors/cursor");
            foreach (XmlElement cursor in cursors)
            {
                string type = ExString.Default(cursor.GetAttribute("type"), ""),
                    uri     = ExString.Default(cursor.GetAttribute("uri"), "");

                adventureData.addCursor(type, uri);
            }

            XmlNodeList buttons = gui.SelectNodes("buttons/button");
            foreach (XmlElement button in buttons)
            {
                string type = ExString.Default(button.GetAttribute("type"), ""),
                    uri     = ExString.Default(button.GetAttribute("uri"), ""),
                    action  = ExString.Default(button.GetAttribute("action"), "");

                adventureData.addButton(action, type, uri);
            }

            XmlNodeList arrows = gui.SelectNodes("cursors/cursor");
            foreach (XmlElement arrow in arrows)
            {
                string type = ExString.Default(arrow.GetAttribute("type"), ""),
                    uri     = ExString.Default(arrow.GetAttribute("uri"), "");

                adventureData.addArrow(type, uri);
            }
        }
        private static void ParseGraphics(AdventureData adventureData, XmlElement graphics, List<Incidence> incidences)
        {
            if (graphics == null)
            {
                return;
            }

            var graphicsMode = ExString.Default(graphics.GetAttribute("mode"), "fullscreen");
            switch (graphicsMode)
            {
                case "windowed": adventureData.setGraphicConfig(DescriptorData.GRAPHICS_WINDOWED); break;
                case "fullscreen": adventureData.setGraphicConfig(DescriptorData.GRAPHICS_FULLSCREEN); break;
                case "blackbkg": adventureData.setGraphicConfig(DescriptorData.GRAPHICS_BLACKBKG); break;
                default: incidences.Add(Incidence.createDescriptorIncidence("Unknown graphicsMode type: " + graphicsMode, null)); break;
            }
        }
Ejemplo n.º 6
0
        protected override AdventureData ParseXml(XmlDocument doc)
        {
            XmlElement element     = doc.DocumentElement,
                       descriptor  = (XmlElement)element.SelectSingleNode("/game-descriptor"),
                       title       = (XmlElement)descriptor.SelectSingleNode("title"),
                       description = (XmlElement)descriptor.SelectSingleNode("description");

            // Basic attributes
            content.setVersionNumber(ExString.Default(descriptor.GetAttribute("versionNumber"), "0"));
            content.setTitle(title.InnerText ?? "");
            content.setDescription(description.InnerText ?? "");

            // Sub nodes
            XmlElement configuration = (XmlElement)descriptor.SelectSingleNode("configuration"),
                       contents      = (XmlElement)descriptor.SelectSingleNode("contents");

            ParseConfiguration(content, configuration, incidences);
            ParseContents(content, contents, resourceManager, incidences);

            return(base.content);
        }
        private static void ParseGui(AdventureData adventureData, XmlElement gui, List <Incidence> incidences)
        {
            if (gui == null)
            {
                return;
            }

            var guiType = ExString.Default(gui.GetAttribute("type"), "contextual");

            switch (guiType)
            {
            case "traditional": adventureData.setGUIType(DescriptorData.GUI_TRADITIONAL); break;

            case "contextual":  adventureData.setGUIType(DescriptorData.GUI_CONTEXTUAL);  break;

            default: incidences.Add(Incidence.createDescriptorIncidence("Unknown GUIType type: " + guiType, null)); break;
            }

            var isCustomized = ExString.EqualsDefault(gui.GetAttribute("customized"), "yes", false);

            adventureData.setGUI(adventureData.getGUIType(), isCustomized);

            var inventoryPosition = ExString.Default(gui.GetAttribute("inventoryPosition"), "top_bottom");

            switch (inventoryPosition)
            {
            case "none": adventureData.setInventoryPosition(DescriptorData.INVENTORY_NONE); break;

            case "top_bottom": adventureData.setInventoryPosition(DescriptorData.INVENTORY_TOP_BOTTOM); break;

            case "top": adventureData.setInventoryPosition(DescriptorData.INVENTORY_TOP); break;

            case "bottom": adventureData.setInventoryPosition(DescriptorData.INVENTORY_BOTTOM); break;

            case "fixed_top": adventureData.setInventoryPosition(DescriptorData.INVENTORY_FIXED_TOP); break;

            case "fixed_bottom": adventureData.setInventoryPosition(DescriptorData.INVENTORY_FIXED_BOTTOM); break;

            case "icon":
                adventureData.setInventoryPosition(DescriptorData.INVENTORY_ICON_FREEPOS);
                var scale = gui.GetAttribute("inventoryScale");
                adventureData.setInventoryScale(ExParsers.ParseDefault(gui.GetAttribute("inventoryScale"), CultureInfo.InvariantCulture, 0.2f));
                var xCoord = ExParsers.ParseDefault(gui.GetAttribute("inventoryX"), CultureInfo.InvariantCulture, 675f);
                var yCoord = ExParsers.ParseDefault(gui.GetAttribute("inventoryY"), CultureInfo.InvariantCulture, 550f);
                adventureData.setInventoryCoords(new UnityEngine.Vector2(xCoord, yCoord));
                adventureData.setInventoryImage(ExString.Default(gui.GetAttribute("inventoryImage"), SpecialAssetPaths.ASSET_DEFAULT_INVENTORY));
                break;

            default: incidences.Add(Incidence.createDescriptorIncidence("Unknown inventoryPosition type: " + inventoryPosition, null)); break;
            }

            XmlNodeList cursors = gui.SelectNodes("cursors/cursor");

            foreach (XmlElement cursor in cursors)
            {
                string type         = ExString.Default(cursor.GetAttribute("type"), ""),
                                uri = ExString.Default(cursor.GetAttribute("uri"), "");

                adventureData.addCursor(type, uri);
            }

            XmlNodeList buttons = gui.SelectNodes("buttons/button");

            foreach (XmlElement button in buttons)
            {
                string type            = ExString.Default(button.GetAttribute("type"), ""),
                                uri    = ExString.Default(button.GetAttribute("uri"), ""),
                                action = ExString.Default(button.GetAttribute("action"), "");

                adventureData.addButton(action, type, uri);
            }

            XmlNodeList arrows = gui.SelectNodes("cursors/cursor");

            foreach (XmlElement arrow in arrows)
            {
                string type         = ExString.Default(arrow.GetAttribute("type"), ""),
                                uri = ExString.Default(arrow.GetAttribute("uri"), "");

                adventureData.addArrow(type, uri);
            }
        }
Ejemplo n.º 8
0
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            XmlNodeList points       = element.SelectNodes("point"),
                        descriptions = element.SelectNodes("description");
            XmlElement conditions    = element.SelectSingleNode("condition") as XmlElement,
                       actions       = element.SelectSingleNode("actions") as XmlElement,
                       documentation = element.SelectSingleNode("documentation") as XmlElement;

            string id          = ExString.Default(element.GetAttribute("id"), null);
            bool   rectangular = ExString.EqualsDefault(element.GetAttribute("rectangular"), "yes", true);

            int x      = ExParsers.ParseDefault(element.GetAttribute("x"), 0),
                y      = ExParsers.ParseDefault(element.GetAttribute("y"), 0),
                width  = ExParsers.ParseDefault(element.GetAttribute("width"), 0),
                height = ExParsers.ParseDefault(element.GetAttribute("height"), 0);

            bool hasInfluence    = ExString.EqualsDefault(element.GetAttribute("hasInfluenceArea"), "yes", false);
            int  influenceX      = ExParsers.ParseDefault(element.GetAttribute("influenceX"), 0),
                 influenceY      = ExParsers.ParseDefault(element.GetAttribute("influenceY"), 0),
                 influenceWidth  = ExParsers.ParseDefault(element.GetAttribute("influenceWidth"), 0),
                 influenceHeight = ExParsers.ParseDefault(element.GetAttribute("influenceHeight"), 0);


            var activeArea = new ActiveArea((id ?? generateId()), rectangular, x, y, width, height);

            switch (element.GetAttribute("behaviour"))
            {
            case "atrezzo":      activeArea.setBehaviour(Item.BehaviourType.ATREZZO);      break;

            case "first-action": activeArea.setBehaviour(Item.BehaviourType.FIRST_ACTION); break;

            default:             activeArea.setBehaviour(Item.BehaviourType.NORMAL);       break;
            }

            if (hasInfluence)
            {
                var influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                activeArea.setInfluenceArea(influenceArea);
            }

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

            activeArea.setDescriptions(DOMParserUtility.DOMParse <Description> (descriptions, parameters).ToList());

            foreach (XmlElement el in points)
            {
                activeArea.addVector2(
                    new Vector2(ExParsers.ParseDefault(el.GetAttribute("x"), 0),
                                ExParsers.ParseDefault(el.GetAttribute("y"), 0)));
            }

            if (actions != null)
            {
                activeArea.setActions(DOMParserUtility.DOMParse <Action>(actions.ChildNodes, parameters).ToList());
            }
            if (conditions != null)
            {
                activeArea.setConditions(DOMParserUtility.DOMParse(conditions, parameters) as Conditions ?? new Conditions());
            }

            return(activeArea);
        }
Ejemplo n.º 9
0
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            var chapter = parameters [0] as Chapter;

            string sceneId          = element.GetAttribute("id");
            bool   initialScene     = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false);
            bool   hideInventory    = ExString.EqualsDefault(element.GetAttribute("hideInventory"), "yes", false);
            bool   allowsSavingGame = ExString.EqualsDefault(element.GetAttribute("allowsSavingGame"), "yes", true);
            int    playerLayer      = ExParsers.ParseDefault(element.GetAttribute("playerLayer"), -1);
            float  playerScale      = ExParsers.ParseDefault(element.GetAttribute("playerScale"), CultureInfo.InvariantCulture, 1.0f);

            playerScale = Mathf.Max(0, playerScale);

            scene = new Scene(sceneId)
            {
                HideInventory = hideInventory
            };
            scene.setPlayerLayer(playerLayer);
            scene.setPlayerScale(playerScale);
            scene.setAllowsSavingGame(allowsSavingGame);

            if (initialScene)
            {
                chapter.setTargetId(sceneId);
            }

            var name = element.SelectSingleNode("name");

            if (name != null)
            {
                scene.setName(name.InnerText);
            }

            var documentation = element.SelectSingleNode("documentation");

            if (documentation != null)
            {
                scene.setDocumentation(documentation.InnerText);
            }

            //XAPI ELEMENTS
            scene.setXApiClass(ExString.Default(element.GetAttribute("class"), "accesible"));
            scene.setXApiType(ExString.Default(element.GetAttribute("type"), "area"));
            //END OF XAPI

            foreach (var res in DOMParserUtility.DOMParse <ResourcesUni> (element.SelectNodes("resources"), parameters))
            {
                scene.addResources(res);
            }

            var defaultsinitialsposition = element.SelectSingleNode("default-initial-position") as XmlElement;

            if (defaultsinitialsposition != null)
            {
                int x = ExParsers.ParseDefault(defaultsinitialsposition.GetAttribute("x"), int.MinValue),
                    y = ExParsers.ParseDefault(defaultsinitialsposition.GetAttribute("y"), int.MinValue);

                scene.setDefaultPosition(x, y);
            }

            foreach (XmlElement el in  element.SelectNodes("exits/exit"))
            {
                int x                  = ExParsers.ParseDefault(el.GetAttribute("x"), 0),
                                y      = ExParsers.ParseDefault(el.GetAttribute("y"), 0),
                                width  = ExParsers.ParseDefault(el.GetAttribute("width"), 0),
                                height = ExParsers.ParseDefault(el.GetAttribute("height"), 0);

                bool rectangular  = ExString.EqualsDefault(el.GetAttribute("rectangular"), "yes", true);
                bool hasInfluence = ExString.EqualsDefault(el.GetAttribute("hasInfluenceArea"), "yes", false);

                int influenceX      = ExParsers.ParseDefault(el.GetAttribute("influenceX"), 0),
                    influenceY      = ExParsers.ParseDefault(el.GetAttribute("influenceY"), 0),
                    influenceWidth  = ExParsers.ParseDefault(el.GetAttribute("influenceWidth"), 0),
                    influenceHeight = ExParsers.ParseDefault(el.GetAttribute("influenceHeight"), 0);

                string idTarget = el.GetAttribute("idTarget");
                int    destinyX = ExParsers.ParseDefault(el.GetAttribute("destinyX"), int.MinValue),
                       destinyY = ExParsers.ParseDefault(el.GetAttribute("destinyY"), int.MinValue);

                float destinyScale = ExParsers.ParseDefault(el.GetAttribute("destinyScale"), CultureInfo.InvariantCulture, float.MinValue);

                int transitionType = ExParsers.ParseDefault(el.GetAttribute("transitionType"), 0),
                    transitionTime = ExParsers.ParseDefault(el.GetAttribute("transitionTime"), 0);
                bool notEffects    = ExString.EqualsDefault(el.GetAttribute("not-effects"), "yes", false);


                currentExit = new Exit(rectangular, x, y, width, height);
                currentExit.setNextSceneId(idTarget);
                currentExit.setDestinyX(destinyX);
                currentExit.setDestinyY(destinyY);
                currentExit.setDestinyScale(destinyScale);
                currentExit.setTransitionTime(transitionTime);
                currentExit.setTransitionType(transitionType);
                currentExit.setHasNotEffects(notEffects);

                if (hasInfluence)
                {
                    InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight);
                    currentExit.setInfluenceArea(influenceArea);
                }

                foreach (XmlElement ell in el.SelectNodes("exit-look"))
                {
                    currentExitLook = new ExitLook();
                    string text       = ell.GetAttribute("text");
                    string cursorPath = ell.GetAttribute("cursor-path");
                    string soundPath  = ell.GetAttribute("sound-path");

                    currentExitLook.setCursorPath(cursorPath);
                    currentExitLook.setExitText(text);
                    currentExitLook.setSoundPath(soundPath);
                    currentExit.setDefaultExitLook(currentExitLook);
                }

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

                foreach (XmlElement ell in el.SelectNodes("point"))
                {
                    currentPoint = new Vector2(
                        ExParsers.ParseDefault(ell.GetAttribute("x"), 0),
                        ExParsers.ParseDefault(ell.GetAttribute("y"), 0));
                    currentExit.addPoint(currentPoint);
                }

                currentExit.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters)      as Conditions ?? new Conditions());
                currentExit.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters)            as Effects ?? new Effects());
                currentExit.setNotEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("not-effect"), parameters) as Effects ?? new Effects());
                currentExit.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects());

                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 element.SelectNodes("next-scene"))
            {
                string idTarget       = el.GetAttribute("idTarget");
                int    x              = ExParsers.ParseDefault(el.GetAttribute("x"), int.MinValue),
                       y              = ExParsers.ParseDefault(el.GetAttribute("y"), int.MinValue),
                       transitionType = ExParsers.ParseDefault(el.GetAttribute("transitionType"), 0),
                       transitionTime = ExParsers.ParseDefault(el.GetAttribute("transitionTime"), 0);

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

                currentNextScene.setExitLook(currentExitLook);

                currentNextScene.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions());
                currentNextScene.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters)               as Effects ?? new Effects());
                currentNextScene.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects());
            }

            foreach (XmlElement el in element.SelectNodes("objects/object-ref"))
            {
                currentElementReference = parseElementReference(el, parameters);
                scene.addItemReference(currentElementReference);
            }

            foreach (XmlElement el in element.SelectNodes("characters/character-ref"))
            {
                currentElementReference = parseElementReference(el, parameters);
                scene.addCharacterReference(currentElementReference);
            }

            foreach (XmlElement el in element.SelectNodes("atrezzo/atrezzo-ref"))
            {
                currentElementReference = parseElementReference(el, parameters);
                scene.addAtrezzoReference(currentElementReference);
            }

            foreach (var activeArea in DOMParserUtility.DOMParse <ActiveArea>(element.SelectNodes("active-areas/active-area"), parameters).ToList())
            {
                scene.addActiveArea(activeArea);
            }

            foreach (var barrier in DOMParserUtility.DOMParse <Barrier>(element.SelectNodes("barriers/barrier"), parameters).ToList())
            {
                scene.addBarrier(barrier);
            }

            foreach (var trajectory in DOMParserUtility.DOMParse <Trajectory>(element.SelectNodes("trajectory"), parameters).ToList())
            {
                scene.setTrajectory(trajectory);
            }


            if (scene != null)
            {
                TrajectoryFixer.fixTrajectory(scene);
            }

            return(scene);
        }
        public object DOMParse(XmlElement element, params object[] parameters)
        {
            var chapter = parameters [0] as Chapter;

            Cutscene cutscene;

            XmlNodeList
                endsgame   = element.SelectNodes("end-game"),
                nextsscene = element.SelectNodes("next-scene");

            string slidesceneId = element.GetAttribute("id");
            bool   initialScene = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false);

            if (element.Name.Equals("slidescene"))
            {
                cutscene = new Slidescene(slidesceneId);
            }
            else
            {
                cutscene = new Videoscene(slidesceneId);
            }
            if (initialScene)
            {
                chapter.setTargetId(slidesceneId);
            }

            //XAPI ELEMENTS
            cutscene.setXApiClass(element.GetAttribute("class"));
            cutscene.setXApiType(element.GetAttribute("type"));
            //END OF XAPI

            cutscene.setTargetId(element.GetAttribute("idTarget"));
            cutscene.setPositionX(ExParsers.ParseDefault(element.GetAttribute("destinyX"), int.MinValue));
            cutscene.setPositionY(ExParsers.ParseDefault(element.GetAttribute("destinyY"), int.MinValue));
            cutscene.setTransitionType((TransitionType)ExParsers.ParseDefault(element.GetAttribute("transitionType"), 0));
            cutscene.setTransitionTime(ExParsers.ParseDefault(element.GetAttribute("transitionTime"), 0));

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

            cutscene.setEffects(DOMParserUtility.DOMParse(element.SelectSingleNode("effect"), parameters) as Effects ?? new Effects());

            if (cutscene is Videoscene)
            {
                ((Videoscene)cutscene).setCanSkip(ExString.EqualsDefault(element.GetAttribute("canSkip"), "yes", true));
            }

            string next = ExString.Default(element.GetAttribute("next"), "go-back");

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

            // RESOURCES
            foreach (var res in DOMParserUtility.DOMParse <ResourcesUni> (element.SelectNodes("resources"), parameters))
            {
                cutscene.addResources(res);
            }

            for (int i = 0; i < endsgame.Count; i++)
            {
                cutscene.setNext(Cutscene.ENDCHAPTER);
            }

            foreach (XmlElement el in nextsscene)
            {
                var currentNextScene = new NextScene(el.GetAttribute("idTarget"),
                                                     ExParsers.ParseDefault(element.GetAttribute("destinyX"), int.MinValue),
                                                     ExParsers.ParseDefault(element.GetAttribute("destinyY"), int.MinValue));

                currentNextScene.setTransitionType((TransitionType)ExParsers.ParseDefault(element.GetAttribute("transitionType"), 0));
                currentNextScene.setTransitionTime(ExParsers.ParseDefault(element.GetAttribute("transitionTime"), 0));
                currentNextScene.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions());
                currentNextScene.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters) as Effects ?? new Effects());
                currentNextScene.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects());

                cutscene.addNextScene(currentNextScene);
            }

            return(cutscene);
        }