public void Save(saveDictionariesTypes dictionaryType) { File.WriteAllText( GetPath(saveDictionaryNames[(int)dictionaryType]), JsonUtility.ToJson(dictionaries[dictionaryType]) ); }
public void SetData(string key, int value, saveDictionariesTypes type, bool save = true) { if (!dictionaries.ContainsKey(type)) { dictionaries.Add(type, new SaveDict <string, int>(20)); } int keyIndex = dictionaries[type].GetKeyIndex(key); if (keyIndex != -1 && dictionaries[type].GetValue(keyIndex) != value) { dictionaries[type].SetValue(keyIndex, value); if (save) { Save(type); } return; } else if (keyIndex != -1 && dictionaries[type].GetValue(keyIndex) == value) { return; } dictionaries[type].Add(key, value); if (save) { Save(type); } }
public int GetData(string key, int defaultValue, saveDictionariesTypes type) { if (!dictionaries.ContainsKey(type)) { dictionaries.Add(type, new SaveDict <string, int>(20)); } int keyIndex = dictionaries[type].GetKeyIndex(key); if (keyIndex != -1) { return(dictionaries[type].GetValue(keyIndex)); } SetData(key, defaultValue, type); return(defaultValue); }