private BuildTileBlockString ( int xStart, int yStart, int width, int height ) : string | ||
xStart | int | |
yStart | int | |
width | int | |
height | int | |
return | string |
public static LevelX.MultiTileGridLayerX ToXmlProxyX(MultiTileGridLayer layer) { if (layer == null) { return(null); } const int blockSize = 4; int xLimit = (layer.TilesWide + blockSize - 1) / blockSize; int yLimit = (layer.TilesHigh + blockSize - 1) / blockSize; List <CommonX.TileBlockX> blocks = new List <CommonX.TileBlockX>(); for (int y = 0; y < yLimit; y++) { for (int x = 0; x < xLimit; x++) { string data = layer.BuildTileBlockString(x * blockSize, y * blockSize, blockSize, blockSize); if (!string.IsNullOrEmpty(data)) { blocks.Add(new CommonX.TileBlockX() { X = x * blockSize, Y = y * blockSize, Data = data, }); } } } List <CommonX.PropertyX> props = new List <CommonX.PropertyX>(); foreach (Property prop in layer.PropertyManager.CustomProperties) { props.Add(Property.ToXmlProxyX(prop)); } return(new LevelX.MultiTileGridLayerX() { Name = layer.Name, Opacity = layer.Opacity, Visible = layer.IsVisible, RasterMode = layer.RasterMode, GridColor = layer.GridColor.ToArgbHex(), TileWidth = layer.TileWidth, TileHeight = layer.TileHeight, Blocks = blocks.Count > 0 ? blocks : null, Properties = props.Count > 0 ? props : null, }); }
public static LevelX.MultiTileGridLayerX ToXmlProxyX(MultiTileGridLayer layer) { if (layer == null) return null; const int blockSize = 4; int xLimit = (layer.TilesWide + blockSize - 1) / blockSize; int yLimit = (layer.TilesHigh + blockSize - 1) / blockSize; List<CommonX.TileBlockX> blocks = new List<CommonX.TileBlockX>(); for (int y = 0; y < yLimit; y++) { for (int x = 0; x < xLimit; x++) { string data = layer.BuildTileBlockString(x * blockSize, y * blockSize, blockSize, blockSize); if (!string.IsNullOrEmpty(data)) { blocks.Add(new CommonX.TileBlockX() { X = x * blockSize, Y = y * blockSize, Data = data, }); } } } List<CommonX.PropertyX> props = new List<CommonX.PropertyX>(); foreach (Property prop in layer.PropertyManager.CustomProperties) props.Add(Property.ToXmlProxyX(prop)); return new LevelX.MultiTileGridLayerX() { Name = layer.Name, Opacity = layer.Opacity, Visible = layer.IsVisible, RasterMode = layer.RasterMode, GridColor = layer.GridColor.ToArgbHex(), TileWidth = layer.TileWidth, TileHeight = layer.TileHeight, Blocks = blocks.Count > 0 ? blocks : null, Properties = props.Count > 0 ? props : null, }; }