36 lines
966 B
C#
36 lines
966 B
C#
using System.Collections;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Level
|
|
{
|
|
[System.Serializable]
|
|
public class LevelData
|
|
{
|
|
public LayoutCell.LayoutCellData[][] layout;
|
|
public int width;
|
|
public int height;
|
|
|
|
public byte[] ToBytes()
|
|
{
|
|
BinaryFormatter formatter = new BinaryFormatter();
|
|
using (MemoryStream memoryStream = new MemoryStream())
|
|
{
|
|
formatter.Serialize(memoryStream, this);
|
|
return memoryStream.ToArray();
|
|
}
|
|
}
|
|
|
|
public static LevelData FromBytes(byte[] data)
|
|
{
|
|
BinaryFormatter formatter = new BinaryFormatter();
|
|
using (MemoryStream memoryStream = new MemoryStream(data))
|
|
{
|
|
return (LevelData)formatter.Deserialize(memoryStream);
|
|
}
|
|
}
|
|
}
|
|
}
|