Пример #1
0
    /**
     * Build a node from a list of actions
     *
     * @param actions
     *            the list of actions
     * @return the xml node with the list of actions
     */

    public static XmlNode buildDOM(List <Action> actions)
    {
        XmlElement actionsElement = null;


        XmlDocument doc = Writer.GetDoc();

        // Create the root node
        actionsElement = doc.CreateElement("actions");

        // Append the actions (if there is at least one)
        if (actions.Count > 0)
        {
            // For every action
            foreach (Action action in actions)
            {
                XmlElement actionElement = null;

                // Create the element
                switch (action.getType())
                {
                case Action.EXAMINE:
                    actionElement = doc.CreateElement("examine");
                    break;

                case Action.GRAB:
                    actionElement = doc.CreateElement("grab");
                    break;

                case Action.USE:
                    actionElement = doc.CreateElement("use");
                    break;

                case Action.TALK_TO:
                    actionElement = doc.CreateElement("talk-to");
                    break;

                case Action.USE_WITH:
                    actionElement = doc.CreateElement("use-with");
                    actionElement.SetAttribute("idTarget", action.getTargetId());
                    break;

                case Action.GIVE_TO:
                    actionElement = doc.CreateElement("give-to");
                    actionElement.SetAttribute("idTarget", action.getTargetId());
                    break;

                case Action.DRAG_TO:
                    actionElement = doc.CreateElement("drag-to");
                    actionElement.SetAttribute("idTarget", action.getTargetId());
                    break;

                case Action.CUSTOM:
                    actionElement = doc.CreateElement("custom");
                    actionElement.SetAttribute("name", ((CustomAction)action).getName());
                    foreach (ResourcesUni resources in ((CustomAction)action).getResources())
                    {
                        XmlNode resourcesXmlNode = ResourcesDOMWriter.buildDOM(resources,
                                                                               ResourcesDOMWriter.RESOURCES_CUSTOM_ACTION);
                        //doc.adoptXmlNode(resourcesXmlNode);
                        doc.ImportNode(resourcesXmlNode, true);
                        actionElement.AppendChild(resourcesXmlNode);
                    }
                    break;

                case Action.CUSTOM_INTERACT:
                    actionElement = doc.CreateElement("custom-interact");
                    actionElement.SetAttribute("idTarget", action.getTargetId());
                    actionElement.SetAttribute("name", ((CustomAction)action).getName());
                    foreach (ResourcesUni resources in ((CustomAction)action).getResources())
                    {
                        XmlNode resourcesXmlNode = ResourcesDOMWriter.buildDOM(resources,
                                                                               ResourcesDOMWriter.RESOURCES_CUSTOM_ACTION);
                        doc.ImportNode(resourcesXmlNode, true);
                        actionElement.AppendChild(resourcesXmlNode);
                    }
                    break;
                }

                actionElement.SetAttribute("needsGoTo", (action.isNeedsGoTo() ? "yes" : "no"));
                actionElement.SetAttribute("keepDistance", "" + action.getKeepDistance());
                actionElement.SetAttribute("not-effects", action.isActivatedNotEffects() ? "yes" : "no");

                // Append the documentation (if avalaible)
                if (action.getDocumentation() != null)
                {
                    XmlNode actionDocumentationXmlNode = doc.CreateElement("documentation");
                    actionDocumentationXmlNode.AppendChild(doc.CreateTextNode(action.getDocumentation()));
                    actionElement.AppendChild(actionDocumentationXmlNode);
                }

                // Append the conditions (if avalaible)
                if (!action.getConditions().isEmpty())
                {
                    XmlNode conditionsXmlNode = ConditionsDOMWriter.buildDOM(action.getConditions());
                    doc.ImportNode(conditionsXmlNode, true);
                    actionElement.AppendChild(conditionsXmlNode);
                }

                // Append the effects (if avalaible)
                if (!action.getEffects().isEmpty())
                {
                    XmlNode effectsXmlNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, action.getEffects());
                    doc.ImportNode(effectsXmlNode, true);
                    actionElement.AppendChild(effectsXmlNode);
                }
                // Append the not effects (if avalaible)
                if (action.getNotEffects() != null && !action.getNotEffects().isEmpty())
                {
                    XmlNode notEffectsXmlNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.NOT_EFFECTS,
                                                                          action.getNotEffects());
                    doc.ImportNode(notEffectsXmlNode, true);
                    actionElement.AppendChild(notEffectsXmlNode);
                }

                // Append the action element
                actionsElement.AppendChild(actionElement);
            }
        }

        return(actionsElement);
    }
Пример #2
0
    /**
     * Returns the DOM element for the chapter
     *
     * @param chapter
     *            Chapter data to be written
     * @return DOM element with the chapter data
     */

    public static XmlNode buildDOM(Chapter chapter, String zipFile, XmlDocument doc)
    {
        XmlElement chapterNode = null;

        //try {
        // Create the necessary elements to create the DOM

        /*DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance( );
         * DocumentBuilder db = dbf.newDocumentBuilder( );
         * Document doc = db.newDocument( );
         */
        // Create the root node
        chapterNode = doc.CreateElement("eAdventure");

        // Add the adaptation and assessment active profiles
        if (!chapter.getAdaptationName().Equals(""))
        {
            chapterNode.SetAttribute("adaptProfile", chapter.getAdaptationName());
        }

        // Create and append the assessment configuration
        if (!chapter.getAssessmentName().Equals(""))
        {
            chapterNode.SetAttribute("assessProfile", chapter.getAssessmentName());
        }

        // Append the scene elements
        foreach (Scene scene in chapter.getScenes())
        {
            bool    initialScene = chapter.getTargetId().Equals(scene.getId());
            XmlNode sceneNode    = SceneDOMWriter.buildDOM(scene, initialScene);
            doc.ImportNode(sceneNode, true);
            chapterNode.AppendChild(sceneNode);
        }

        // Append the cutscene elements
        foreach (Cutscene cutscene in chapter.getCutscenes())
        {
            bool    initialScene = chapter.getTargetId().Equals(cutscene.getId());
            XmlNode cutsceneNode = CutsceneDOMWriter.buildDOM(cutscene, initialScene);
            doc.ImportNode(cutsceneNode, true);
            chapterNode.AppendChild(cutsceneNode);
        }

        // Append the book elements
        foreach (Book book in chapter.getBooks())
        {
            XmlNode bookNode = BookDOMWriter.buildDOM(book);
            doc.ImportNode(bookNode, true);
            chapterNode.AppendChild(bookNode);
        }

        // Append the item elements
        foreach (Item item in chapter.getItems())
        {
            XmlNode itemNode = ItemDOMWriter.buildDOM(item);
            doc.ImportNode(itemNode, true);
            chapterNode.AppendChild(itemNode);
        }

        // Append the player element
        XmlNode playerNode = PlayerDOMWriter.buildDOM(chapter.getPlayer());

        doc.ImportNode(playerNode, true);
        chapterNode.AppendChild(playerNode);

        // Append the character element
        foreach (NPC character in chapter.getCharacters())
        {
            XmlNode characterNode = CharacterDOMWriter.buildDOM(character);
            doc.ImportNode(characterNode, true);
            chapterNode.AppendChild(characterNode);
        }

        // Append the conversation element
        foreach (Conversation conversation in chapter.getConversations())
        {
            XmlNode conversationNode = ConversationDOMWriter.buildDOM(conversation);
            doc.ImportNode(conversationNode, true);
            chapterNode.AppendChild(conversationNode);
        }

        // Append the timers
        foreach (Timer timer in chapter.getTimers())
        {
            XmlNode timerNode = TimerDOMWriter.buildDOM(timer);
            doc.ImportNode(timerNode, true);
            chapterNode.AppendChild(timerNode);
        }

        // Append global states
        foreach (GlobalState globalState in chapter.getGlobalStates())
        {
            XmlElement globalStateElement = ConditionsDOMWriter.buildDOM(globalState);
            doc.ImportNode(globalStateElement, true);
            chapterNode.AppendChild(globalStateElement);
        }

        // Append macros
        foreach (Macro macro in chapter.getMacros())
        {
            XmlElement macroElement = EffectsDOMWriter.buildDOM(macro);
            doc.ImportNode(macroElement, true);
            chapterNode.AppendChild(macroElement);
        }

        // Append the atrezzo item elements
        foreach (Atrezzo atrezzo in chapter.getAtrezzo())
        {
            XmlNode atrezzoNode = AtrezzoDOMWriter.buildDOM(atrezzo);
            doc.ImportNode(atrezzoNode, true);
            chapterNode.AppendChild(atrezzoNode);
        }

        /*} catch( ParserConfigurationException e ) {
         *      ReportDialog.GenerateErrorReport(e, true, "UNKNOWERROR");
         * }*/

        return(chapterNode);
    }
Пример #3
0
    public static XmlNode buildDOM(Timer timer)
    {
        XmlElement timerElement = null;

        // Create the necessary elements to create the DOM
        XmlDocument doc = Writer.GetDoc();

        // Create the root node
        timerElement = doc.CreateElement("timer");

        // Set the time attribute
        timerElement.SetAttribute("time", timer.getTime().ToString());
        timerElement.SetAttribute("usesEndCondition", timer.isUsesEndCondition() ? "yes" : "no");
        timerElement.SetAttribute("multipleStarts", timer.isMultipleStarts() ? "yes" : "no");
        timerElement.SetAttribute("runsInLoop", timer.isRunsInLoop() ? "yes" : "no");
        timerElement.SetAttribute("showTime", timer.isShowTime() ? "yes" : "no");
        timerElement.SetAttribute("displayName", timer.getDisplayName());
        timerElement.SetAttribute("countDown", timer.isCountDown() ? "yes" : "no");
        timerElement.SetAttribute("showWhenStopped", timer.isShowWhenStopped() ? "yes" : "no");

        // Append the documentation (if avalaible)
        if (timer.getDocumentation() != null)
        {
            XmlNode timerDocumentationNode = doc.CreateElement("documentation");
            timerDocumentationNode.AppendChild(doc.CreateTextNode(timer.getDocumentation()));
            timerElement.AppendChild(timerDocumentationNode);
        }

        // Append the init conditions (if avalaible)
        if (!timer.getInitCond().isEmpty())
        {
            XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(ConditionsDOMWriter.INIT_CONDITIONS,
                                                                  timer.getInitCond());
            doc.ImportNode(conditionsNode, true);
            timerElement.AppendChild(conditionsNode);
        }

        // Append the end-conditions (if avalaible)
        if (!timer.getEndCond().isEmpty())
        {
            XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(ConditionsDOMWriter.END_CONDITIONS, timer.getEndCond());
            doc.ImportNode(conditionsNode, true);
            timerElement.AppendChild(conditionsNode);
        }

        // Append the effects (if avalaible)
        if (!timer.getEffects().isEmpty())
        {
            XmlNode effectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, timer.getEffects());
            doc.ImportNode(effectsNode, true);
            timerElement.AppendChild(effectsNode);
        }

        // Append the post-effects (if avalaible)
        if (!timer.getPostEffects().isEmpty())
        {
            XmlNode postEffectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.POST_EFFECTS, timer.getPostEffects());
            doc.ImportNode(postEffectsNode, true);
            timerElement.AppendChild(postEffectsNode);
        }

        return(timerElement);
    }
Пример #4
0
    public static XmlNode buildDOM(Scene scene, bool initialScene)
    {
        XmlElement sceneElement = null;

        if (scene != null)
        {
            TrajectoryFixer.fixTrajectory(scene);
        }
        // Create the necessary elements to create the DOM
        XmlDocument doc = Writer.GetDoc();

        // Create the root node
        sceneElement = doc.CreateElement("scene");
        sceneElement.SetAttribute("id", scene.getId());
        if (initialScene)
        {
            sceneElement.SetAttribute("start", "yes");
        }
        else
        {
            sceneElement.SetAttribute("start", "no");
        }

        sceneElement.SetAttribute("playerLayer", scene.getPlayerLayer().ToString());
        sceneElement.SetAttribute("playerScale", scene.getPlayerScale().ToString());

        // Append the documentation (if avalaible)
        if (scene.getDocumentation() != null)
        {
            XmlNode sceneDocumentationNode = doc.CreateElement("documentation");
            sceneDocumentationNode.AppendChild(doc.CreateTextNode(scene.getDocumentation()));
            sceneElement.AppendChild(sceneDocumentationNode);
        }

        // Append the resources
        foreach (ResourcesUni resources in scene.getResources())
        {
            XmlNode resourcesNode = ResourcesDOMWriter.buildDOM(resources, ResourcesDOMWriter.RESOURCES_SCENE);
            doc.ImportNode(resourcesNode, true);
            sceneElement.AppendChild(resourcesNode);
        }

        // Append the name
        XmlNode nameNode = doc.CreateElement("name");

        nameNode.AppendChild(doc.CreateTextNode(scene.getName()));
        sceneElement.AppendChild(nameNode);

        // Append the default inital position (if avalaible)
        if (scene.hasDefaultPosition())
        {
            XmlElement initialPositionElement = doc.CreateElement("default-initial-position");
            initialPositionElement.SetAttribute("x", scene.getPositionX().ToString());
            initialPositionElement.SetAttribute("y", scene.getPositionY().ToString());
            sceneElement.AppendChild(initialPositionElement);
        }

        // Append the exits (if there is at least one)
        if (scene.getExits().Count > 0)
        {
            XmlNode exitsElement = doc.CreateElement("exits");

            // Append every single exit
            foreach (Exit exit in scene.getExits())
            {
                // Create the exit element
                XmlElement exitElement = doc.CreateElement("exit");
                exitElement.SetAttribute("rectangular", (exit.isRectangular() ? "yes" : "no"));
                exitElement.SetAttribute("x", exit.getX().ToString());
                exitElement.SetAttribute("y", exit.getY().ToString());
                exitElement.SetAttribute("width", exit.getWidth().ToString());
                exitElement.SetAttribute("height", exit.getHeight().ToString());
                exitElement.SetAttribute("hasInfluenceArea", (exit.getInfluenceArea().isExists() ? "yes" : "no"));
                exitElement.SetAttribute("idTarget", exit.getNextSceneId());
                exitElement.SetAttribute("destinyY", exit.getDestinyY().ToString());
                exitElement.SetAttribute("destinyX", exit.getDestinyX().ToString());
                exitElement.SetAttribute("transitionType", exit.getTransitionType().ToString());
                exitElement.SetAttribute("transitionTime", exit.getTransitionTime().ToString());
                exitElement.SetAttribute("not-effects", (exit.isHasNotEffects() ? "yes" : "no"));

                if (exit.getInfluenceArea().isExists())
                {
                    exitElement.SetAttribute("influenceX", exit.getInfluenceArea().getX().ToString());
                    exitElement.SetAttribute("influenceY", exit.getInfluenceArea().getY().ToString());
                    exitElement.SetAttribute("influenceWidth", exit.getInfluenceArea().getWidth().ToString());
                    exitElement.SetAttribute("influenceHeight", exit.getInfluenceArea().getHeight().ToString());
                }

                // Append the documentation (if avalaible)
                if (exit.getDocumentation() != null)
                {
                    XmlNode exitDocumentationNode = doc.CreateElement("documentation");
                    exitDocumentationNode.AppendChild(doc.CreateTextNode(exit.getDocumentation()));
                    exitElement.AppendChild(exitDocumentationNode);
                }

                //Append the default exit look (if available)
                ExitLook defaultLook = exit.getDefaultExitLook();
                if (defaultLook != null)
                {
                    XmlElement exitLook = doc.CreateElement("exit-look");
                    if (defaultLook.getExitText() != null)
                    {
                        exitLook.SetAttribute("text", defaultLook.getExitText());
                    }
                    if (defaultLook.getCursorPath() != null)
                    {
                        exitLook.SetAttribute("cursor-path", defaultLook.getCursorPath());
                    }
                    if (defaultLook.getSoundPath() != null)
                    {
                        exitLook.SetAttribute("sound-path", defaultLook.getSoundPath());
                    }

                    if (defaultLook.getExitText() != null || defaultLook.getCursorPath() != null)
                    {
                        exitElement.AppendChild(exitLook);
                    }
                }

                // Append the next-scene structures
                foreach (NextScene nextScene in exit.getNextScenes())
                {
                    // Create the next-scene element
                    XmlElement nextSceneElement = doc.CreateElement("next-scene");
                    nextSceneElement.SetAttribute("idTarget", nextScene.getTargetId());

                    // Append the destination position (if avalaible)
                    if (nextScene.hasPlayerPosition())
                    {
                        nextSceneElement.SetAttribute("x", nextScene.getPositionX().ToString());
                        nextSceneElement.SetAttribute("y", nextScene.getPositionY().ToString());
                    }

                    nextSceneElement.SetAttribute("transitionTime", nextScene.getTransitionTime().ToString());
                    nextSceneElement.SetAttribute("transitionType", nextScene.getTransitionType().ToString());

                    // Append the conditions (if avalaible)
                    if (!nextScene.getConditions().isEmpty())
                    {
                        XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(nextScene.getConditions());
                        doc.ImportNode(conditionsNode, true);
                        nextSceneElement.AppendChild(conditionsNode);
                    }

                    //Append the default exit look (if available)
                    ExitLook look = nextScene.getExitLook();
                    if (look != null)
                    {
                        Debug.Log("SAVE 154: " + look.getExitText());
                        XmlElement exitLook = doc.CreateElement("exit-look");
                        if (look.getExitText() != null)
                        {
                            exitLook.SetAttribute("text", look.getExitText());
                        }
                        if (look.getCursorPath() != null)
                        {
                            exitLook.SetAttribute("cursor-path", look.getCursorPath());
                        }
                        if (look.getSoundPath() != null)
                        {
                            exitLook.SetAttribute("sound-path", look.getSoundPath());
                        }
                        if (look.getExitText() != null || look.getCursorPath() != null)
                        {
                            nextSceneElement.AppendChild(exitLook);
                        }
                    }

                    // Append the effects (if avalaible)
                    if (!nextScene.getEffects().isEmpty())
                    {
                        XmlNode effectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS,
                                                                        nextScene.getEffects());
                        doc.ImportNode(effectsNode, true);
                        nextSceneElement.AppendChild(effectsNode);
                    }

                    // Append the post-effects (if avalaible)
                    if (!nextScene.getPostEffects().isEmpty())
                    {
                        XmlNode postEffectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.POST_EFFECTS,
                                                                            nextScene.getPostEffects());
                        doc.ImportNode(postEffectsNode, true);
                        nextSceneElement.AppendChild(postEffectsNode);
                    }

                    // Append the next scene
                    exitElement.AppendChild(nextSceneElement);
                }

                if (!exit.isRectangular())
                {
                    foreach (Vector2 point in exit.getPoints())
                    {
                        XmlElement pointNode = doc.CreateElement("point");
                        pointNode.SetAttribute("x", ((int)point.x).ToString());
                        pointNode.SetAttribute("y", ((int)point.y).ToString());
                        exitElement.AppendChild(pointNode);
                    }
                }

                if (exit.getConditions() != null && !exit.getConditions().isEmpty())
                {
                    XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(exit.getConditions());
                    doc.ImportNode(conditionsNode, true);
                    exitElement.AppendChild(conditionsNode);
                }

                if (exit.getEffects() != null && !exit.getEffects().isEmpty())
                {
                    Debug.Log("SceneDOM Effects: " + exit.getEffects().getEffects().Count);
                    XmlNode effectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, exit.getEffects());
                    doc.ImportNode(effectsNode, true);
                    exitElement.AppendChild(effectsNode);
                }

                if (exit.getPostEffects() != null && !exit.getPostEffects().isEmpty())
                {
                    Debug.Log("SceneDOM PostEffects: " + exit.getPostEffects().getEffects().Count);
                    XmlNode postEffectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.POST_EFFECTS,
                                                                        exit.getPostEffects());
                    doc.ImportNode(postEffectsNode, true);
                    exitElement.AppendChild(postEffectsNode);
                }

                if (exit.getNotEffects() != null && !exit.getNotEffects().isEmpty())
                {
                    Debug.Log("SceneDOM NonEffects: " + exit.getNotEffects().getEffects().Count);
                    XmlNode notEffectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.NOT_EFFECTS,
                                                                       exit.getNotEffects());
                    doc.ImportNode(notEffectsNode, true);
                    exitElement.AppendChild(notEffectsNode);
                }

                // Append the exit
                exitsElement.AppendChild(exitElement);
            }
            // Append the list of exits
            sceneElement.AppendChild(exitsElement);
        }

        // Add the item references (if there is at least one)
        if (scene.getItemReferences().Count > 0)
        {
            XmlNode itemsNode = doc.CreateElement("objects");

            // Append every single item reference
            foreach (ElementReference itemReference in scene.getItemReferences())
            {
                // Create the item reference element
                XmlElement itemReferenceElement = doc.CreateElement("object-ref");
                itemReferenceElement.SetAttribute("idTarget", itemReference.getTargetId());
                itemReferenceElement.SetAttribute("x", itemReference.getX().ToString());
                itemReferenceElement.SetAttribute("y", itemReference.getY().ToString());
                itemReferenceElement.SetAttribute("scale", itemReference.getScale().ToString());
                if (itemReference.getLayer() != -1)
                {
                    itemReferenceElement.SetAttribute("layer", itemReference.getLayer().ToString());
                }
                if (itemReference.getInfluenceArea().isExists())
                {
                    itemReferenceElement.SetAttribute("hasInfluenceArea", "yes");
                    InfluenceArea ia = itemReference.getInfluenceArea();
                    itemReferenceElement.SetAttribute("influenceX", ia.getX().ToString());
                    itemReferenceElement.SetAttribute("influenceY", ia.getY().ToString());
                    itemReferenceElement.SetAttribute("influenceWidth", ia.getWidth().ToString());
                    itemReferenceElement.SetAttribute("influenceHeight", ia.getHeight().ToString());
                }
                else
                {
                    itemReferenceElement.SetAttribute("hasInfluenceArea", "no");
                }

                // Append the documentation (if avalaible)
                if (itemReference.getDocumentation() != null)
                {
                    XmlNode itemDocumentationNode = doc.CreateElement("documentation");
                    itemDocumentationNode.AppendChild(doc.CreateTextNode(itemReference.getDocumentation()));
                    itemReferenceElement.AppendChild(itemDocumentationNode);
                }

                // Append the conditions (if avalaible)
                if (!itemReference.getConditions().isEmpty())
                {
                    XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(itemReference.getConditions());
                    doc.ImportNode(conditionsNode, true);
                    itemReferenceElement.AppendChild(conditionsNode);
                }

                // Append the exit
                itemsNode.AppendChild(itemReferenceElement);
            }
            // Append the list of exits
            sceneElement.AppendChild(itemsNode);
        }

        // Add the character references (if there is at least one)
        if (scene.getCharacterReferences().Count > 0)
        {
            XmlNode charactersNode = doc.CreateElement("characters");

            // Append every single character reference
            foreach (ElementReference characterReference in scene.getCharacterReferences())
            {
                // Create the character reference element
                XmlElement npcReferenceElement = doc.CreateElement("character-ref");
                npcReferenceElement.SetAttribute("idTarget", characterReference.getTargetId());
                npcReferenceElement.SetAttribute("x", characterReference.getX().ToString());
                npcReferenceElement.SetAttribute("y", characterReference.getY().ToString());
                npcReferenceElement.SetAttribute("scale", characterReference.getScale().ToString());
                if (characterReference.getLayer() != -1)
                {
                    npcReferenceElement.SetAttribute("layer", characterReference.getLayer().ToString());
                }
                if (characterReference.getInfluenceArea().isExists())
                {
                    npcReferenceElement.SetAttribute("hasInfluenceArea", "yes");
                    InfluenceArea ia = characterReference.getInfluenceArea();
                    npcReferenceElement.SetAttribute("influenceX", ia.getX().ToString());
                    npcReferenceElement.SetAttribute("influenceY", ia.getY().ToString());
                    npcReferenceElement.SetAttribute("influenceWidth", ia.getWidth().ToString());
                    npcReferenceElement.SetAttribute("influenceHeight", ia.getHeight().ToString());
                }
                else
                {
                    npcReferenceElement.SetAttribute("hasInfluenceArea", "no");
                }

                // Append the documentation (if avalaible)
                if (characterReference.getDocumentation() != null)
                {
                    XmlNode itemDocumentationNode = doc.CreateElement("documentation");
                    itemDocumentationNode.AppendChild(doc.CreateTextNode(characterReference.getDocumentation()));
                    npcReferenceElement.AppendChild(itemDocumentationNode);
                }

                // Append the conditions (if avalaible)
                if (!characterReference.getConditions().isEmpty())
                {
                    XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(characterReference.getConditions());
                    doc.ImportNode(conditionsNode, true);
                    npcReferenceElement.AppendChild(conditionsNode);
                }

                // Append the exit
                charactersNode.AppendChild(npcReferenceElement);
            }
            // Append the list of exits
            sceneElement.AppendChild(charactersNode);
        }

        // Append the exits (if there is at least one)
        if (scene.getActiveAreas().Count > 0)
        {
            XmlNode aasElement = doc.CreateElement("active-areas");

            // Append every single exit
            foreach (ActiveArea activeArea in scene.getActiveAreas())
            {
                // Create the active area element
                XmlElement aaElement = doc.CreateElement("active-area");
                if (activeArea.getId() != null)
                {
                    aaElement.SetAttribute("id", activeArea.getId());
                }
                aaElement.SetAttribute("rectangular", (activeArea.isRectangular() ? "yes" : "no"));
                aaElement.SetAttribute("x", activeArea.getX().ToString());
                aaElement.SetAttribute("y", activeArea.getY().ToString());
                aaElement.SetAttribute("width", activeArea.getWidth().ToString());
                aaElement.SetAttribute("height", activeArea.getHeight().ToString());
                if (activeArea.getInfluenceArea().isExists())
                {
                    aaElement.SetAttribute("hasInfluenceArea", "yes");
                    InfluenceArea ia = activeArea.getInfluenceArea();
                    aaElement.SetAttribute("influenceX", ia.getX().ToString());
                    aaElement.SetAttribute("influenceY", ia.getY().ToString());
                    aaElement.SetAttribute("influenceWidth", ia.getWidth().ToString());
                    aaElement.SetAttribute("influenceHeight", ia.getHeight().ToString());
                }
                else
                {
                    aaElement.SetAttribute("hasInfluenceArea", "no");
                }

                // Append the documentation (if avalaible)
                if (activeArea.getDocumentation() != null)
                {
                    XmlNode exitDocumentationNode = doc.CreateElement("documentation");
                    exitDocumentationNode.AppendChild(doc.CreateTextNode(activeArea.getDocumentation()));
                    aaElement.AppendChild(exitDocumentationNode);
                }

                // Append the conditions (if avalaible)
                if (!activeArea.getConditions().isEmpty())
                {
                    XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(activeArea.getConditions());
                    doc.ImportNode(conditionsNode, true);
                    aaElement.AppendChild(conditionsNode);
                }


                foreach (Description description in activeArea.getDescriptions())
                {
                    // Create the description
                    XmlNode descriptionNode = doc.CreateElement("description");

                    // Append the conditions (if available)
                    if (description.getConditions() != null && !description.getConditions().isEmpty())
                    {
                        XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(description.getConditions());
                        doc.ImportNode(conditionsNode, true);
                        descriptionNode.AppendChild(conditionsNode);
                    }

                    // Create and append the name, brief description and detailed description
                    XmlElement aaNameNode = doc.CreateElement("name");
                    if (description.getNameSoundPath() != null && !description.getNameSoundPath().Equals(""))
                    {
                        aaNameNode.SetAttribute("soundPath", description.getNameSoundPath());
                    }
                    aaNameNode.AppendChild(doc.CreateTextNode(description.getName()));
                    descriptionNode.AppendChild(aaNameNode);

                    XmlElement aaBriefNode = doc.CreateElement("brief");
                    if (description.getDescriptionSoundPath() != null &&
                        !description.getDescriptionSoundPath().Equals(""))
                    {
                        aaBriefNode.SetAttribute("soundPath", description.getDescriptionSoundPath());
                    }
                    aaBriefNode.AppendChild(doc.CreateTextNode(description.getDescription()));
                    descriptionNode.AppendChild(aaBriefNode);

                    XmlElement aaDetailedNode = doc.CreateElement("detailed");
                    if (description.getDetailedDescriptionSoundPath() != null &&
                        !description.getDetailedDescriptionSoundPath().Equals(""))
                    {
                        aaDetailedNode.SetAttribute("soundPath", description.getDetailedDescriptionSoundPath());
                    }
                    aaDetailedNode.AppendChild(doc.CreateTextNode(description.getDetailedDescription()));
                    descriptionNode.AppendChild(aaDetailedNode);

                    // Append the description
                    aaElement.AppendChild(descriptionNode);
                }

                // Append the actions (if there is at least one)
                if (activeArea.getActions().Count > 0)
                {
                    XmlNode actionsNode = ActionsDOMWriter.buildDOM(activeArea.getActions());
                    doc.ImportNode(actionsNode, true);

                    // Append the actions node
                    aaElement.AppendChild(actionsNode);
                }

                if (!activeArea.isRectangular())
                {
                    foreach (Vector2 point in activeArea.getPoints())
                    {
                        XmlElement pointNode = doc.CreateElement("point");
                        pointNode.SetAttribute("x", ((int)point.x).ToString());
                        pointNode.SetAttribute("y", ((int)point.y).ToString());
                        aaElement.AppendChild(pointNode);
                    }
                }

                // Append the exit
                aasElement.AppendChild(aaElement);
            }
            // Append the list of exits
            sceneElement.AppendChild(aasElement);
        }

        // Append the barriers (if there is at least one)
        if (scene.getBarriers().Count > 0)
        {
            XmlNode barriersElement = doc.CreateElement("barriers");

            // Append every single barrier
            foreach (Barrier barrier in scene.getBarriers())
            {
                // Create the active area element
                XmlElement barrierElement = doc.CreateElement("barrier");
                barrierElement.SetAttribute("x", barrier.getX().ToString());
                barrierElement.SetAttribute("y", barrier.getY().ToString());
                barrierElement.SetAttribute("width", barrier.getWidth().ToString());
                barrierElement.SetAttribute("height", barrier.getHeight().ToString());

                // Append the documentation (if avalaible)
                if (barrier.getDocumentation() != null)
                {
                    XmlNode exitDocumentationNode = doc.CreateElement("documentation");
                    exitDocumentationNode.AppendChild(doc.CreateTextNode(barrier.getDocumentation()));
                    barrierElement.AppendChild(exitDocumentationNode);
                }

                // Append the conditions (if avalaible)
                if (!barrier.getConditions().isEmpty())
                {
                    XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(barrier.getConditions());
                    doc.ImportNode(conditionsNode, true);
                    barrierElement.AppendChild(conditionsNode);
                }

                // Append the barrier
                barriersElement.AppendChild(barrierElement);
            }
            // Append the list of exits
            sceneElement.AppendChild(barriersElement);
        }

        // Add the atrezzo item references (if there is at least one)
        if (scene.getAtrezzoReferences().Count > 0)
        {
            XmlNode atrezzoNode = doc.CreateElement("atrezzo");

            // Append every single atrezzo reference
            foreach (ElementReference atrezzoReference in scene.getAtrezzoReferences())
            {
                // Create the atrezzo reference element
                XmlElement atrezzoReferenceElement = doc.CreateElement("atrezzo-ref");
                atrezzoReferenceElement.SetAttribute("idTarget", atrezzoReference.getTargetId());
                atrezzoReferenceElement.SetAttribute("x", atrezzoReference.getX().ToString());
                atrezzoReferenceElement.SetAttribute("y", atrezzoReference.getY().ToString());
                atrezzoReferenceElement.SetAttribute("scale", atrezzoReference.getScale().ToString());
                if (atrezzoReference.getLayer() != -1)
                {
                    atrezzoReferenceElement.SetAttribute("layer", atrezzoReference.getLayer().ToString());
                }

                // Append the documentation (if avalaible)
                if (atrezzoReference.getDocumentation() != null)
                {
                    XmlNode itemDocumentationNode = doc.CreateElement("documentation");
                    itemDocumentationNode.AppendChild(doc.CreateTextNode(atrezzoReference.getDocumentation()));
                    atrezzoReferenceElement.AppendChild(itemDocumentationNode);
                }

                // Append the conditions (if avalaible)
                if (!atrezzoReference.getConditions().isEmpty())
                {
                    XmlNode conditionsNode = ConditionsDOMWriter.buildDOM(atrezzoReference.getConditions());
                    doc.ImportNode(conditionsNode, true);
                    atrezzoReferenceElement.AppendChild(conditionsNode);
                }

                // Append the atrezzo reference
                atrezzoNode.AppendChild(atrezzoReferenceElement);
            }
            // Append the list of atrezzo references
            sceneElement.AppendChild(atrezzoNode);
        }

        if (scene.getTrajectory() != null)
        {
            XmlNode trajectoryNode = TrajectoryDOMWriter.buildDOM(scene.getTrajectory());
            doc.ImportNode(trajectoryNode, true);
            sceneElement.AppendChild(trajectoryNode);
        }

        return(sceneElement);
    }
    /**
     * Recursive function responsible for transforming a node (and its children)
     * into a DOM structure
     *
     * @param currentNode
     *            Node to be transformed
     * @param rootDOMNode
     *            DOM node in which the elements must be attached
     */

    private static void writeNodeInDOM(ConversationNode currentNode, XmlNode rootDOMNode)
    {
        // Extract the document
        XmlDocument document = rootDOMNode.OwnerDocument;

        // If the node is a DialogueNode write the lines one after another, and then the child (or the mark if it is no
        // child)
        if (currentNode.getType() == ConversationNodeViewEnum.DIALOGUE)
        {
            // For each line of the node
            for (int i = 0; i < currentNode.getLineCount(); i++)
            {
                // Create a phrase element, and extract the actual text line
                XmlElement       phrase;
                XmlNode          conditionsNode = null;
                ConversationLine line           = currentNode.getLine(i);

                // If the line belongs to the player, create a "speak-player" element. Otherwise, if it belongs to a
                // NPC,
                // create a "speak-char" element, which will have an attribute "idTarget" with the name of the
                // non-playable character,
                // if there is no name the attribute won't be written
                if (line.isPlayerLine())
                {
                    phrase = document.CreateElement("speak-player");
                }
                else
                {
                    phrase = document.CreateElement("speak-char");
                    if (!line.getName().Equals("NPC"))
                    {
                        phrase.SetAttribute("idTarget", line.getName());
                    }
                }

                // Add the line text into the element
                phrase.InnerText = (line.getText());

                //If there is audio track, store it as attribute
                if (line.isValidAudio())
                {
                    phrase.SetAttribute("uri", line.getAudioPath());
                }
                //If there is a synthesizer valid voice, store it as attribute
                if (line.getSynthesizerVoice())
                {
                    phrase.SetAttribute("synthesize", "yes");
                }

                // Add the element to the DOM root
                rootDOMNode.AppendChild(phrase);

                // Create conditions for current effect
                conditionsNode = ConditionsDOMWriter.buildDOM(line.getConditions());
                document.ImportNode(conditionsNode, true);

                // Add conditions associated to that effect
                rootDOMNode.AppendChild(conditionsNode);
            }

            // Check if the node is terminal
            if (currentNode.isTerminal())
            {
                // If it is terminal add a "end-conversation" element
                XmlElement endConversation = document.CreateElement("end-conversation");

                // If the terminal node has an effect, include it into the DOM
                if (currentNode.hasEffects())
                {
                    // Extract the root node
                    XmlNode effect = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, currentNode.getEffects());

                    // Insert it into the DOM
                    document.ImportNode(effect, true);
                    endConversation.AppendChild(effect);
                }

                // Add the "end-conversation" tag into the root
                rootDOMNode.AppendChild(endConversation);
            }
            else
            {
                // If the node isn't terminal, check if it performing a "go-back" (going back to the inmediatly upper
                // OptionNode)
                if (TreeConversation.thereIsGoBackTag(currentNode))
                {
                    // If it is the case, add a "go-back" element
                    rootDOMNode.AppendChild(document.CreateElement("go-back"));
                }
                else
                {
                    // Otherwise, if the node has a child, call the recursive function with the child node, and the same
                    // DOM root node
                    writeNodeInDOM(currentNode.getChild(0), rootDOMNode);
                }
            }
        }

        // If the node is a OptionNode write a "response" element, and inside it a "option" element with its content
        else if (currentNode.getType() == ConversationNodeViewEnum.OPTION)
        {
            // Create the "response" element
            XmlElement response = document.CreateElement("response");
            // Adds a random attribute if "random" is activate in conversation node data
            if (((OptionConversationNode)currentNode).isRandom())
            {
                response.SetAttribute("random", "yes");
            }
            // For each line of the node (we suppose the number of line equals the number of links, or children nodes)
            for (int i = 0; i < currentNode.getLineCount(); i++)
            {
                // Create the "option" element
                XmlElement       optionElement = document.CreateElement("option");
                ConversationLine line          = currentNode.getLine(i);
                // Create the actual option (a "speak-player" element) and add its respective text
                XmlElement lineElement = document.CreateElement("speak-player");
                lineElement.InnerText = currentNode.getLine(i).getText();

                //If there is audio track, store it as attribute
                if (line.isValidAudio())
                {
                    lineElement.SetAttribute("uri", line.getAudioPath());
                }
                //If there is a synthesizer valid voice, store it as attribute
                if (line.getSynthesizerVoice())
                {
                    lineElement.SetAttribute("synthesize", "yes");
                }

                // Insert the text line in the option node
                optionElement.AppendChild(lineElement);

                // Call the recursive function, to write in the "option" node the appropiate elements
                // Note that the root DOM node is the "option" element
                writeNodeInDOM(currentNode.getChild(i), optionElement);

                // Add the "option" element
                response.AppendChild(optionElement);
            }
            // If the terminal node has an effect, include it into the DOM
            if (currentNode.hasEffects())
            {
                // Extract the root node
                XmlNode effect = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, currentNode.getEffects());

                // Insert it into the DOM
                document.ImportNode(effect, true);
                response.AppendChild(effect);
            }

            // Add the element
            rootDOMNode.AppendChild(response);
        }
    }
    private static XmlNode buildGraphConversationDOM(GraphConversation graphConversation)
    {
        XmlElement conversationElement = null;

        // Get the complete node list
        List <ConversationNode> nodes = graphConversation.getAllNodes();

        // Create the necessary elements to create the DOM
        XmlDocument doc = Writer.GetDoc();

        // Create the root node
        conversationElement = doc.CreateElement("graph-conversation");
        conversationElement.SetAttribute("id", graphConversation.getId());

        // For each node
        for (int i = 0; i < nodes.Count; i++)
        {
            ConversationNode node = nodes[i];

            XmlElement nodeElement    = null;
            XmlNode    conditionsNode = null;

            // If the node is a dialogue node
            if (node is DialogueConversationNode)
            {
                // Create the node element and set the nodeindex
                nodeElement = doc.CreateElement("dialogue-node");
                nodeElement.SetAttribute("nodeindex", i.ToString());
                // Adds a random attribute if "keepShowing" is activate in conversation node data
                if (((DialogueConversationNode)node).isKeepShowing())
                {
                    nodeElement.SetAttribute("keepShowing", "yes");
                }
                if (node.getEditorX() != -1)
                {
                    nodeElement.SetAttribute("editor-x", node.getEditorX().ToString());
                }
                if (node.getEditorY() != -1)
                {
                    nodeElement.SetAttribute("editor-y", node.getEditorY().ToString());
                }
                // For each line of the node
                for (int j = 0; j < node.getLineCount(); j++)
                {
                    // Create a phrase element, and extract the actual text line
                    XmlElement       phrase;
                    ConversationLine line = node.getLine(j);

                    // If the line belongs to the player, create a "speak-player" element. Otherwise, if it belongs
                    // to a NPC,
                    // create a "speak-char" element, which will have an attribute "idTarget" with the name of the
                    // non-playable character,
                    // if there is no name the attribute won't be written
                    if (line.isPlayerLine())
                    {
                        phrase = doc.CreateElement("speak-player");
                    }
                    else
                    {
                        phrase = doc.CreateElement("speak-char");
                        if (!line.getName().Equals("NPC"))
                        {
                            phrase.SetAttribute("idTarget", line.getName());
                        }
                    }

                    //If there is audio track, store it as attribute
                    if (line.isValidAudio())
                    {
                        phrase.SetAttribute("uri", line.getAudioPath());
                    }
                    //If there is a synthesizer valid voice, store it as attribute
                    if (line.getSynthesizerVoice())
                    {
                        phrase.SetAttribute("synthesize", "yes");
                    }

                    // Add the line text into the element
                    phrase.InnerText = (line.getText());

                    // Add the element to the node
                    nodeElement.AppendChild(phrase);

                    // Create conditions for current effect
                    conditionsNode = ConditionsDOMWriter.buildDOM(line.getConditions());
                    doc.ImportNode(conditionsNode, true);
                    // Add conditions associated to that effect
                    nodeElement.AppendChild(conditionsNode);
                }

                // Check if the node is terminal
                if (node.isTerminal())
                {
                    // If it is terminal add a "end-conversation" element
                    XmlElement endConversation = doc.CreateElement("end-conversation");

                    // If the terminal node has an effect, include it into the DOM
                    if (node.hasEffects())
                    {
                        // Extract the root node
                        XmlNode effect = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, node.getEffects());

                        // Insert it into the DOM
                        doc.ImportNode(effect, true);
                        endConversation.AppendChild(effect);
                    }

                    // Add the "end-conversation" tag into the node
                    nodeElement.AppendChild(endConversation);
                }
                else
                {
                    // Otherwise, if the node has a child, add the element
                    XmlElement childElement = doc.CreateElement("child");

                    // Add the number of the child node (index of the node in the structure)
                    childElement.SetAttribute("nodeindex", nodes.IndexOf(node.getChild(0)).ToString());

                    // Insert the tag into the node
                    nodeElement.AppendChild(childElement);

                    // TODO MODIFIED
                    // If the terminal node has an effect, include it into the DOM
                    if (node.hasEffects())
                    {
                        // Extract the root node
                        XmlNode effect = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, node.getEffects());

                        // Insert it into the DOM
                        doc.ImportNode(effect, true);
                        nodeElement.AppendChild(effect);
                    }
                }
            }

            // If the node is a option node
            if (node is OptionConversationNode)
            {
                // Create the node element and set the nodeindex
                nodeElement = doc.CreateElement("option-node");
                nodeElement.SetAttribute("nodeindex", i.ToString());
                // Adds a random attribute if "random" is activate in conversation node data
                if (((OptionConversationNode)node).isRandom())
                {
                    nodeElement.SetAttribute("random", "yes");
                }
                // Adds a random attribute if "keepShowing" is activate in conversation node data
                if (((OptionConversationNode)node).isKeepShowing())
                {
                    nodeElement.SetAttribute("keepShowing", "yes");
                }
                // Adds a random attribute if "showUserOption" is activate in conversation node data
                if (((OptionConversationNode)node).isShowUserOption())
                {
                    nodeElement.SetAttribute("showUserOption", "yes");
                }
                // Adds a random attribute if "preListening" is activate in conversation node data
                if (((OptionConversationNode)node).isPreListening())
                {
                    nodeElement.SetAttribute("preListening", "yes");
                }
                if (node.getEditorX() != -1)
                {
                    nodeElement.SetAttribute("editor-x", node.getEditorX().ToString());
                }
                if (node.getEditorY() != -1)
                {
                    nodeElement.SetAttribute("editor-y", node.getEditorY().ToString());
                }
                // Adds the x position of the options conversations node
                nodeElement.SetAttribute("x", ((OptionConversationNode)node).getX().ToString());
                // Adds a random attribute if "preListening" is activate in conversation node data
                nodeElement.SetAttribute("y", ((OptionConversationNode)node).getY().ToString());

                // For each line of the node
                for (int j = 0; j < node.getLineCount(); j++)
                {
                    // Take the current conversation line
                    ConversationLine line = node.getLine(j);

                    // Create the actual option (a "speak-player" element) and add its respective text
                    XmlElement lineElement = doc.CreateElement("speak-player");
                    lineElement.InnerText = (node.getLine(j).getText());

                    //If there is audio track, store it as attribute
                    if (line.isValidAudio())
                    {
                        lineElement.SetAttribute("uri", line.getAudioPath());
                    }
                    //If there is a synthesizer valid voice, store it as attribute
                    if (line.getSynthesizerVoice())
                    {
                        lineElement.SetAttribute("synthesize", "yes");
                    }

                    // Create conditions for current effect
                    conditionsNode = ConditionsDOMWriter.buildDOM(line.getConditions());
                    doc.ImportNode(conditionsNode, true);

                    // Create a child tag, and set it the index of the child
                    XmlElement childElement = doc.CreateElement("child");
                    childElement.SetAttribute("nodeindex", nodes.IndexOf(node.getChild(j)).ToString());

                    // Insert the text line in the option node
                    nodeElement.AppendChild(lineElement);
                    // Add conditions associated to that effect
                    nodeElement.AppendChild(conditionsNode);
                    // Insert child tag
                    nodeElement.AppendChild(childElement);
                }
                // If node has an effect, include it into the DOM
                if (node.hasEffects())
                {
                    // Extract the root node
                    XmlNode effect = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, node.getEffects());

                    // Insert it into the DOM
                    doc.ImportNode(effect, true);
                    nodeElement.AppendChild(effect);
                }
            }

            // Add the node to the conversation
            conversationElement.AppendChild(nodeElement);
        }


        return(conversationElement);
    }
    public static XmlNode buildDOM(Cutscene cutscene, bool initialScene)
    {
        XmlElement cutsceneElement = null;


        // Create the necessary elements to create the DOM
        XmlDocument doc = Writer.GetDoc();

        // Create the root node
        if (cutscene.getType() == GeneralScene.GeneralSceneSceneType.SLIDESCENE)
        {
            cutsceneElement = doc.CreateElement("slidescene");
        }
        else if (cutscene.getType() == GeneralScene.GeneralSceneSceneType.VIDEOSCENE)
        {
            cutsceneElement = doc.CreateElement("videoscene");
            if (((Videoscene)cutscene).isCanSkip())
            {
                cutsceneElement.SetAttribute("canSkip", "yes");
            }
            else
            {
                cutsceneElement.SetAttribute("canSkip", "no");
            }
        }

        // Set the attributes
        cutsceneElement.SetAttribute("id", cutscene.getId());
        if (initialScene)
        {
            cutsceneElement.SetAttribute("start", "yes");
        }
        else
        {
            cutsceneElement.SetAttribute("start", "no");
        }

        if (cutscene.getNext() == Cutscene.NEWSCENE)
        {
            cutsceneElement.SetAttribute("idTarget", cutscene.getTargetId());

            cutsceneElement.SetAttribute("destinyX", cutscene.getPositionX().ToString());
            cutsceneElement.SetAttribute("destinyY", cutscene.getPositionY().ToString());

            cutsceneElement.SetAttribute("transitionTime", cutscene.getTransitionTime().ToString());
            cutsceneElement.SetAttribute("transitionType", cutscene.getTransitionType().ToString());
        }

        if (cutscene.getNext() == Cutscene.GOBACK)
        {
            cutsceneElement.SetAttribute("next", "go-back");
        }
        else if (cutscene.getNext() == Cutscene.ENDCHAPTER)
        {
            cutsceneElement.SetAttribute("next", "end-chapter");
        }
        else if (cutscene.getNext() == Cutscene.NEWSCENE)
        {
            cutsceneElement.SetAttribute("next", "new-scene");
        }

        // Append the documentation (if avalaible)
        if (cutscene.getDocumentation() != null)
        {
            XmlNode cutsceneDocumentationNode = doc.CreateElement("documentation");
            cutsceneDocumentationNode.AppendChild(doc.CreateTextNode(cutscene.getDocumentation()));
            cutsceneElement.AppendChild(cutsceneDocumentationNode);
        }

        if (!cutscene.getEffects().isEmpty())
        {
            XmlNode effectsNode = EffectsDOMWriter.buildDOM(EffectsDOMWriter.EFFECTS, cutscene.getEffects());
            doc.ImportNode(effectsNode, true);
            cutsceneElement.AppendChild(effectsNode);
        }

        // Append the resources
        foreach (ResourcesUni resources in cutscene.getResources())
        {
            XmlNode resourcesNode = ResourcesDOMWriter.buildDOM(resources, ResourcesDOMWriter.RESOURCES_CUTSCENE);
            doc.ImportNode(resourcesNode, true);
            cutsceneElement.AppendChild(resourcesNode);
        }

        // Append the name
        XmlNode nameNode = doc.CreateElement("name");

        nameNode.AppendChild(doc.CreateTextNode(cutscene.getName()));
        cutsceneElement.AppendChild(nameNode);

        return(cutsceneElement);
    }