Exemplo n.º 1
0
        public static LayerTileSaveData Merge(List<TileSaveData> tileData, List<TilePositionCloud> tilePositions)
        {
            tileData = tileData.OrderBy(t => t.TileSaveID).ToList();
            tilePositions = tilePositions.OrderBy(t => t.TileSaveID).ToList();

            var result = new LayerTileSaveData();
            result.Tiles = new Dictionary<TileSaveData, TilePositionCloud>();

            for (int i = 0; i < tileData.Count; i++)
            {
                result.Tiles.Add(tileData[i], tilePositions[i]);
            }

            return result;
        }
Exemplo n.º 2
0
		internal object GetTilePositionCloudObjects(LayerTileSaveData layerData)
		{
			var result = new List<object>(layerData.Tiles.Count);

			foreach (var positionCloud in layerData.Tiles.Values)
			{
				result.Add(new
				{
					id = positionCloud.TileSaveID,
					positions = positionCloud.CellNumbers.SerializeCompact(sorted: true)
				});
			}

			return result;
		}
Exemplo n.º 3
0
		internal object GetUniqueTileObjects(LayerTileSaveData layerData)
		{
			var result = new List<object>(layerData.Tiles.Count);

			foreach (var uniqueTile in layerData.Tiles.Keys)
			{
				result.Add(new
				{
					id = uniqueTile.TileSaveID,
					typeName = uniqueTile.TypeName,
					solidSides = uniqueTile.SolidSides,
					name = uniqueTile.Name,
					graphicsResource = uniqueTile.GraphicsResourceName,
					state = uniqueTile.InitialState,
					customData = uniqueTile.CustomData
				});
			}

			return result;
		}
Exemplo n.º 4
0
		internal object GetLayerObjects(Section section)
		{
			var result = new List<object>(section.Layers.Count);

			foreach (var layer in section.Layers)
			{
				LayerTileSaveData layerData = new LayerTileSaveData(layer);
				result.Add(new
				{
					index = layer.Index,
					name = layer.Name,
					isMainLayer = layer.IsMainLayer,
					position = layer.Tiles.Position.Serialize(),
					gridWidth = layer.Tiles.Width,
					gridHeight = layer.Tiles.Height,
					uniqueTiles = GetUniqueTileObjects(layerData),
					tilePositions = GetTilePositionCloudObjects(layerData)
				});
			}

			return result;
		}