private void ParseImageLayerXml(XElement xml) { if (xml.Element("image") == null) { Logger.WriteWarning("Image Layer '{0}' is being ignored since it has no image.", base.Name); base.Ignore = IgnoreSettings.True; } else { Width = 1; Height = 1; string imagePath = TmxHelper.GetAttributeAsFullPath(xml.Element("image"), "source"); TmxTile value = base.ParentMap.Tiles.First((KeyValuePair <uint, TmxTile> t) => t.Value.TmxImage.AbsolutePath.ToLower() == imagePath.ToLower()).Value; Data = new TmxData(this); TmxChunk tmxChunk = new TmxChunk(Data); tmxChunk.X = 0; tmxChunk.Y = 0; tmxChunk.Width = 1; tmxChunk.Height = 1; tmxChunk.TileIds.Add(value.GlobalId); Data.Chunks.Add(tmxChunk); PointF offset = base.Offset; offset.Y -= (float)base.ParentMap.TileHeight; offset.Y += (float)value.TmxImage.Size.Height; PointF pointF = TmxMath.TileCornerInScreenCoordinates(base.ParentMap, 0, 0); offset.X -= pointF.X; offset.Y -= pointF.Y; offset.X += TmxHelper.GetAttributeAsFloat(xml, "x", 0f); offset.Y += TmxHelper.GetAttributeAsFloat(xml, "y", 0f); base.Offset = offset; } }
public static List <TmxChunk> ListFromDataXml(XElement xml, TmxData parentData) { if (xml.Element("chunk") == null) { return(ListFromDataXml_Finite(xml, parentData)); } return(ListFromDataXml_Infinite(xml, parentData)); }
public TmxLayer(TmxLayerNode parent, TmxMap map) : base(parent, map) { base.Visible = true; base.Opacity = 1f; Data = new TmxData(this); CollisionLayers = new List <TmxLayer>(); }
public static TmxData FromDataXml(XElement xml, TmxLayer parentLayer) { TmxData tmxData = new TmxData(parentLayer); tmxData.Encoding = TmxHelper.GetAttributeAsEnum(xml, "encoding", DataEncoding.Xml); tmxData.Compression = TmxHelper.GetAttributeAsEnum(xml, "compression", DataCompression.None); tmxData.Chunks = TmxChunk.ListFromDataXml(xml, tmxData); return(tmxData); }
public TmxData MakeEmptyCopy(TmxLayer parent) { TmxData data = new TmxData(parent); data.Encoding = Encoding; data.Compression = Compression; data.Chunks = (from c in Chunks select c.MakeEmptyCopy(data)).ToList(); return(data); }
private static List <TmxChunk> ListFromDataXml_Finite(XElement xml, TmxData parentData) { TmxChunk tmxChunk = new TmxChunk(parentData); tmxChunk.X = 0; tmxChunk.Y = 0; tmxChunk.Width = parentData.ParentLayer.Width; tmxChunk.Height = parentData.ParentLayer.Height; tmxChunk.ReadTileIds(xml); return(tmxChunk.ToEnumerable().ToList()); }
public TmxChunk MakeEmptyCopy(TmxData parentData) { return(new TmxChunk(parentData) { X = X, Y = Y, Width = Width, Height = Height, TileIds = Enumerable.Repeat(0u, TileIds.Count).ToList() }); }
private static List <TmxChunk> ListFromDataXml_Infinite(XElement xml, TmxData parentData) { List <TmxChunk> list = new List <TmxChunk>(); foreach (XElement item in xml.Elements("chunk")) { TmxChunk tmxChunk = new TmxChunk(parentData); tmxChunk.X = TmxHelper.GetAttributeAsInt(item, "x", 0); tmxChunk.Y = TmxHelper.GetAttributeAsInt(item, "y", 0); tmxChunk.Width = TmxHelper.GetAttributeAsInt(item, "width", 0); tmxChunk.Height = TmxHelper.GetAttributeAsInt(item, "height", 0); tmxChunk.ReadTileIds(item); list.Add(tmxChunk); } return(list); }
public TmxChunk(TmxData parentData) { ParentData = parentData; TileIds = new List <uint>(); }
private void ParseData(XElement elem) { Logger.WriteVerbose("Parse {0} layer data ...", base.Name); Data = TmxData.FromDataXml(elem, this); }