Exemple #1
0
        public void ReplaceElement <T>(string p_ID, int p_index) where T : DataElement
        {
            if (DataManager.Instance == null)
            {
                return;
            }

            #pragma warning disable CS0162 // Unreachable code detected
            for (int i = 0; i < SaveData.ids.Count; i++)
            #pragma warning restore CS0162 // Unreachable code detected
            {
                if (p_ID == SaveData.ids[p_index])
                {
                    break;
                }
                else
                {
                    throw new ArgumentException("Argument does not exists.");
                }
            }

            T t_info = (T)DataParser.CreateAsset <T>(p_ID);
            t_info.ID = p_ID;

            File.Delete(Application.persistentDataPath + "/" + DataManager.Instance.ID + "/" + SceneManager.Instance.DataReferences.ID + "/" + p_ID + ".json");

            DataParser.SaveJSON(p_ID, JsonUtility.ToJson(t_info, true));
            JsonUtility.FromJsonOverwrite(DataBuilder.Decrypt(File.ReadAllText(Application.persistentDataPath + "/" + DataManager.Instance.ID + "/" + SceneManager.Instance.DataReferences.ID + "/" + p_ID + ".json")), t_info as T);

            SaveData.ids[p_index]   = p_ID;
            SaveData.info[p_index]  = t_info;
            SaveData.types[p_index] = t_info.GetType().ToString();

            Save();
        }
Exemple #2
0
        public void AddElement <T>(string p_ID) where T : DataElement
        {
            if (DataManager.Instance == null)
            {
                return;
            }

            for (int i = 0; i < SaveData.ids.Count; i++)
            {
                if (p_ID == SaveData.ids[i])
                {
                    return;
                }
            }

            T t_info = (T)DataParser.CreateAsset <T>(p_ID);

            t_info.ID = p_ID;

            DataParser.SaveJSON(p_ID, JsonUtility.ToJson(t_info, true));
            JsonUtility.FromJsonOverwrite(DataBuilder.Decrypt(File.ReadAllText(Application.persistentDataPath + "/" + DataManager.Instance.ID + "/" + SceneManager.Instance.DataReferences.ID + "/" + p_ID + ".json")), t_info);

            SaveData.ids.Add(p_ID);
            SaveData.info.Add(t_info);
            SaveData.types.Add(t_info.GetType().ToString());

            Save();
        }
Exemple #3
0
 public void Save()
 {
     DataParser.SaveJSON(_id.ToString(), JsonUtility.ToJson(this, true));
     JsonUtility.FromJsonOverwrite(DataBuilder.Decrypt(File.ReadAllText(Application.persistentDataPath + "/" + DataManager.Instance.ID + "/" + SceneManager.Instance.DataReferences.ID + "/" + _id.ToString() + ".json")), this);
 }