public object SetFromString(string textData) { var dataLoader = new ByteSerializer(textData); var data = dataLoader.GetAsBytes(); if (data == null || data.Length <= 1) { return(this); } var ms = new MemoryStream(data); var br = new BinaryReader(ms); var version = br.ReadInt32(); name = br.ReadString(); inventory = new Item[br.ReadInt32()]; for (var i = 0; i < inventory.Length; i++) { inventory[i] = (Item) new Item().SetFromString(br.ReadString()); } location = new Vector2Int(br.ReadInt32(), br.ReadInt32()); br.Close(); ms.Close(); return(this); }
public object SetFromString(string textData) { var dataLoader = new ByteSerializer(textData); var data = dataLoader.GetAsBytes(); if (data == null || data.Length <= 1) { return(this); } var ms = new MemoryStream(data); var br = new BinaryReader(ms); var version = br.ReadInt32(); // Version 1 data walls = new Vector2Int[br.ReadInt32()]; for (var i = 0; i < walls.Length; i++) { walls[i] = new Vector2Int(br.ReadInt32(), br.ReadInt32()); } items = new Item[br.ReadInt32()]; for (var i = 0; i < items.Length; i++) { items[i] = (Item) new Item().SetFromString(br.ReadString()); } levelScore = br.ReadUInt32(); player = (Player) new Player().SetFromString(br.ReadString()); width = br.ReadInt32(); height = br.ReadInt32(); br.Close(); ms.Close(); return(this); }
public object SetFromString(string textData) { var dataLoader = new ByteSerializer(textData); var data = dataLoader.GetAsBytes(); if (data == null || data.Length <= 1) { return(this); } var ms = new MemoryStream(data); var br = new BinaryReader(ms); var version = br.ReadInt32(); name = br.ReadString(); description = br.ReadString(); location = new Vector2Int(br.ReadInt32(), br.ReadInt32()); br.Close(); ms.Close(); return(this); }