protected static ResourcesUni createResources(ExitLook exitLook) { ResourcesUni resources = new ResourcesUni(); resources.addAsset(CURSOR_STR, exitLook.getCursorPath()); return(resources); }
public ExitLookDataControl(NextScene nextScene) { if (nextScene.getExitLook() == null) { nextScene.setExitLook(new ExitLook()); } this.exitLook = nextScene.getExitLook(); }
public ExitLookDataControl(Exit exit) { if (exit.getDefaultExitLook() == null) { exit.setDefaultExitLook(new ExitLook()); } this.exitLook = exit.getDefaultExitLook(); }
public object Clone() { ExitLook el = (ExitLook)this.MemberwiseClone(); el.cursorPath = (cursorPath != null ? cursorPath : null); el.exitText = (exitText != null ? exitText : null); el.soundPath = (soundPath != null ? soundPath : null); return(el); }
/** * Creates a new Exit * * @param x * The horizontal coordinate of the upper left corner of the exit * @param y * The vertical coordinate of the upper left corner of the exit * @param width * The width of the exit * @param height * The height of the exit */ public Exit(bool rectangular, int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; documentation = null; points = new List <Vector2>(); nextScenes = new List <NextScene>(); this.rectangular = rectangular; influenceArea = new InfluenceArea(); destinyX = int.MinValue; destinyY = int.MinValue; conditions = new Conditions(); effects = new Effects(); postEffects = new Effects(); notEffects = new Effects(); hasNotEffects = false; transitionType = NO_TRANSITION; transitionTime = 0; defaultExitLook = new ExitLook(); }
protected override void FillNode(XmlNode node, object target, params IDOMWriterParam[] options) { var sceneElement = node as XmlElement; var scene = target as Scene; if (scene != null) { TrajectoryFixer.fixTrajectory(scene); } // Create the necessary elements to create the DOM XmlDocument doc = Writer.GetDoc(); // Create the root node sceneElement.SetAttribute("id", scene.getId()); sceneElement.SetAttribute("hideInventory", scene.HideInventory ? "yes" : "no"); if (options.Any(o => o is CIP && (o as CIP).TargetId.Equals(scene.getId()))) { sceneElement.SetAttribute("start", "yes"); } else { sceneElement.SetAttribute("start", "no"); } sceneElement.SetAttribute("playerLayer", scene.getPlayerLayer().ToString()); sceneElement.SetAttribute("playerScale", scene.getPlayerScale().ToString(CultureInfo.InvariantCulture)); sceneElement.SetAttribute("class", scene.getXApiClass()); sceneElement.SetAttribute("type", scene.getXApiType()); // 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()); if (exit.getDestinyScale() >= 0) { exitElement.SetAttribute("destinyScale", exit.getDestinyScale().ToString(CultureInfo.InvariantCulture)); } 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()) { DOMWriterUtility.DOMWrite(nextSceneElement, nextScene.getConditions()); } //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); } } OrderedDictionary nextSceneEffects = new OrderedDictionary(); if (nextScene.getEffects() != null && !nextScene.getEffects().IsEmpty()) { nextSceneEffects.Add(EffectsDOMWriter.EFFECTS, nextScene.getEffects()); } if (nextScene.getPostEffects() != null && !nextScene.getPostEffects().IsEmpty()) { nextSceneEffects.Add(EffectsDOMWriter.POST_EFFECTS, nextScene.getPostEffects()); } // Append the next scene DOMWriterUtility.DOMWrite(nextSceneElement, nextSceneEffects, DOMWriterUtility.DontCreateElement()); 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()) { DOMWriterUtility.DOMWrite(exitElement, exit.getConditions()); } OrderedDictionary effectsTypes = new OrderedDictionary(); if (exit.getEffects() != null && !exit.getEffects().IsEmpty()) { effectsTypes.Add(EffectsDOMWriter.EFFECTS, exit.getEffects()); } if (exit.getPostEffects() != null && !exit.getPostEffects().IsEmpty()) { effectsTypes.Add(EffectsDOMWriter.POST_EFFECTS, exit.getPostEffects()); } if (exit.getNotEffects() != null && !exit.getNotEffects().IsEmpty()) { effectsTypes.Add(EffectsDOMWriter.NOT_EFFECTS, exit.getNotEffects()); } DOMWriterUtility.DOMWrite(exitElement, effectsTypes, DOMWriterUtility.DontCreateElement()); // 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.Scale.ToString(CultureInfo.InvariantCulture)); 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.Conditions.IsEmpty()) { DOMWriterUtility.DOMWrite(itemReferenceElement, itemReference.Conditions); } // 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.Scale.ToString(CultureInfo.InvariantCulture)); npcReferenceElement.SetAttribute("orientation", ((int)characterReference.Orientation).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.Conditions.IsEmpty()) { DOMWriterUtility.DOMWrite(npcReferenceElement, characterReference.Conditions); } // 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"); } // Behavior if (activeArea.getBehaviour() == Item.BehaviourType.NORMAL) { aaElement.SetAttribute("behaviour", "normal"); } if (activeArea.getBehaviour() == Item.BehaviourType.ATREZZO) { aaElement.SetAttribute("behaviour", "atrezzo"); } if (activeArea.getBehaviour() == Item.BehaviourType.FIRST_ACTION) { aaElement.SetAttribute("behaviour", "first-action"); } // 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()) { DOMWriterUtility.DOMWrite(aaElement, activeArea.getConditions()); } 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()) { DOMWriterUtility.DOMWrite(descriptionNode, description.getConditions()); } // 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) { DOMWriterUtility.DOMWrite(aaElement, activeArea.getActions()); } 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()) { DOMWriterUtility.DOMWrite(barrierElement, barrier.getConditions()); } // 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.Scale.ToString(CultureInfo.InvariantCulture)); 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.Conditions.IsEmpty()) { DOMWriterUtility.DOMWrite(atrezzoReferenceElement, atrezzoReference.Conditions); } // Append the atrezzo reference atrezzoNode.AppendChild(atrezzoReferenceElement); } // Append the list of atrezzo references sceneElement.AppendChild(atrezzoNode); } if (scene.getTrajectory() != null) { DOMWriterUtility.DOMWrite(sceneElement, scene.getTrajectory()); } }
/** * @param defaultExitLook * the defaultExitLook to set */ public void setDefaultExitLook(ExitLook defaultExitLook) { this.defaultExitLook = defaultExitLook; }
/** * Creates a new Exit * * @param x * The horizontal coordinate of the upper left corner of the exit * @param y * The vertical coordinate of the upper left corner of the exit * @param width * The width of the exit * @param height * The height of the exit */ public Exit(bool rectangular, int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; documentation = null; points = new List<Vector2>(); nextScenes = new List<NextScene>(); this.rectangular = rectangular; influenceArea = new InfluenceArea(); destinyX = int.MinValue; destinyY = int.MinValue; conditions = new Conditions(); effects = new Effects(); postEffects = new Effects(); notEffects = new Effects(); hasNotEffects = false; transitionType = NO_TRANSITION; transitionTime = 0; defaultExitLook = new ExitLook(); }
public override void ParseElement(XmlElement element) { XmlNodeList resourcess = element.SelectNodes("resources"), assets, conditions, effects, postseffects, notseffect, defaultsinitialsposition = element.SelectNodes("default-initial-position"), exits = element.SelectNodes("exits/exit"), exitslook, nextsscene = element.SelectNodes("next-scene"), points, objectsrefs = element.SelectNodes("objects/object-ref"), charactersrefs = element.SelectNodes("characters/character-ref"), atrezzosrefs = element.SelectNodes("atrezzo/atrezzo-ref"), activesareas = element.SelectNodes("active-areas/active-area"), barriers = element.SelectNodes("barrier"), trajectorys = element.SelectNodes("trajectory"); string tmpArgVal; string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { sceneId = tmpArgVal; } tmpArgVal = element.GetAttribute("start"); if (!string.IsNullOrEmpty(tmpArgVal)) { initialScene = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("playerLayer"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerLayer = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("playerScale"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerScale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) { chapter.setTargetId(sceneId); } if (element.SelectSingleNode("name") != null) { scene.setName(element.SelectSingleNode("name").InnerText); } if (element.SelectSingleNode("documentation") != null) { scene.setDocumentation(element.SelectSingleNode("documentation").InnerText); } foreach (XmlElement el in resourcess) { currentResources = new ResourcesUni(); tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentResources.setName(el.GetAttribute(tmpArgVal)); } assets = el.SelectNodes("asset"); foreach (XmlElement ell in assets) { string type = ""; string path = ""; tmpArgVal = ell.GetAttribute("type"); if (!string.IsNullOrEmpty(tmpArgVal)) { type = tmpArgVal; } tmpArgVal = ell.GetAttribute("uri"); if (!string.IsNullOrEmpty(tmpArgVal)) { path = tmpArgVal; } currentResources.addAsset(type, path); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentResources.setConditions(currentConditions); } scene.addResources(currentResources); } foreach (XmlElement el in defaultsinitialsposition) { int x = int.MinValue, y = int.MinValue; tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } scene.setDefaultPosition(x, y); } foreach (XmlElement el in exits) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; tmpArgVal = el.GetAttribute("rectangular"); if (!string.IsNullOrEmpty(tmpArgVal)) { rectangular = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("destinyX"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("destinyY"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { notEffects = tmpArgVal.Equals("yes"); } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } exitslook = el.SelectNodes("exit-look"); foreach (XmlElement ell in exitslook) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; tmpArgVal = ell.GetAttribute("text"); if (!string.IsNullOrEmpty(tmpArgVal)) { text = tmpArgVal; } tmpArgVal = ell.GetAttribute("cursor-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { cursorPath = tmpArgVal; } tmpArgVal = ell.GetAttribute("sound-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { soundPath = tmpArgVal; } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } currentExit.setDefaultExitLook(currentExitLook); } if (el.SelectSingleNode("documentation") != null) { currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText); } points = el.SelectNodes("point"); foreach (XmlElement ell in points) { int x_ = 0; int y_ = 0; tmpArgVal = ell.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = ell.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } currentPoint = new Vector2(x_, y_); currentExit.addPoint(currentPoint); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentExit.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setEffects(currentEffects); } notseffect = el.SelectNodes("not-effect"); foreach (XmlElement ell in notseffect) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setNotEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in postseffects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setPostEffects(currentEffects); } if (currentExit.getNextScenes().Count > 0) { foreach (NextScene nextScene in currentExit.getNextScenes()) { Exit exit = (Exit)currentExit; exit.setNextScenes(new List <NextScene>()); exit.setDestinyX(nextScene.getPositionX()); exit.setDestinyY(nextScene.getPositionY()); exit.setEffects(nextScene.getEffects()); exit.setPostEffects(nextScene.getPostEffects()); if (exit.getDefaultExitLook() == null) { exit.setDefaultExitLook(nextScene.getExitLook()); } else { if (nextScene.getExitLook() != null) { if (nextScene.getExitLook().getExitText() != null && !nextScene.getExitLook().getExitText().Equals("")) { exit.getDefaultExitLook().setExitText(nextScene.getExitLook().getExitText()); } if (nextScene.getExitLook().getCursorPath() != null && !nextScene.getExitLook().getCursorPath().Equals("")) { exit.getDefaultExitLook().setCursorPath(nextScene.getExitLook().getCursorPath()); } } } exit.setHasNotEffects(false); exit.setConditions(nextScene.getConditions()); exit.setNextSceneId(nextScene.getTargetId()); scene.addExit(exit); } } else { scene.addExit(currentExit); } } foreach (XmlElement el in nextsscene) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); currentNextScene.setExitLook(currentExitLook); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentNextScene.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setPostEffects(currentEffects); } } foreach (XmlElement el in objectsrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } if (el.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addItemReference(currentElementReference); } foreach (XmlElement el in charactersrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } if (el.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addCharacterReference(currentElementReference); } foreach (XmlElement el in atrezzosrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } if (el.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addAtrezzoReference(currentElementReference); } foreach (XmlElement el in activesareas) { new ActiveAreaSubParser_(chapter, scene, scene.getActiveAreas().Count).ParseElement(el); } foreach (XmlElement el in barriers) { new BarrierSubParser_(chapter, scene, scene.getBarriers().Count).ParseElement(el); } foreach (XmlElement el in trajectorys) { new TrajectorySubParser_(chapter, scene).ParseElement(el); } if (scene != null) { TrajectoryFixer.fixTrajectory(scene); } chapter.addScene(scene); }
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); }
public void setExitLook(ExitLook exitLook) { look = exitLook; }
public SelectExitCursorPathTool(ExitLook exitLook) : base(createResources(exitLook), createAssetInfoArray(), Controller.EXIT, 0) { this.exitLook = exitLook; }
public override void ParseElement(XmlElement element) { XmlNodeList resourcess = element.SelectNodes("resources"), assets, conditions, effects, postseffects, notseffect, defaultsinitialsposition = element.SelectNodes("default-initial-position"), exits = element.SelectNodes("exits/exit"), exitslook, nextsscene = element.SelectNodes("next-scene"), points, objectsrefs = element.SelectNodes("objects/object-ref"), charactersrefs = element.SelectNodes("characters/character-ref"), atrezzosrefs = element.SelectNodes("atrezzo/atrezzo-ref"), activesareas = element.SelectNodes("active-areas/active-area"), barriers = element.SelectNodes("barrier"), trajectorys = element.SelectNodes("trajectory"); string tmpArgVal; string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { sceneId = tmpArgVal; } tmpArgVal = element.GetAttribute("start"); if (!string.IsNullOrEmpty(tmpArgVal)) { initialScene = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("playerLayer"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerLayer = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("playerScale"); if (!string.IsNullOrEmpty(tmpArgVal)) { playerScale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) chapter.setTargetId(sceneId); if (element.SelectSingleNode("name") != null) scene.setName(element.SelectSingleNode("name").InnerText); if (element.SelectSingleNode("documentation") != null) scene.setDocumentation(element.SelectSingleNode("documentation").InnerText); foreach (XmlElement el in resourcess) { currentResources = new ResourcesUni(); tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentResources.setName(el.GetAttribute(tmpArgVal)); } assets = el.SelectNodes("asset"); foreach (XmlElement ell in assets) { string type = ""; string path = ""; tmpArgVal = ell.GetAttribute("type"); if (!string.IsNullOrEmpty(tmpArgVal)) { type = tmpArgVal; } tmpArgVal = ell.GetAttribute("uri"); if (!string.IsNullOrEmpty(tmpArgVal)) { path = tmpArgVal; } currentResources.addAsset(type, path); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentResources.setConditions(currentConditions); } scene.addResources(currentResources); } foreach (XmlElement el in defaultsinitialsposition) { int x = int.MinValue, y = int.MinValue; tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } scene.setDefaultPosition(x, y); } foreach (XmlElement el in exits) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; tmpArgVal = el.GetAttribute("rectangular"); if (!string.IsNullOrEmpty(tmpArgVal)) { rectangular = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("destinyX"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("destinyY"); if (!string.IsNullOrEmpty(tmpArgVal)) { destinyY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { notEffects = tmpArgVal.Equals("yes"); } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } exitslook = el.SelectNodes("exit-look"); foreach (XmlElement ell in exitslook) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; tmpArgVal = ell.GetAttribute("text"); if (!string.IsNullOrEmpty(tmpArgVal)) { text = tmpArgVal; } tmpArgVal = ell.GetAttribute("cursor-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { cursorPath = tmpArgVal; } tmpArgVal = ell.GetAttribute("sound-path"); if (!string.IsNullOrEmpty(tmpArgVal)) { soundPath = tmpArgVal; } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } currentExit.setDefaultExitLook(currentExitLook); } if (el.SelectSingleNode("documentation") != null) currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText); points = el.SelectNodes("point"); foreach (XmlElement ell in points) { int x_ = 0; int y_ = 0; tmpArgVal = ell.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = ell.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } currentPoint = new Vector2(x_, y_); currentExit.addPoint(currentPoint); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentExit.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setEffects(currentEffects); } notseffect = el.SelectNodes("not-effect"); foreach (XmlElement ell in notseffect) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setNotEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in postseffects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentExit.setPostEffects(currentEffects); } if (currentExit.getNextScenes().Count > 0) { foreach (NextScene nextScene in currentExit.getNextScenes()) { Exit exit = (Exit) currentExit; exit.setNextScenes(new List<NextScene>()); exit.setDestinyX(nextScene.getPositionX()); exit.setDestinyY(nextScene.getPositionY()); exit.setEffects(nextScene.getEffects()); exit.setPostEffects(nextScene.getPostEffects()); if (exit.getDefaultExitLook() == null) exit.setDefaultExitLook(nextScene.getExitLook()); else { if (nextScene.getExitLook() != null) { if (nextScene.getExitLook().getExitText() != null && !nextScene.getExitLook().getExitText().Equals("")) exit.getDefaultExitLook().setExitText(nextScene.getExitLook().getExitText()); if (nextScene.getExitLook().getCursorPath() != null && !nextScene.getExitLook().getCursorPath().Equals("")) exit.getDefaultExitLook().setCursorPath(nextScene.getExitLook().getCursorPath()); } } exit.setHasNotEffects(false); exit.setConditions(nextScene.getConditions()); exit.setNextSceneId(nextScene.getTargetId()); scene.addExit(exit); } } else { scene.addExit(currentExit); } } foreach (XmlElement el in nextsscene) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionType"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionType = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("transitionTime"); if (!string.IsNullOrEmpty(tmpArgVal)) { transitionTime = int.Parse(tmpArgVal); } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType) transitionType); currentNextScene.setTransitionTime(transitionTime); currentNextScene.setExitLook(currentExitLook); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentNextScene.setConditions(currentConditions); } effects = el.SelectNodes("effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setEffects(currentEffects); } postseffects = el.SelectNodes("post-effect"); foreach (XmlElement ell in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(ell); currentNextScene.setPostEffects(currentEffects); } } foreach (XmlElement el in objectsrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); if (el.SelectSingleNode("documentation") != null) currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addItemReference(currentElementReference); } foreach (XmlElement el in charactersrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); if (el.SelectSingleNode("documentation") != null) currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addCharacterReference(currentElementReference); } foreach (XmlElement el in atrezzosrefs) { string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("scale"); if (!string.IsNullOrEmpty(tmpArgVal)) { scale = float.Parse(tmpArgVal, CultureInfo.InvariantCulture); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("layer"); if (!string.IsNullOrEmpty(tmpArgVal)) { layer = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); if (el.SelectSingleNode("documentation") != null) currentElementReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentElementReference.setConditions(currentConditions); } scene.addAtrezzoReference(currentElementReference); } foreach (XmlElement el in activesareas) { new ActiveAreaSubParser_(chapter, scene, scene.getActiveAreas().Count).ParseElement(el); } foreach (XmlElement el in barriers) { new BarrierSubParser_(chapter, scene, scene.getBarriers().Count).ParseElement(el); } foreach (XmlElement el in trajectorys) { new TrajectorySubParser_(chapter, scene).ParseElement(el); } if (scene != null) { TrajectoryFixer.fixTrajectory(scene); } chapter.addScene(scene); }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary <string, string> attrs) { Debug.Log("START: " + sName + " " + qName + " sub:" + subParsing + ", reading: " + reading); // If no element is being parsed if (subParsing == SUBPARSING_NONE) { // If it is a scene tag, create a new scene with its id if (qName.Equals("scene")) { string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("id")) { sceneId = entry.Value.ToString(); } if (entry.Key.Equals("start")) { initialScene = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("playerLayer")) { playerLayer = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("playerScale")) { playerScale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) { chapter.setTargetId(sceneId); } } // If it is a resources tag, create the new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("name")) { currentResources.setName(entry.Value.ToString()); } } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("type")) { type = entry.Value.ToString(); } if (entry.Key.Equals("uri")) { path = entry.Value.ToString(); } } currentResources.addAsset(type, path); } // If it is a default-initial-position tag, store it in the scene else if (qName.Equals("default-initial-position")) { int x = int.MinValue, y = int.MinValue; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } scene.setDefaultPosition(x, y); } // If it is an exit tag, create the new exit else if (qName.Equals("exit")) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("rectangular")) { rectangular = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("width")) { width = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("height")) { height = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("hasInfluenceArea")) { hasInfluence = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("influenceX")) { influenceX = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceY")) { influenceY = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceWidth")) { influenceWidth = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceHeight")) { influenceHeight = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("destinyX")) { destinyX = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("destinyY")) { destinyY = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("not-effects")) { notEffects = entry.Value.ToString().Equals("yes"); } } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } reading = READING_EXIT; } else if (qName.Equals("exit-look")) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("text")) { text = entry.Value.ToString(); } if (entry.Key.Equals("cursor-path")) { cursorPath = entry.Value.ToString(); } if (entry.Key.Equals("sound-path")) { soundPath = entry.Value.ToString(); } } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } // Debug.Log("311" + currentExitLook.getExitText()); } // If it is a next-scene tag, create the new next scene else if (qName.Equals("next-scene")) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionType")) { transitionType = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("transitionTime")) { transitionTime = int.Parse(entry.Value.ToString()); } } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); reading = READING_NEXT_SCENE; } else if (qName.Equals("point")) { int x = 0; int y = 0; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } } currentPoint = new Vector2(x, y); } // If it is a object-ref or character-ref, create the new element reference else if (qName.Equals("object-ref") || qName.Equals("character-ref") || qName.Equals("atrezzo-ref")) { Debug.Log("SceneReference Start"); string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; foreach (KeyValuePair <string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) { idTarget = entry.Value.ToString(); } if (entry.Key.Equals("x")) { x = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("y")) { y = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("scale")) { scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } if (entry.Key.Equals("layer")) { layer = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("hasInfluenceArea")) { hasInfluence = entry.Value.ToString().Equals("yes"); } if (entry.Key.Equals("influenceX")) { influenceX = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceY")) { influenceY = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceWidth")) { influenceWidth = int.Parse(entry.Value.ToString()); } if (entry.Key.Equals("influenceHeight")) { influenceHeight = int.Parse(entry.Value.ToString()); } } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) { layer = 0; } currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.setScale(scale); } reading = READING_ELEMENT_REFERENCE; } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("not-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("active-area")) { subParsing = SUBPARSING_ACTIVE_AREA; subParser = new ActiveAreaSubParser(chapter, scene, scene.getActiveAreas().Count); } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("barrier")) { subParsing = SUBPARSING_BARRIER; subParser = new BarrierSubParser(chapter, scene, scene.getBarriers().Count); } else if (qName.Equals("trajectory")) { subParsing = SUBPARSING_TRAJECTORY; subParser = new TrajectorySubParser(chapter, scene); } } // If it is subparsing an effect or condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
public InvalidExitCursorTool(ExitLook exitLook) { this.exitLook = exitLook; this.oldCursorPath = exitLook.getCursorPath(); }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.Attributes) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs) { Debug.Log("START: " + sName + " " + qName + " sub:" + subParsing + ", reading: " + reading); // If no element is being parsed if (subParsing == SUBPARSING_NONE) { // If it is a scene tag, create a new scene with its id if (qName.Equals("scene")) { string sceneId = ""; bool initialScene = false; int playerLayer = -1; float playerScale = 1.0f; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("id")) sceneId = entry.Value.ToString(); if (entry.Key.Equals("start")) initialScene = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("playerLayer")) playerLayer = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("playerScale")) playerScale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); } scene = new Scene(sceneId); scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) chapter.setTargetId(sceneId); } // If it is a resources tag, create the new resources else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("name")) currentResources.setName(entry.Value.ToString()); } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("type")) type = entry.Value.ToString(); if (entry.Key.Equals("uri")) path = entry.Value.ToString(); } currentResources.addAsset(type, path); } // If it is a default-initial-position tag, store it in the scene else if (qName.Equals("default-initial-position")) { int x = int.MinValue, y = int.MinValue; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); } scene.setDefaultPosition(x, y); } // If it is an exit tag, create the new exit else if (qName.Equals("exit")) { int x = 0, y = 0, width = 0, height = 0; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; string idTarget = ""; int destinyX = int.MinValue, destinyY = int.MinValue; int transitionType = 0, transitionTime = 0; bool notEffects = false; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("rectangular")) rectangular = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("width")) width = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("height")) height = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("hasInfluenceArea")) hasInfluence = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("influenceX")) influenceX = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceY")) influenceY = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceWidth")) influenceWidth = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceHeight")) influenceHeight = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("destinyX")) destinyX = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("destinyY")) destinyY = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionType")) transitionType = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionTime")) transitionTime = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("not-effects")) notEffects = entry.Value.ToString().Equals("yes"); } currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } reading = READING_EXIT; } else if (qName.Equals("exit-look")) { currentExitLook = new ExitLook(); string text = null; string cursorPath = null; string soundPath = null; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("text")) { text = entry.Value.ToString(); } if (entry.Key.Equals("cursor-path")) cursorPath = entry.Value.ToString(); if (entry.Key.Equals("sound-path")) soundPath = entry.Value.ToString(); } currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); if (soundPath != null) { currentExitLook.setSoundPath(soundPath); } // Debug.Log("311" + currentExitLook.getExitText()); } // If it is a next-scene tag, create the new next scene else if (qName.Equals("next-scene")) { string idTarget = ""; int x = int.MinValue, y = int.MinValue; int transitionType = 0, transitionTime = 0; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionType")) transitionType = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("transitionTime")) transitionTime = int.Parse(entry.Value.ToString()); } currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((NextSceneEnumTransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); reading = READING_NEXT_SCENE; } else if (qName.Equals("point")) { int x = 0; int y = 0; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); } currentPoint = new Vector2(x, y); } // If it is a object-ref or character-ref, create the new element reference else if (qName.Equals("object-ref") || qName.Equals("character-ref") || qName.Equals("atrezzo-ref")) { Debug.Log("SceneReference Start"); string idTarget = ""; int x = 0, y = 0; float scale = 0; int layer = 0; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) idTarget = entry.Value.ToString(); if (entry.Key.Equals("x")) x = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("y")) y = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("scale")) scale = float.Parse(entry.Value.ToString(), CultureInfo.InvariantCulture); if (entry.Key.Equals("layer")) layer = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("hasInfluenceArea")) hasInfluence = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("influenceX")) influenceX = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceY")) influenceY = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceWidth")) influenceWidth = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("influenceHeight")) influenceHeight = int.Parse(entry.Value.ToString()); } // This is for maintain the back-compatibility: in previous dtd versions layer has -1 as default value and this is // an erroneous value. This reason, if this value is -1, it will be changed to 0. Now in dtd there are not default value // for layer if (layer == -1) layer = 0; currentElementReference = new ElementReference(idTarget, x, y, layer); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) currentElementReference.setScale(scale); reading = READING_ELEMENT_REFERENCE; } // If it is a condition tag, create the new condition, the subparser and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("post-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("not-effect")) { currentEffects = new Effects(); subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("active-area")) { subParsing = SUBPARSING_ACTIVE_AREA; subParser = new ActiveAreaSubParser(chapter, scene, scene.getActiveAreas().Count); } // If it is a post-effect tag, create the new effect, the subparser and switch the state else if (qName.Equals("barrier")) { subParsing = SUBPARSING_BARRIER; subParser = new BarrierSubParser(chapter, scene, scene.getBarriers().Count); } else if (qName.Equals("trajectory")) { subParsing = SUBPARSING_TRAJECTORY; subParser = new TrajectorySubParser(chapter, scene); } } // If it is subparsing an effect or condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }