Example #1
0
        private static List <TmxDataTile> DecodeBase64Data(TmxData data, int width, int height)
        {
            var tileList    = new List <TmxDataTile>();
            var encodedData = data.Value.Trim();
            var decodedData = Convert.FromBase64String(encodedData);

            using (var stream = OpenStream(decodedData, data.Compression))
            {
                using (var reader = new BinaryReader(stream))
                {
                    data.Tiles = new List <TmxDataTile>();

                    for (var y = 0; y < width; y++)
                    {
                        for (var x = 0; x < height; x++)
                        {
                            var gid = reader.ReadUInt32();
                            tileList.Add(new TmxDataTile((int)gid));
                        }
                    }
                }
            }

            return(tileList);
        }
Example #2
0
 private static List <TmxDataTile> DecodeCsvData(TmxData data)
 {
     return(data.Value
            .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(int.Parse)
            .Select(gid => new TmxDataTile(gid))
            .ToList());
 }