public void FromXml(XmlReader r) { for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read if (r.Name == "modelName") { modelName = r.Value; } if (r.Name == "type") { type = r.Value; } if (r.Name == "firstTerrainIndex") { firstTerrainIndex = int.Parse(r.Value); } } r.MoveToElement(); //Moves the reader back to the element node. while (r.Read()) { if (r.NodeType == XmlNodeType.Whitespace) { continue; } // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "BoundingPolygon": List <PathPolygon> polys = ReadPolygons(r); Debug.Assert(polys.Count == 1, "In PathObject.FromXml, must have exactly one polygon in BoundingPolygon list!"); boundingPolygon = polys[0]; break; case "PathPolygons": polygons = ReadPolygons(r); break; case "PathPortals": portals = ReadArcs(r); break; case "PathArcs": arcs = ReadArcs(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } }
public void ToXml(XmlWriter w) { w.WriteStartElement("PathPolygon"); w.WriteAttributeString("kind", PathPolygon.PolygonKindToString(kind)); w.WriteAttributeString("index", index.ToString()); foreach (Vector3 corner in corners) { XmlHelperClass.WriteVectorElement(w, "Corner", corner); } w.WriteEndElement(); }
public PathObject(string modelName, string type, int firstTerrainIndex, PathPolygon boundingPolygon, List <PathPolygon> polygons, List <PathArc> portals, List <PathArc> arcs) { this.modelName = modelName; this.type = type; this.firstTerrainIndex = firstTerrainIndex; this.boundingPolygon = boundingPolygon; this.polygons = polygons; this.portals = portals; this.arcs = arcs; }
public void FromXml(XmlReader r) { for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read if (r.Name == "modelName") modelName = r.Value; if (r.Name == "type") type = r.Value; if (r.Name == "firstTerrainIndex") firstTerrainIndex = int.Parse(r.Value); } r.MoveToElement(); //Moves the reader back to the element node. while (r.Read()) { if (r.NodeType == XmlNodeType.Whitespace) { continue; } // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "BoundingPolygon": List<PathPolygon> polys = ReadPolygons(r); Debug.Assert(polys.Count == 1, "In PathObject.FromXml, must have exactly one polygon in BoundingPolygon list!"); boundingPolygon = polys[0]; break; case "PathPolygons": polygons = ReadPolygons(r); break; case "PathPortals": portals = ReadArcs(r); break; case "PathArcs": arcs = ReadArcs(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } }
public PathObject(string modelName, string type, int firstTerrainIndex, PathPolygon boundingPolygon, List<PathPolygon> polygons, List<PathArc> portals, List<PathArc> arcs) { this.modelName = modelName; this.type = type; this.firstTerrainIndex = firstTerrainIndex; this.boundingPolygon = boundingPolygon; this.polygons = polygons; this.portals = portals; this.arcs = arcs; }