/** * 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.destinyScale = float.MinValue; 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(); }
/** * Creates a new ElementReference * * @param idTarget * the id of the element that is referenced * @param x * the horizontal position of the element * @param y * the vertical position of the element * @param layer * the position where this element reference will be paint */ public ElementReference(string idTarget, int x, int y, int layer) : base(idTarget) { this.x = x; this.y = y; this.layer = layer; influenceArea = new InfluenceArea(); }
public object DOMParse(XmlElement element, params object[] parameters) { XmlNodeList points = element.SelectNodes("point"), descriptions = element.SelectNodes("description"); XmlElement conditions = element.SelectSingleNode("condition") as XmlElement, actionss = element.SelectSingleNode("actions") as XmlElement, documentation = element.SelectSingleNode("documentation") as XmlElement; string id = element.GetAttribute("id") ?? null; bool rectangular = (element.GetAttribute("rectangular") ?? "yes").Equals("yes"); int x = ExParsers.ParseDefault(element.GetAttribute("x"), 0), y = ExParsers.ParseDefault(element.GetAttribute("y"), 0), width = ExParsers.ParseDefault(element.GetAttribute("width"), 0), height = ExParsers.ParseDefault(element.GetAttribute("height"), 0); bool hasInfluence = "yes".Equals(element.GetAttribute("hasInfluenceArea")); int influenceX = ExParsers.ParseDefault(element.GetAttribute("influenceX"), 0), influenceY = ExParsers.ParseDefault(element.GetAttribute("influenceY"), 0), influenceWidth = ExParsers.ParseDefault(element.GetAttribute("influenceWidth"), 0), influenceHeight = ExParsers.ParseDefault(element.GetAttribute("influenceHeight"), 0); ActiveArea activeArea = new ActiveArea((id == null ? generateId() : id), rectangular, x, y, width, height); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); activeArea.setInfluenceArea(influenceArea); } if (documentation != null) { activeArea.setDocumentation(documentation.InnerText); } activeArea.setDescriptions(DOMParserUtility.DOMParse <Description> (descriptions, parameters).ToList()); foreach (XmlElement el in points) { if (activeArea != null) { activeArea.addVector2( new Vector2(ExParsers.ParseDefault(el.GetAttribute("x"), 0), ExParsers.ParseDefault(el.GetAttribute("y"), 0))); } } if (actionss != null) { activeArea.setActions(DOMParserUtility.DOMParse <Action>(actionss.ChildNodes, parameters).ToList()); } if (conditions != null) { activeArea.setConditions(DOMParserUtility.DOMParse(conditions, parameters) as Conditions ?? new Conditions()); } return(activeArea); }
public object Clone() { InfluenceArea ia = (InfluenceArea)this.MemberwiseClone(); ia.exists = exists; ia.height = height; ia.width = width; ia.x = x; ia.y = y; return(ia); }
/** * Creates a new ElementReference * * @param idTarget * the id of the element that is referenced * @param x * the horizontal position of the element * @param y * the vertical position of the element * @param layer * the position where this element reference will be paint */ public ElementReference(string idTarget, int x, int y, int layer) { this.idTarget = idTarget; this.x = x; this.y = y; this.scale = 1; this.layer = layer; documentation = null; conditions = new Conditions(); influenceArea = new InfluenceArea(); }
/** * Creates a new Exit * * @param rectangular * * @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 ActiveArea(string id, bool rectangular, int x, int y, int width, int height) : base(id) { this.rectangular = rectangular; this.x = x; this.y = y; this.width = width; this.height = height; Vector2s = new List <Vector2>(); conditions = new Conditions(); influenceArea = new InfluenceArea(); }
/** * Creates a new ElementReference * * @param idTarget * the id of the element that is referenced * @param x * the horizontal position of the element * @param y * the vertical position of the element */ public ElementReference(string idTarget, int x, int y) { this.idTarget = idTarget; this.x = x; this.y = y; this.scale = 1; this.layer = -1; documentation = null; conditions = new Conditions(); influenceArea = new InfluenceArea(); orientation = Runner.Orientation.S; }
private ElementReference parseElementReference(XmlElement element, params object[] parameters) { string idTarget = element.GetAttribute("idTarget") ?? ""; int x = ExParsers.ParseDefault(element.GetAttribute("x"), 0), y = ExParsers.ParseDefault(element.GetAttribute("y"), 0); float scale = ExParsers.ParseDefault(element.GetAttribute("scale"), NumberFormatInfo.CurrentInfo, 0f); int layer = ExParsers.ParseDefault(element.GetAttribute("layer"), 0); int influenceX = ExParsers.ParseDefault(element.GetAttribute("influenceX"), 0), influenceY = ExParsers.ParseDefault(element.GetAttribute("influenceY"), 0), influenceWidth = ExParsers.ParseDefault(element.GetAttribute("influenceWidth"), 0), influenceHeight = ExParsers.ParseDefault(element.GetAttribute("influenceHeight"), 0); bool hasInfluence = "yes".Equals(element.GetAttribute("hasInfluenceArea")); // 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; } var 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 (element.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(element.SelectSingleNode("documentation").InnerText); } currentElementReference.setConditions(DOMParserUtility.DOMParse(element.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions()); return(currentElementReference); }
private ElementReference parseElementReference(XmlElement element, params object[] parameters) { string idTarget = element.GetAttribute("idTarget"); int x = ExParsers.ParseDefault(element.GetAttribute("x"), 0), y = ExParsers.ParseDefault(element.GetAttribute("y"), 0); Orientation orientation = (Orientation)ExParsers.ParseDefault(element.GetAttribute("orientation"), 2); float scale = ExParsers.ParseDefault(element.GetAttribute("scale"), CultureInfo.InvariantCulture, 0f); int layer = ExParsers.ParseDefault(element.GetAttribute("layer"), -1); int influenceX = ExParsers.ParseDefault(element.GetAttribute("influenceX"), 0), influenceY = ExParsers.ParseDefault(element.GetAttribute("influenceY"), 0), influenceWidth = ExParsers.ParseDefault(element.GetAttribute("influenceWidth"), 0), influenceHeight = ExParsers.ParseDefault(element.GetAttribute("influenceHeight"), 0); bool hasInfluence = ExString.EqualsDefault(element.GetAttribute("hasInfluenceArea"), "yes", false); var currentElementReference = new ElementReference(idTarget, x, y, layer); currentElementReference.Orientation = orientation; if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentElementReference.setInfluenceArea(influenceArea); } if (scale > 0.001 || scale < -0.001) { currentElementReference.Scale = scale; } if (element.SelectSingleNode("documentation") != null) { currentElementReference.setDocumentation(element.SelectSingleNode("documentation").InnerText); } currentElementReference.Conditions = DOMParserUtility.DOMParse(element.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions(); return(currentElementReference); }
public object DOMParse(XmlElement element, params object[] parameters) { var chapter = parameters [0] as Chapter; string sceneId = element.GetAttribute("id"); bool initialScene = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false); bool hideInventory = ExString.EqualsDefault(element.GetAttribute("hideInventory"), "yes", false); int playerLayer = ExParsers.ParseDefault(element.GetAttribute("playerLayer"), -1); float playerScale = ExParsers.ParseDefault(element.GetAttribute("playerScale"), CultureInfo.InvariantCulture, 1.0f); scene = new Scene(sceneId) { HideInventory = hideInventory }; scene.setPlayerLayer(playerLayer); scene.setPlayerScale(playerScale); if (initialScene) { chapter.setTargetId(sceneId); } var name = element.SelectSingleNode("name"); if (name != null) { scene.setName(name.InnerText); } var documentation = element.SelectSingleNode("documentation"); if (documentation != null) { scene.setDocumentation(documentation.InnerText); } //XAPI ELEMENTS scene.setXApiClass(element.GetAttribute("class")); scene.setXApiType(element.GetAttribute("type")); //END OF XAPI foreach (var res in DOMParserUtility.DOMParse <ResourcesUni> (element.SelectNodes("resources"), parameters)) { scene.addResources(res); } var defaultsinitialsposition = element.SelectSingleNode("default-initial-position") as XmlElement; if (defaultsinitialsposition != null) { int x = ExParsers.ParseDefault(defaultsinitialsposition.GetAttribute("x"), int.MinValue), y = ExParsers.ParseDefault(defaultsinitialsposition.GetAttribute("y"), int.MinValue); scene.setDefaultPosition(x, y); } foreach (XmlElement el in element.SelectNodes("exits/exit")) { int x = ExParsers.ParseDefault(el.GetAttribute("x"), 0), y = ExParsers.ParseDefault(el.GetAttribute("y"), 0), width = ExParsers.ParseDefault(el.GetAttribute("width"), 0), height = ExParsers.ParseDefault(el.GetAttribute("height"), 0); bool rectangular = ExString.EqualsDefault(el.GetAttribute("rectangular"), "yes", true); bool hasInfluence = ExString.EqualsDefault(el.GetAttribute("hasInfluenceArea"), "yes", false); int influenceX = ExParsers.ParseDefault(el.GetAttribute("influenceX"), 0), influenceY = ExParsers.ParseDefault(el.GetAttribute("influenceY"), 0), influenceWidth = ExParsers.ParseDefault(el.GetAttribute("influenceWidth"), 0), influenceHeight = ExParsers.ParseDefault(el.GetAttribute("influenceHeight"), 0); string idTarget = el.GetAttribute("idTarget"); int destinyX = ExParsers.ParseDefault(el.GetAttribute("destinyX"), int.MinValue), destinyY = ExParsers.ParseDefault(el.GetAttribute("destinyY"), int.MinValue); float destinyScale = ExParsers.ParseDefault(el.GetAttribute("destinyScale"), CultureInfo.InvariantCulture, float.MinValue); int transitionType = ExParsers.ParseDefault(el.GetAttribute("transitionType"), 0), transitionTime = ExParsers.ParseDefault(el.GetAttribute("transitionTime"), 0); bool notEffects = ExString.EqualsDefault(el.GetAttribute("not-effects"), "yes", false); currentExit = new Exit(rectangular, x, y, width, height); currentExit.setNextSceneId(idTarget); currentExit.setDestinyX(destinyX); currentExit.setDestinyY(destinyY); currentExit.setDestinyScale(destinyScale); currentExit.setTransitionTime(transitionTime); currentExit.setTransitionType(transitionType); currentExit.setHasNotEffects(notEffects); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); currentExit.setInfluenceArea(influenceArea); } foreach (XmlElement ell in el.SelectNodes("exit-look")) { currentExitLook = new ExitLook(); string text = ell.GetAttribute("text"); string cursorPath = ell.GetAttribute("cursor-path"); string soundPath = ell.GetAttribute("sound-path"); currentExitLook.setCursorPath(cursorPath); currentExitLook.setExitText(text); currentExitLook.setSoundPath(soundPath); currentExit.setDefaultExitLook(currentExitLook); } if (el.SelectSingleNode("documentation") != null) { currentExit.setDocumentation(el.SelectSingleNode("documentation").InnerText); } foreach (XmlElement ell in el.SelectNodes("point")) { currentPoint = new Vector2( ExParsers.ParseDefault(ell.GetAttribute("x"), 0), ExParsers.ParseDefault(ell.GetAttribute("y"), 0)); currentExit.addPoint(currentPoint); } currentExit.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions()); currentExit.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters) as Effects ?? new Effects()); currentExit.setNotEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("not-effect"), parameters) as Effects ?? new Effects()); currentExit.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects()); if (currentExit.getNextScenes().Count > 0) { foreach (NextScene nextScene in currentExit.getNextScenes()) { Exit exit = (Exit)currentExit; exit.setNextScenes(new List <NextScene>()); exit.setDestinyX(nextScene.getPositionX()); exit.setDestinyY(nextScene.getPositionY()); exit.setEffects(nextScene.getEffects()); exit.setPostEffects(nextScene.getPostEffects()); if (exit.getDefaultExitLook() == null) { exit.setDefaultExitLook(nextScene.getExitLook()); } else { if (nextScene.getExitLook() != null) { if (nextScene.getExitLook().getExitText() != null && !nextScene.getExitLook().getExitText().Equals("")) { exit.getDefaultExitLook().setExitText(nextScene.getExitLook().getExitText()); } if (nextScene.getExitLook().getCursorPath() != null && !nextScene.getExitLook().getCursorPath().Equals("")) { exit.getDefaultExitLook().setCursorPath(nextScene.getExitLook().getCursorPath()); } } } exit.setHasNotEffects(false); exit.setConditions(nextScene.getConditions()); exit.setNextSceneId(nextScene.getTargetId()); scene.addExit(exit); } } else { scene.addExit(currentExit); } } foreach (XmlElement el in element.SelectNodes("next-scene")) { string idTarget = el.GetAttribute("idTarget"); int x = ExParsers.ParseDefault(el.GetAttribute("x"), int.MinValue), y = ExParsers.ParseDefault(el.GetAttribute("y"), int.MinValue), transitionType = ExParsers.ParseDefault(el.GetAttribute("transitionType"), 0), transitionTime = ExParsers.ParseDefault(el.GetAttribute("transitionTime"), 0); currentNextScene = new NextScene(idTarget, x, y); currentNextScene.setTransitionType((TransitionType)transitionType); currentNextScene.setTransitionTime(transitionTime); currentNextScene.setExitLook(currentExitLook); currentNextScene.setConditions(DOMParserUtility.DOMParse(el.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions()); currentNextScene.setEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("effect"), parameters) as Effects ?? new Effects()); currentNextScene.setPostEffects(DOMParserUtility.DOMParse(el.SelectSingleNode("post-effect"), parameters) as Effects ?? new Effects()); } foreach (XmlElement el in element.SelectNodes("objects/object-ref")) { currentElementReference = parseElementReference(el, parameters); scene.addItemReference(currentElementReference); } foreach (XmlElement el in element.SelectNodes("characters/character-ref")) { currentElementReference = parseElementReference(el, parameters); scene.addCharacterReference(currentElementReference); } foreach (XmlElement el in element.SelectNodes("atrezzo/atrezzo-ref")) { currentElementReference = parseElementReference(el, parameters); scene.addAtrezzoReference(currentElementReference); } foreach (var activeArea in DOMParserUtility.DOMParse <ActiveArea>(element.SelectNodes("active-areas/active-area"), parameters).ToList()) { scene.addActiveArea(activeArea); } foreach (var barrier in DOMParserUtility.DOMParse <Barrier>(element.SelectNodes("barriers/barrier"), parameters).ToList()) { scene.addBarrier(barrier); } foreach (var trajectory in DOMParserUtility.DOMParse <Trajectory>(element.SelectNodes("trajectory"), parameters).ToList()) { scene.setTrajectory(trajectory); } if (scene != null) { TrajectoryFixer.fixTrajectory(scene); } return(scene); }
/** * @param influenceArea * the influenceArea to set */ public void setInfluenceArea(InfluenceArea influenceArea) { this.influenceArea = influenceArea; }
public object DOMParse(XmlElement element, params object[] parameters) { XmlNodeList points = element.SelectNodes("point"), descriptions = element.SelectNodes("description"); XmlElement conditions = element.SelectSingleNode("condition") as XmlElement, actions = element.SelectSingleNode("actions") as XmlElement, documentation = element.SelectSingleNode("documentation") as XmlElement; string id = ExString.Default(element.GetAttribute("id"), null); bool rectangular = ExString.EqualsDefault(element.GetAttribute("rectangular"), "yes", true); int x = ExParsers.ParseDefault(element.GetAttribute("x"), 0), y = ExParsers.ParseDefault(element.GetAttribute("y"), 0), width = ExParsers.ParseDefault(element.GetAttribute("width"), 0), height = ExParsers.ParseDefault(element.GetAttribute("height"), 0); bool hasInfluence = ExString.EqualsDefault(element.GetAttribute("hasInfluenceArea"), "yes", false); int influenceX = ExParsers.ParseDefault(element.GetAttribute("influenceX"), 0), influenceY = ExParsers.ParseDefault(element.GetAttribute("influenceY"), 0), influenceWidth = ExParsers.ParseDefault(element.GetAttribute("influenceWidth"), 0), influenceHeight = ExParsers.ParseDefault(element.GetAttribute("influenceHeight"), 0); var activeArea = new ActiveArea((id ?? generateId()), rectangular, x, y, width, height); switch (element.GetAttribute("behaviour")) { case "atrezzo": activeArea.setBehaviour(Item.BehaviourType.ATREZZO); break; case "first-action": activeArea.setBehaviour(Item.BehaviourType.FIRST_ACTION); break; default: activeArea.setBehaviour(Item.BehaviourType.NORMAL); break; } if (hasInfluence) { var influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); activeArea.setInfluenceArea(influenceArea); } if (documentation != null) { activeArea.setDocumentation(documentation.InnerText); } activeArea.setDescriptions(DOMParserUtility.DOMParse <Description> (descriptions, parameters).ToList()); foreach (XmlElement el in points) { activeArea.addVector2( new Vector2(ExParsers.ParseDefault(el.GetAttribute("x"), 0), ExParsers.ParseDefault(el.GetAttribute("y"), 0))); } if (actions != null) { activeArea.setActions(DOMParserUtility.DOMParse <Action>(actions.ChildNodes, parameters).ToList()); } if (conditions != null) { activeArea.setConditions(DOMParserUtility.DOMParse(conditions, parameters) as Conditions ?? new Conditions()); } return(activeArea); }