示例#1
0
        public static void DeserializeTilemap(TilemapSerializedData data, STETilemap tilemap)
        {
            foreach (TilemapSerializedData.TileData dataItem in data.tileDataList)
            {
                tilemap.SetTileData(dataItem.gridX, dataItem.gridY, dataItem.tileData); // NOT SURE ABOUT THIS LINE.
            }
            tilemap.UpdateMesh();

            //TilemapUtils.IterateTilemapWithAction(tilemap, action);
            //return data;
        }
示例#2
0
        // RecordData() is called when saving. It returns a string representation of the save data.
        public override string RecordData()
        {
            STETilemap tilemap = GetComponent <STETilemap>();

            if (tilemap == null)
            {
                return(string.Empty);
            }
            TilemapSerializedData data = SerializeTilemap(tilemap);

            return(SaveSystem.Serialize(data));
        }
示例#3
0
        // ApplyData() is called when loading. It receives a string representation of the
        // save data and applies it to the tilemap.
        public override void ApplyData(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return;
            }
            TilemapSerializedData data = SaveSystem.Deserialize <TilemapSerializedData>(s);

            if (data != null)
            {
                DeserializeTilemap(data, GetComponent <STETilemap>());
            }
        }
示例#4
0
        public static TilemapSerializedData SerializeTilemap(STETilemap tilemap)
        {
            TilemapSerializedData data = new TilemapSerializedData();

            System.Action <STETilemap, int, int, uint> action = (tmap, gridX, gridY, tileData) =>
            {
                data.tileDataList.Add(new TilemapSerializedData.TileData()
                {
                    gridX = gridX, gridY = gridY, tileData = tileData
                });
            };
            TilemapUtils.IterateTilemapWithAction(tilemap, action);
            return(data);
        }