public static void Save(string fileName, string content) { var path = Application.persistentDataPath + "/" + fileName; if (isEn) { var bt = MTXXTea.Encrypt(content.ToString(), K); FileUtil.WriteAllBytes(path, bt); } else { FileUtil.WriteAllText(path, content); } }
void LoadSetting() { var bt = File.ReadAllBytes(GetPath()); string content = MTXXTea.DecryptToString(bt, SKEY); //File.ReadAllText(GetPath()); // Debug.Log("get content " + content); MTJSONObject setJs = MTJSON.Deserialize(content); totalCoin = setJs.GetInt(SettingEnum.totalCoin.ToString(), 0); //Debug.Log("get totoal coin " + totalCoin); recordCoin = setJs.GetInt(SettingEnum.recordCoin.ToString(), 0); recordScore = setJs.GetInt(SettingEnum.recordScore.ToString(), 0); recordBomb = setJs.GetInt(SettingEnum.recordBomb.ToString(), 0); recordRound = setJs.GetInt(SettingEnum.recordRound.ToString(), 0); recordMatch = setJs.GetInt(SettingEnum.recordMatch.ToString(), 0); }
public static string Load(string fileName) { var path = Application.persistentDataPath + "/" + fileName; if (isEn) { var bt = FileUtil.ReadAllBytes(path); if (bt == null) { return(""); } string content = MTXXTea.DecryptToString(bt, K); return(content); } else { return(File.ReadAllText(path)); } }
public void SaveToFile() { MTJSONObject setJs = MTJSONObject.CreateDict(); setJs.Set(SettingEnum.totalCoin.ToString(), totalCoin); setJs.Set(SettingEnum.recordCoin.ToString(), recordCoin); setJs.Set(SettingEnum.recordScore.ToString(), recordScore); setJs.Set(SettingEnum.recordBomb.ToString(), recordBomb); setJs.Set(SettingEnum.recordRound.ToString(), recordRound); setJs.Set(SettingEnum.recordMatch.ToString(), recordMatch); var bt = MTXXTea.Encrypt(setJs.ToString(), SKEY); File.WriteAllBytes(GetPath(), bt); }