Storyline+Dialog初步
This commit is contained in:
@@ -36,8 +36,7 @@ namespace Ichni
|
||||
SongSaveModule.LoadStoryUnlockKeys();
|
||||
|
||||
StorySaveModule = new StorySaveModule();
|
||||
StorySaveModule.LoadStoryVariables();
|
||||
StorySaveModule.LoadChoices();
|
||||
StorySaveModule.LoadVariables();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,113 +225,5 @@ namespace Ichni
|
||||
}
|
||||
}
|
||||
|
||||
public partial class StorySaveModule
|
||||
{
|
||||
public Dictionary<string, List<TutorialBlockSave>> tutorialBlockSaves;
|
||||
public Dictionary<string, List<SongBlockSave>> songBlockSaves;
|
||||
public Dictionary<string, List<DialogBlockSave>> dialogBlockSaves;
|
||||
public Dictionary<string, List<BlockConnectorSave>> connectorSaves;
|
||||
|
||||
public Dictionary<string, int> storyVariables;
|
||||
public Dictionary<string, int> selectedChoices;
|
||||
|
||||
private string GetStorySavePath(string chapterName) => Application.persistentDataPath + "/StorySaves/" + chapterName + ".json";
|
||||
private string StoryVariablesPath => Application.persistentDataPath + "/StorySaves/StoryVariables.json";
|
||||
private string ChoicesPath => Application.persistentDataPath + "/StorySaves/Choices.json";
|
||||
|
||||
public StorySaveModule()
|
||||
{
|
||||
tutorialBlockSaves = new Dictionary<string, List<TutorialBlockSave>>();
|
||||
songBlockSaves = new Dictionary<string, List<SongBlockSave>>();
|
||||
dialogBlockSaves = new Dictionary<string, List<DialogBlockSave>>();
|
||||
connectorSaves = new Dictionary<string, List<BlockConnectorSave>>();
|
||||
storyVariables = new Dictionary<string, int>();
|
||||
selectedChoices = new Dictionary<string, int>();
|
||||
//Debug.Log("Story Variables path: " + StoryVariablesPath);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class StorySaveModule
|
||||
{
|
||||
public bool IsNewStoryline(string chapterName)
|
||||
{
|
||||
return !ES3.FileExists(GetStorySavePath(chapterName));
|
||||
}
|
||||
|
||||
public void LoadStoryline(string chapterName)
|
||||
{
|
||||
tutorialBlockSaves[chapterName] = ES3.Load<List<TutorialBlockSave>>("TutorialBlockSaves", GetStorySavePath(chapterName));
|
||||
songBlockSaves[chapterName] = ES3.Load<List<SongBlockSave>>("SongBlockSaves", GetStorySavePath(chapterName));
|
||||
dialogBlockSaves[chapterName] = ES3.Load<List<DialogBlockSave>>("TextBlockSaves", GetStorySavePath(chapterName));
|
||||
connectorSaves[chapterName] = ES3.Load<List<BlockConnectorSave>>("BlockConnectorSaves", GetStorySavePath(chapterName));
|
||||
}
|
||||
|
||||
public void SaveStoryline(string chapterName, List<TutorialBlockSave> tutorialBlocks,
|
||||
List<SongBlockSave> songBlocks, List<DialogBlockSave> dialogBlocks,
|
||||
List<BlockConnectorSave> connectors)
|
||||
{
|
||||
ES3.Save("TutorialBlockSaves", tutorialBlocks, GetStorySavePath(chapterName));
|
||||
ES3.Save("SongBlockSaves", songBlocks, GetStorySavePath(chapterName));
|
||||
ES3.Save("TextBlockSaves", dialogBlocks, GetStorySavePath(chapterName));
|
||||
ES3.Save("BlockConnectorSaves", connectors, GetStorySavePath(chapterName));
|
||||
|
||||
SaveStoryVariables();
|
||||
SaveChoices();
|
||||
}
|
||||
|
||||
public void ClearAllStoryline()
|
||||
{
|
||||
string path = GetStorySavePath("Chapter0");
|
||||
if (ES3.FileExists(path))
|
||||
{
|
||||
ES3.DeleteFile(path);
|
||||
Debug.Log("Cleared all story saves at: " + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("No story saves found at: " + path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class StorySaveModule
|
||||
{
|
||||
public void SaveStoryVariables()
|
||||
{
|
||||
string path = Application.persistentDataPath + "/StorySaves/" + "StoryVariables.json";
|
||||
ES3.Save("StoryVariables", storyVariables, path);
|
||||
}
|
||||
|
||||
public void LoadStoryVariables()
|
||||
{
|
||||
string path = Application.persistentDataPath + "/StorySaves/" + "StoryVariables.json";
|
||||
if (ES3.FileExists(path))
|
||||
{
|
||||
storyVariables = ES3.Load<Dictionary<string, int>>("StoryVariables", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
storyVariables = new Dictionary<string, int>();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveChoices()
|
||||
{
|
||||
string path = Application.persistentDataPath + "/StorySaves/" + "Choices.json";
|
||||
ES3.Save("Choices", selectedChoices, path);
|
||||
}
|
||||
|
||||
public void LoadChoices()
|
||||
{
|
||||
string path = Application.persistentDataPath + "/StorySaves/" + "Choices.json";
|
||||
if (ES3.FileExists(path))
|
||||
{
|
||||
selectedChoices = ES3.Load<Dictionary<string, int>>("Choices", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedChoices = new Dictionary<string, int>();
|
||||
}
|
||||
}
|
||||
}
|
||||
// StorySaveModule 已迁移至 NewStorySystem/Save/StorySaveModule.cs(按章节存树/选项,全局存变量)
|
||||
}
|
||||
Reference in New Issue
Block a user