static TiledPolygonObject ParsePolygonObject(XmlNode node, TiledObject baseObj) { var obj = new TiledPolygonObject(baseObj); XmlNode polyXml; if (node["polygon"] != null) { polyXml = node["polygon"]; obj.Closed = true; } else { polyXml = node["polyline"]; obj.Closed = false; } var pointStrings = polyXml.Attributes["points"].Value.Split(' '); var points = new Vector2[pointStrings.Length]; for (var i = 0; i < points.Length; i += 1) { var vecStr = pointStrings[i].Split(','); points[i] = new Vector2( float.Parse(vecStr[0], CultureInfo.InvariantCulture), float.Parse(vecStr[1], CultureInfo.InvariantCulture) ); } obj.Points = points; return(obj); }
TiledObject ReadPolygonObject(ContentReader input, TiledObject baseObj) { var obj = new TiledPolygonObject(baseObj); obj.Closed = input.ReadBoolean(); obj.Points = input.ReadObject <Vector2[]>(); return(obj); }
void WritePolygonObject(ContentWriter output, TiledPolygonObject obj) { output.Write((byte)TiledObjectType.Polygon); output.Write(obj.Closed); output.WriteObject(obj.Points); }