5 using System.Collections.Generic;
6 using System.Globalization;
13 public string Name {
get;
private set;}
18 public TmxList<TmxObject>
Objects {
get;
private set;}
23 Name = (string)xObjectGroup.Attribute(
"name");
25 Opacity = (
double?)xObjectGroup.Attribute(
"opacity") ?? 1.0;
26 Visible = (
bool?)xObjectGroup.Attribute(
"visible") ??
true;
28 Objects =
new TmxList<TmxObject>();
29 foreach (var e
in xObjectGroup.Elements(
"object"))
39 public string Name {
get;
private set;}
41 public string Type {
get;
private set;}
42 public int X {
get;
private set;}
43 public int Y {
get;
private set;}
44 public int Width {
get;
private set;}
45 public int Height {
get;
private set;}
50 public List<Tuple<int,int>>
Points {
get;
private set;}
55 Name = (string)xObject.Attribute(
"name") ??
"";
56 Type = (string)xObject.Attribute(
"type");
57 X = (int)xObject.Attribute(
"x");
58 Y = (int)xObject.Attribute(
"y");
59 Visible = (
bool?)xObject.Attribute(
"visible") ??
true;
60 Width = (
int?)xObject.Attribute(
"width") ?? 0;
61 Height = (
int?)xObject.Attribute(
"height") ?? 0;
62 Rotation = (
double?)xObject.Attribute(
"rotation") ?? 0.0;
65 var xGid = xObject.Attribute(
"gid");
66 var xEllipse = xObject.Element(
"ellipse");
67 var xPolygon = xObject.Element(
"polygon");
68 var xPolyline = xObject.Element(
"polyline");
75 else if (xEllipse != null)
79 else if (xPolygon != null)
84 else if (xPolyline != null)
96 var points =
new List<Tuple<int, int>>();
98 var pointString = (string)xPoints.Attribute(
"points");
99 var pointStringPair = pointString.Split(
' ');
100 foreach (var s
in pointStringPair)
102 var pt = s.Split(
',');
103 var x = int.Parse(pt[0]);
104 var y = int.Parse(pt[1]);
105 points.Add(Tuple.Create<int,
int>(x, y));
PropertyDict Properties
User-defined object properties.
TmxObjectType ObjectType
Tiled object type.
int X
X (rightward) object position in pixels.
string Name
Object layer name.
string Type
User-defined object type.
int Y
Y (downward) object position in pixels.
TmxObjectGroup(XElement xObjectGroup)
Object layer constructor.
List< Tuple< int, int > > Points
List of (X,Y) object vertices in pixels.
int Height
Object height in pixels.
int Width
Object width in pixels.
Tile elements of a layer map.
bool Visible
True if object layer is visible.
TmxObject(XElement xObject)
Object constructor.
double Rotation
Clockwise rotation of object in degrees.
PropertyDict Properties
User-defined object layer properties.
TmxColor Color
Object layer elements color.
TmxObjectType
Tiled object type.
TmxList< TmxObject > Objects
List of objects in object layer.
User-defined property list.
double Opacity
Alpha transparency of object layer.
List< Tuple< int, int > > ParsePoints(XElement xPoints)
Parse vertex point string into (X,Y) coordinate pairs.
TmxLayerTile Tile
Object tile reference.
bool Visible
True if object is visible.