public TmxObjectGroup(TmxMap map, XElement xObjectGroup) { Map = map; Name = (string)xObjectGroup.Attribute("name") ?? string.Empty; Color = TmxColor.ParseColor(xObjectGroup.Attribute("color")); Opacity = (float?)xObjectGroup.Attribute("opacity") ?? 1.0f; Visible = (bool?)xObjectGroup.Attribute("visible") ?? true; OffsetX = (float?)xObjectGroup.Attribute("offsetx") ?? 0.0f; OffsetY = (float?)xObjectGroup.Attribute("offsety") ?? 0.0f; var drawOrderDict = new Dictionary <string, DrawOrderType> { { "unknown", DrawOrderType.UnknownOrder }, { "topdown", DrawOrderType.IndexOrder }, { "index", DrawOrderType.TopDown } }; var drawOrderValue = (string)xObjectGroup.Attribute("draworder"); if (drawOrderValue != null) { DrawOrder = drawOrderDict[drawOrderValue]; } Objects = new TmxList <TmxObject>(); foreach (var e in xObjectGroup.Elements("object")) { Objects.Add(new TmxObject(map, e)); } Properties = PropertyDict.ParsePropertyDict(xObjectGroup.Element("properties")); }
public TmxImage(XElement xImage, string tmxDir = "") { var xSource = xImage.Attribute("source"); if (xSource != null) { // Append directory if present Source = Path.Combine(tmxDir, (string)xSource); using (var stream = TitleContainer.OpenStream(Source)) Texture = Texture2D.FromStream(Core.GraphicsDevice, stream); } else { Format = (string)xImage.Attribute("format"); var xData = xImage.Element("data"); var decodedStream = new TmxBase64Data(xData); Data = decodedStream.Data; throw new NotSupportedException("Stream Data loading is not yet supported"); } Trans = TmxColor.ParseColor(xImage.Attribute("trans")); Width = (int?)xImage.Attribute("width") ?? 0; Height = (int?)xImage.Attribute("height") ?? 0; }
public TmxText(XElement xText) { FontFamily = (string)xText.Attribute("fontfamily") ?? "sans-serif"; PixelSize = (int?)xText.Attribute("pixelsize") ?? 16; Wrap = (bool?)xText.Attribute("wrap") ?? false; Color = TmxColor.ParseColor(xText.Attribute("color")); Bold = (bool?)xText.Attribute("bold") ?? false; Italic = (bool?)xText.Attribute("italic") ?? false; Underline = (bool?)xText.Attribute("underline") ?? false; Strikeout = (bool?)xText.Attribute("strikeout") ?? false; Kerning = (bool?)xText.Attribute("kerning") ?? true; Alignment = new TmxAlignment(xText.Attribute("halign"), xText.Attribute("valign")); Value = xText.Value; }