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(); }
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(); }
public void Build <T>() where T : DataElement { for (int i = 0; i < SaveData.ids.Count; i++) { if (SaveData.types[i] == typeof(T).Name) { DataBuilder.BuildElementOfType <T>(SaveData, i); } } }
public void Build() { SceneManager t_sceneManager = SceneManager.Instance; DataBuilder.BuildDataReferences(); DataBuilder.BuildElementsOfType <TreeInfo>(t_sceneManager.DataReferences.SaveData); DataBuilder.BuildElementsOfType <BuildingInfo>(t_sceneManager.DataReferences.SaveData); DataBuilder.BuildElementsOfType <RockInfo>(t_sceneManager.DataReferences.SaveData); DataBuilder.BuildElementsOfType <ResourceInfo>(t_sceneManager.DataReferences.SaveData); DataBuilder.BuildElementsOfType <CollonistInfo>(t_sceneManager.DataReferences.SaveData); }
public void Build() { SceneManager t_sceneManager = SceneManager.Instance; DataBuilder.BuildDataReferences(); //BUILD OBJECTS HERE DataBuilder.BuildElementsOfType <PlayerData>(t_sceneManager.DataReferences.SaveData); DataBuilder.BuildElementsOfType <GlobalData>(t_sceneManager.DataReferences.SaveData); DataBuilder.BuildElementsOfType <ListedEnemyData>(t_sceneManager.DataReferences.SaveData); }
public void Build <T>() where T : DataElement { for (int i = 0; i < _saveData.ids.Count; i++) { if (_saveData.types[i] == typeof(T).Name) { DataBuilder.BuildElementOfType <T>(_saveData, i); } if (_saveData.info[i] != null) { for (int a = 0; a < _saveData.info[i].SaveData.ids.Count; a++) { if (_saveData.info[i].SaveData.types[a] == typeof(T).Name) { _saveData.info[i].Build <T>(); } } } } }
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); }