Skip to content

Commit

Permalink
point object support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragath committed Sep 21, 2018
1 parent 54ba4ab commit 4c6e759
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 43 deletions.
10 changes: 10 additions & 0 deletions TiledLib/Objects/PointObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace TiledLib.Objects
{
public class PointObject : BaseObject
{
internal PointObject(Dictionary<string, string> properties) : base(properties) { }
public PointObject() : base(new Dictionary<string, string>()) { }
}
}
60 changes: 17 additions & 43 deletions TiledLib/TmxLayers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ public static BaseObject ReadObject(this XmlReader reader)
};
reader.Skip();
break;
case "point":
result = new PointObject(properties)
{
Id = id,
X = x,
Y = y,
Name = name,
ObjectType = type
};
reader.Skip();
break;
default:
throw new XmlException(reader.Name);
}
Expand Down Expand Up @@ -267,54 +278,17 @@ void HW()
writer.WritePoints(o.Polyline);
writer.WriteEndElement();
break;
case PointObject o:
writer.WriteProperties(entity.Properties);

writer.WriteStartElement("point");
writer.WriteEndElement();
break;
default:
throw new NotImplementedException();
}

writer.WriteEndElement();

// case "polygon":
// result = new PolygonObject(properties)
// {
// X = x,
// Y = y,
// Name = name,
// polygon = reader.ReadPoints().ToArray(),
// ObjectType = type
// };
// reader.Skip();
// break;
// case "polyline":
// result = new PolyLineObject(properties)
// {
// X = x,
// Y = y,
// Name = name,
// polyline = reader.ReadPoints().ToArray(),
// ObjectType = type
// };
// reader.Skip();
// break;
// default:
// throw new XmlException(reader.Name);
// }

// if (reader.Name == "object")
// reader.ReadEndElement();
// else
// throw new XmlException($"Expected </object>, found: {reader.Name}");
// }

// return result ?? new RectangleObject(properties)
// {
// X = x,
// Y = y,
// Width = w.Value,
// Height = h.Value,
// Name = name,
// ObjectType = type
// };
//}
}


Expand Down

0 comments on commit 4c6e759

Please sign in to comment.