public static void saveTopGameDataAt(TopGameData data, paths pathEnum) { if (data == null) { return; } if (pathEnum == paths.top1) { path = path_top1; } if (pathEnum == paths.top2) { path = path_top2; } if (pathEnum == paths.top3) { path = path_top3; } BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, data); stream.Close(); }
public static TopGameData loadTopGameDataAt(paths pathEnum) { if (pathEnum == paths.top1) { path = path_top1; } if (pathEnum == paths.top2) { path = path_top2; } if (pathEnum == paths.top3) { path = path_top3; } if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); TopGameData data = formatter.Deserialize(stream) as TopGameData; stream.Close(); return(data); } else { //Debug.LogError("Save file not found in path: " + path); return(null); } }
public static TopGameData[] loadAllTopGameData() { TopGameData[] data = new TopGameData[3]; data[0] = loadTopGameDataAt(paths.top1); data[1] = loadTopGameDataAt(paths.top2); data[2] = loadTopGameDataAt(paths.top3); return(testTopGameNotNull(data)); }
private static TopGameData[] testTopGameNotNull(TopGameData[] topData) { if (topData[0] == null) { topData[0] = new TopGameData(0, 0, 0, 0); } if (topData[1] == null) { topData[1] = new TopGameData(0, 0, 0, 0); } if (topData[2] == null) { topData[2] = new TopGameData(0, 0, 0, 0); } return(topData); }