private static void loadHighScore() { try { if (File.Exists(Application.persistentDataPath + "/score.json")) { StreamReader sr = new StreamReader(Application.persistentDataPath + "/score.json"); string loadJSON = sr.ReadToEnd(); sr.Close(); highScore = UnityEngine.JsonUtility.FromJson <HighScoreData>(loadJSON).highScore; } } catch { highScore = 0; return; } }
public static bool Load(out Tile[] tiles, out int score) { try { loadHighScore(); tiles = null; score = 0; if (File.Exists(Application.persistentDataPath + "/save.json")) { StreamReader sr = new StreamReader(Application.persistentDataPath + "/save.json"); string loadJSON = sr.ReadToEnd(); sr.Close(); if (loadJSON == "") { File.Delete(Application.persistentDataPath + "/save.json"); return(false); } TilesCollection TS = UnityEngine.JsonUtility.FromJson <TilesCollection>(loadJSON); tiles = new Tile[TS.tsd.Length]; for (int i = 0; i < TS.tsd.Length; i++) { tiles[i] = new Tile(); tiles[i].Value = TS.tsd[i].value; tiles[i].Position = TS.tsd[i].i; } score = TS.score; return(true); } else { return(false); } } catch { score = 0; tiles = null; return(false); } }
public static List <CsvRow> ParseCSV_Exp(string pathNameInResource) { StreamReader mysr = new StreamReader(pathNameInResource); string str = mysr.ReadToEnd(); if (str == string.Empty) { return(null); } string contents = str; byte[] datas = System.Text.Encoding.UTF8.GetBytes(contents); CsvFileReader reader = new CSVHelper.CsvFileReader(new MemoryStream(datas)); List <CsvRow> result = new List <CsvRow>(); CsvRow row = new CsvRow(); while (reader.ReadRow(row)) { result.Add(row); row = new CsvRow(); } return(result); }