56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
using UnityEngine;
|
|
|
|
public class SaveTaskDataManager : SaveModelSystem<Task>
|
|
{
|
|
public override bool SaveModelItem(Task model)
|
|
{
|
|
return base.SaveModelItem(model);
|
|
}
|
|
|
|
public override bool SaveModelList(List<Task> list)
|
|
{
|
|
BinaryFormatter formatter = new BinaryFormatter();
|
|
|
|
Debug.Log("Saved Quest at " + Path);
|
|
|
|
if (!Directory.Exists(Path)) Directory.CreateDirectory(Path);
|
|
|
|
FileStream stream = new FileStream(
|
|
Path + GetFileName(ObjectListName),
|
|
FileMode.Create
|
|
);
|
|
|
|
formatter.Serialize(stream, list);
|
|
stream.Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
public override Task LoadModelItem()
|
|
{
|
|
return base.LoadModelItem();
|
|
}
|
|
|
|
public override List<Task> LoadModelList()
|
|
{
|
|
string path = Path + GetFileName(ObjectListName);
|
|
|
|
if(File.Exists(path))
|
|
{
|
|
BinaryFormatter formatter = new BinaryFormatter();
|
|
FileStream stream = new FileStream(path, FileMode.Open);
|
|
|
|
List<Task> questsList = formatter.Deserialize(stream) as List<Task>;
|
|
stream.Close();
|
|
|
|
return questsList;
|
|
} else {
|
|
Debug.Log("Save file not found in " + path);
|
|
}
|
|
|
|
return new List<Task>();
|
|
}
|
|
} |