示例#1
0
 public void Save(saveDictionariesTypes dictionaryType)
 {
     File.WriteAllText(
         GetPath(saveDictionaryNames[(int)dictionaryType]),
         JsonUtility.ToJson(dictionaries[dictionaryType])
         );
 }
示例#2
0
    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);
        }
    }
示例#3
0
    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);
    }