コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: TiledMapReader.cs プロジェクト: mepurubun/Monofoxe
        TiledObject ReadPolygonObject(ContentReader input, TiledObject baseObj)
        {
            var obj = new TiledPolygonObject(baseObj);

            obj.Closed = input.ReadBoolean();
            obj.Points = input.ReadObject <Vector2[]>();

            return(obj);
        }
コード例 #3
0
 void WritePolygonObject(ContentWriter output, TiledPolygonObject obj)
 {
     output.Write((byte)TiledObjectType.Polygon);
     output.Write(obj.Closed);
     output.WriteObject(obj.Points);
 }