public object DOMParse(XmlElement element, params object[] parameters) { var mapScene = new MapScene(element.Attributes["id"].Value); var chapter = parameters[0] as Chapter; mapScene.CameraType = ExParsers.ParseEnum <CameraType>(ExString.Default(element.GetAttribute("cameraType"), CameraType.Aerial2D.ToString())); mapScene.RenderStyle = ExParsers.ParseEnum <RenderStyle>(ExString.Default(element.GetAttribute("renderStyle"), RenderStyle.Tile.ToString())); mapScene.TileMetaIdentifier = ExString.Default(element.GetAttribute("tileMetaIdentifier"), "OSMTile"); mapScene.UsesGameplayArea = ExString.EqualsDefault(element.GetAttribute("usesGameplayArea"), "yes", false); mapScene.GameplayArea = ExParsers.ParseDefault(element.GetAttribute("gameplayArea"), new RectD(Vector2d.zero, Vector2d.zero)); mapScene.LatLon = ExParsers.ParseDefault(element.GetAttribute("center"), Vector2d.zero); mapScene.Zoom = ExParsers.ParseDefault(element.GetAttribute("zoom"), 19); bool initialScene = ExString.EqualsDefault(element.GetAttribute("start"), "yes", false); if (initialScene) { chapter.setTargetId(mapScene.getId()); } int layer = 0; foreach (var e in element.SelectNodes("map-element")) { var mapElementNode = e as XmlElement; MapElement mapElement = null; XmlElement extElemNode; var targetId = mapElementNode.GetAttribute("targetId"); if ((extElemNode = (XmlElement)mapElementNode.SelectSingleNode("ext-elem-ref")) != null) { var extElem = new ExtElemReference(targetId); mapElement = extElem; extElem.TransformManagerDescriptor = GetDescriptor(ExString.Default(extElemNode.GetAttribute("transformManager"), typeof(GeopositionedDescriptor).FullName)); foreach (var param in extElem.TransformManagerDescriptor.ParameterDescription) { var paramNode = extElemNode.SelectSingleNode("param[@name=\"" + param.Key + "\"]"); if (paramNode != null) { extElem.TransformManagerParameters.Add(param.Key, parseParam(param.Value.Type, paramNode.InnerText)); } } } else { mapElement = new GeoReference(targetId); } mapElement.Conditions = DOMParserUtility.DOMParse <Conditions>(mapElementNode.SelectSingleNode("condition") as XmlElement, parameters); mapElement.Layer = ExParsers.ParseDefault(mapElementNode.GetAttribute("layer"), layer); mapElement.Scale = ExParsers.ParseDefault(mapElementNode.GetAttribute("scale"), 1f); mapElement.Orientation = (Orientation)ExParsers.ParseDefault(mapElementNode.GetAttribute("orientation"), 2); layer = Mathf.Max(mapElement.Layer, layer) + 1; mapScene.Elements.Add(mapElement); } return(mapScene); }
public object DOMParse(XmlElement element, params object[] parameters) { var mapScene = new MapScene(element.Attributes["id"].Value); var chapter = parameters[0] as Chapter; mapScene.CameraType = element.Attributes["cameraType"].Value.ToEnum <CameraType>(); var tmpArgVal = element.GetAttribute("start"); if (!string.IsNullOrEmpty(tmpArgVal)) { if (tmpArgVal.Equals("yes")) { chapter.setTargetId(mapScene.getId()); } } tmpArgVal = element.GetAttribute("center"); if (!string.IsNullOrEmpty(tmpArgVal)) { mapScene.LatLon = (Vector2d)parseParam(typeof(Vector2d), tmpArgVal); } foreach (var e in element.SelectNodes("map-element")) { var mapElementNode = e as XmlElement; MapElement mapElement = null; XmlElement extElemNode; if ((extElemNode = (XmlElement)mapElementNode.SelectSingleNode("ext-elem-ref")) != null) { var extElem = new ExtElemReference(mapElementNode.Attributes["targetId"].Value); mapElement = extElem; extElem.TransformManagerDescriptor = GetDescriptor(extElemNode.Attributes["transformManager"].Value); foreach (var param in extElem.TransformManagerDescriptor.ParameterDescription) { var paramNode = extElemNode.SelectSingleNode("param[@name=\"" + param.Key + "\"]"); if (paramNode != null) { extElem.TransformManagerParameters.Add(param.Key, parseParam(param.Value.Type, paramNode.InnerText)); } } } else { mapElement = new GeoReference(mapElementNode.Attributes["targetId"].Value); } mapElement.Conditions = (Conditions)DOMParserUtility.DOMParse(mapElementNode.SelectSingleNode("condition") as XmlElement, parameters); mapElement.Layer = int.Parse(mapElementNode.Attributes["layer"].Value); mapScene.Elements.Add(mapElement); } return(mapScene); }
public object DOMParse(XmlElement element, params object[] parameters) { var qr = new QR(element.Attributes["id"].Value) { Content = element.SelectSingleNode("content").InnerText, Documentation = element.SelectSingleNode("documentation").InnerText }; qr.Conditions = DOMParserUtility.DOMParse(element.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions(); qr.Effects = DOMParserUtility.DOMParse(element.SelectSingleNode("effect"), parameters) as Effects ?? new Effects(); return(qr); }
public object DOMParse(XmlElement element, params object[] parameters) { GeoElement parsed = new GeoElement(element.Attributes["id"].Value); var oldDescriptionSystem = new Description(); parsed.Descriptions = new List <Description> (); foreach (var child in element.ChildNodes) { var node = child as XmlNode; switch (node.Name) { case "description": parsed.Descriptions.Add(DOMParserUtility.DOMParse <Description>(node, parameters)); break; case "name": oldDescriptionSystem.setName(node.InnerText); break; case "brief-description": oldDescriptionSystem.setDescription(node.InnerText); break; case "detailed-description": oldDescriptionSystem.setDetailedDescription(node.InnerText); break; case "geometries": parsed.Geometries = DOMParserUtility.DOMParse <GMLGeometry>(node.ChildNodes, parameters).DefaultIfEmpty(new GMLGeometry()).ToList(); break; case "geometry": parsed.Geometries = new List <GMLGeometry> { DOMParserUtility.DOMParse <GMLGeometry>(node, parameters) }; break; case "actions": parsed.Actions = ParseActions(node, parameters); break; case "resources": parsed.Resources = DOMParserUtility .DOMParse <ResourcesUni>(element.SelectNodes("resources"), parameters).DefaultIfEmpty(new ResourcesUni()).ToList(); break; } } if (parsed.Descriptions.Count == 0) { parsed.Descriptions.Add(oldDescriptionSystem); } return(parsed); }
private Completable.Milestone parseMilestone(XmlElement element, params object[] parameters) { Completable.Milestone milestone = new Completable.Milestone(); string tmpString = ""; tmpString = element.GetAttribute("type"); if (!string.IsNullOrEmpty(tmpString)) { milestone.setType(ParseEnum <Completable.Milestone.MilestoneType>(tmpString)); } if (milestone.getType() != Completable.Milestone.MilestoneType.CONDITION) { tmpString = element.GetAttribute("targetId"); if (!string.IsNullOrEmpty(tmpString)) { milestone.setId(tmpString); } } else { XmlElement c = (XmlElement)element.SelectSingleNode("condition"); if (c != null) { milestone.setConditions(DOMParserUtility.DOMParse(c, parameters) as Conditions ?? new Conditions()); } } tmpString = element.GetAttribute("progress"); if (!string.IsNullOrEmpty(tmpString)) { milestone.setProgress(float.Parse(tmpString)); } return(milestone); }
private List <GeoAction> ParseActions(XmlNode node, params object[] parameters) { return(DOMParserUtility.DOMParse <GeoAction>(node.ChildNodes, parameters) as List <GeoAction>); }
private void ParseBasic(XmlElement element, GeoAction action, params object[] parameters) { action.Conditions = DOMParserUtility.DOMParse(element.SelectSingleNode("condition"), parameters) as Conditions ?? new Conditions(); action.Effects = DOMParserUtility.DOMParse(element.SelectSingleNode("effect"), parameters) as Effects ?? new Effects(); }