public override void ParseElement(XmlElement element) { XmlNodeList points = element.SelectNodes("point"), descriptionss = element.SelectNodes("description"), actionss = element.SelectNodes("actions"), conditions = element.SelectNodes("condition"); //, //effects = element.SelectNodes("effect"); string tmpArgVal; int x = 0, y = 0, width = 0, height = 0; string id = null; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = element.GetAttribute("rectangular"); if (!string.IsNullOrEmpty(tmpArgVal)) { rectangular = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { id = tmpArgVal; } tmpArgVal = element.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } 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 (element.SelectSingleNode("documentation") != null) activeArea.setDocumentation(element.SelectSingleNode("documentation").InnerText); descriptions = new List<Description>(); activeArea.setDescriptions(descriptions); foreach (XmlElement el in descriptionss) { description = new Description(); new DescriptionsSubParser_(description, chapter).ParseElement(el); this.descriptions.Add(description); } foreach (XmlElement el in points) { if (activeArea != null) { int x_ = 0, y_ = 0; tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } Vector2 point = new Vector2(x_, y_); activeArea.addVector2(point); } } foreach (XmlElement el in actionss) { new ActionsSubParser_(chapter, activeArea).ParseElement(el); } foreach (XmlElement el in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(el); this.activeArea.setConditions(currentConditions); } scene.addActiveArea(activeArea); }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#endElement(java.lang.string, java.lang.string, * java.lang.string) */ public override void endElement(string namespaceURI, string sName, string qName) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is an object tag, store the object in the game data if (qName.Equals("active-area")) { scene.addActiveArea(activeArea); } // If it is a documentation tag, hold the documentation in the current element else if (qName.Equals("documentation")) { activeArea.setDocumentation(currentstring.ToString().Trim()); } // Reset the current string currentstring = string.Empty; } // If a condition is being subparsed else if (subParsing == SUBPARSING_CONDITION) { // Spread the call subParser.endElement(namespaceURI, sName, qName); // If the condition tag is being closed if (qName.Equals("condition")) { if (reading == READING_NONE) { this.activeArea.setConditions(currentConditions); } // Switch state subParsing = SUBPARSING_NONE; } } // If an effect is being subparsed else if (subParsing == SUBPARSING_EFFECT) { // Spread the call subParser.endElement(namespaceURI, sName, qName); // If the effect tag is being closed, switch the state if (qName.Equals("effect")) { subParsing = SUBPARSING_NONE; } } else if (subParsing == SUBPARSING_ACTIONS) { subParser.endElement(namespaceURI, sName, qName); if (qName.Equals("actions")) { subParsing = SUBPARSING_NONE; } } // If it is a description tag, create the new description (with its id) else if (subParsing == SUBPARSING_DESCRIPTION) { // Spread the call subParser.endElement(namespaceURI, sName, qName); if (qName.Equals("description")) { this.descriptions.Add(description); subParsing = SUBPARSING_NONE; } } }
public override void ParseElement(XmlElement element) { XmlNodeList points = element.SelectNodes("point"), descriptionss = element.SelectNodes("description"), actionss = element.SelectNodes("actions"), conditions = element.SelectNodes("condition"); //, //effects = element.SelectNodes("effect"); string tmpArgVal; int x = 0, y = 0, width = 0, height = 0; string id = null; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = element.GetAttribute("rectangular"); if (!string.IsNullOrEmpty(tmpArgVal)) { rectangular = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { id = tmpArgVal; } tmpArgVal = element.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } 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 (element.SelectSingleNode("documentation") != null) { activeArea.setDocumentation(element.SelectSingleNode("documentation").InnerText); } descriptions = new List <Description>(); activeArea.setDescriptions(descriptions); foreach (XmlElement el in descriptionss) { description = new Description(); new DescriptionsSubParser_(description, chapter).ParseElement(el); this.descriptions.Add(description); } foreach (XmlElement el in points) { if (activeArea != null) { int x_ = 0, y_ = 0; tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } Vector2 point = new Vector2(x_, y_); activeArea.addVector2(point); } } foreach (XmlElement el in actionss) { new ActionsSubParser_(chapter, activeArea).ParseElement(el); } foreach (XmlElement el in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(el); this.activeArea.setConditions(currentConditions); } scene.addActiveArea(activeArea); }