public static RoomPieceData GetData(string data) { RoomPieceData roomPieceData = new RoomPieceData(); StringReader reader = new StringReader(data); string line = ""; int lineNumber = 0; while ((line = reader.ReadLine()) != null) { lineNumber++; if (line == "[/ROOMPIECES]") { break; } else if (line == "[LEVELSET]") { roomPieceData.LevelSets.Add(ReadLevelSet(ref reader, ref lineNumber)); } } reader.Close(); reader.Dispose(); return roomPieceData; }
public static string GetString(RoomPieceData roomPieceData) { StringBuilder builder = new StringBuilder(); builder.AppendLine("[ROOMPIECES]"); if (roomPieceData.LevelSets.Count > 0) { foreach (var levelSet in roomPieceData.LevelSets) { builder.AppendLevelSet(levelSet); } } builder.Append("[/ROOMPIECES]"); return builder.ToString(); }
private void WriteRoomPieceDataFile(RoomPieceData roomPieceData) { _writer.Write(roomPieceData.LevelSets.Count); foreach (var levelset in roomPieceData.LevelSets) { WriteLevelset(levelset); } for (int i = 0; i < roomPieceData.LevelSets.Count; i++) { _writer.Write(roomPieceData.LevelSets[i].GUIDS.Count); foreach(var guid in roomPieceData.LevelSets[i].GUIDS) { _writer.Write(guid); ; } } }
private RoomPieceData ReadRoomPieceDataFile() { RoomPieceData rawFile = new RoomPieceData(); int levelSetCount = _reader.ReadInt32(); for (int i = 0; i < levelSetCount; i++) { rawFile.LevelSets.Add(ReadLevelset()); } for (int i = 0; i < levelSetCount; i++) { int guidCount = _reader.ReadInt32(); for (int j = 0; j < guidCount; j++) { rawFile.LevelSets[i].GUIDS.Add(_reader.ReadInt64()); } } return rawFile; }