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 void DeserializeFromJson(MTJSONObject curJson, bool sync) { Id = curJson.GetString("id", Id); Name = curJson.GetString("name", Name); MaxLevel = curJson.GetInt("maxLevel", MaxLevel); // levels MTJSONObject levelsJson = curJson.Get("levels"); if (levelsJson != null) { if (!sync) { _levels.Clear(); } if (levelsJson.count > 0) { var itemEnum = levelsJson.dict.GetEnumerator(); while (itemEnum.MoveNext()) { string curKey = itemEnum.Current.Key; int curValue = itemEnum.Current.Value.i; int curKeyInt = Convert.ToInt32(curKey); if (!_levels.ContainsKey(curKeyInt)) { _levels.Add(curKeyInt, curValue); } else { _levels[curKeyInt] = curValue; } } } } }