Scriptum/Assets/Scripts/REFACTORING/Application/Panel/Task/SceneTaskDataLoader.cs

101 lines
3.3 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
public class SceneTaskDataLoader : SceneBaseDataLoader<Task>
{
public SceneTaskDataLoader(string _objectListName, string _objectFolderName)
{
SaveModelSystem = new SaveTaskDataManager();
SaveModelSystem.ObjectFolderName = _objectFolderName;
SaveModelSystem.ObjectListName = _objectListName;
}
// public override List<Task> LoadData(SceneElementTypeEnum type)
// {
// string path = SaveSystem.GetSavePath();
//
// if (!Directory.Exists(path)) // if not exists thats mean there was nothing saved yet - nothing to load
// return new List<Task>();
//
// FileInfo[] fileInfo = new DirectoryInfo(path).GetFiles();
//
// foreach(FileInfo file in fileInfo)
// {
// if(file.Name != ItemsListName + ".fun")
// continue;
//
// List<Task> taskList = SaveQuestSystem.LoadQuestsList(ItemsListName);
//
// foreach(Task task in taskList)
// Elements.Add(task);
// }
//
// return Elements;
// }
// public override void SaveData(List<Task> _elements, SceneElementTypeEnum type)
// {
// // Case I - if we remember all list
// // 1) if after removed item form DynamicList is empty - remove all file
// // 2) if after removed item form DynamciList there are another one - save updated list again
// if(TaskManager.Instance.taskList.Count > 0) {
// SaveQuestSystem.SaveQuestsList(_elements, ItemsListName);
// } else {
// string _path = SaveSystem.GetSavePath() + "/" + ItemsListName + ".fun";
//
// try
// {
// Debug.Log("File to remove: " + _path);
//
// if(File.Exists(_path))
// {
// File.Delete(_path);
// }
// }
// catch (IOException ioExp)
// {
// Debug.LogError(ioExp.Message);
// }
// }
//
// // Case II - if we rememenber object per file
// // 1) remove specyfic file
// //
// // Unfortunatelly we don't use this way of saving items yet :D
//
// }
protected override List<Task> LoadGenericData()
{
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
return SaveModelSystem.LoadModelList();
}
protected override bool SaveGenericData(List<Task> _elements)
{
SaveModelSystem.Path = PathBuilder.BuildSavePath().GetString();
try
{
SaveModelSystem.SaveModelList(_elements);
return true;
}
catch (Exception e) { Debug.LogError(e.Message); }
return false;
}
protected override List<Task> LoadStaticData() { throw new System.NotImplementedException(); }
protected override List<Task> LoadDynamicData() { throw new System.NotImplementedException(); }
protected override bool SaveStaticData(List<Task> _elements) { throw new System.NotImplementedException(); }
protected override bool SaveDynamicData(List<Task> _elements) { throw new System.NotImplementedException(); }
}