Menu基本完成

This commit is contained in:
SoulliesOfficial
2025-06-14 14:42:49 -04:00
parent b9e6a9ab25
commit b19469976a
52 changed files with 1380 additions and 363 deletions

View File

@@ -0,0 +1,192 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame;
using Ichni.Story;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni
{
public class GameSaveManager : SerializedMonoBehaviour
{
public static GameSaveManager instance;
public SongSaveModule SongSaveModule;
public StorySaveModule StorySaveModule;
private void Awake()
{
if (instance == null)
{
instance = this;
SongSaveModule = new SongSaveModule();
SongSaveModule.LoadSongStatuses();
StorySaveModule = new StorySaveModule();
StorySaveModule.LoadStoryVariables();
StorySaveModule.LoadChoices();
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
}
public partial class SongSaveModule
{
public Dictionary<string, SongStatusSave> songStatusSaves;
private string SongSavePath => Application.streamingAssetsPath + "/GameSaves/SongSaves.json";
public SongSaveModule()
{
songStatusSaves = new Dictionary<string, SongStatusSave>();
Debug.Log("Song save path: " + SongSavePath);
}
}
public partial class SongSaveModule
{
[Button]
public void SaveSongStatuses()
{
ES3.Save("SongSaves", songStatusSaves, SongSavePath);
}
public void LoadSongStatuses()
{
if (ES3.FileExists(SongSavePath))
{
songStatusSaves = ES3.Load<Dictionary<string, SongStatusSave>>("SongSaves", SongSavePath);
}
else
{
songStatusSaves = new Dictionary<string, SongStatusSave>();
//TODO: delete
songStatusSaves.Add("Chaos Zone", new SongStatusSave
{
isCompleted = false,
additionalInfo = "",
beatmapSaves = new Dictionary<string, BeatmapSave>()
{
{ "Easy", new BeatmapSave { accuracy = 0.0f, isFullCombo = false, isAllPerfect = false } },
{ "Hard", new BeatmapSave { accuracy = 0.0f, isFullCombo = false, isAllPerfect = false } },
{ "Chaos", new BeatmapSave { accuracy = 0.0f, isFullCombo = false, isAllPerfect = false } }
}
});
}
}
[Button]
public void ClearBeatmapRecords()
{
foreach (var songStatus in songStatusSaves.Values)
{
foreach (var beatmapSave in songStatus.beatmapSaves.Values)
{
beatmapSave.accuracy = 0.0f;
beatmapSave.isFullCombo = false;
beatmapSave.isAllPerfect = false;
}
}
SaveSongStatuses();
}
}
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.streamingAssetsPath + "/StorySaves/" + chapterName + ".json";
private string StoryVariablesPath => Application.streamingAssetsPath + "/StorySaves/StoryVariables.json";
private string ChoicesPath => Application.streamingAssetsPath + "/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 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 partial class StorySaveModule
{
public void SaveStoryVariables()
{
string path = Application.streamingAssetsPath + "/StorySaves/" + "StoryVariables.json";
ES3.Save("StoryVariables", storyVariables, path);
}
public void LoadStoryVariables()
{
string path = Application.streamingAssetsPath + "/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.streamingAssetsPath + "/StorySaves/" + "Choices.json";
ES3.Save("Choices", selectedChoices, path);
}
public void LoadChoices()
{
string path = Application.streamingAssetsPath + "/StorySaves/" + "Choices.json";
if (ES3.FileExists(path))
{
selectedChoices = ES3.Load<Dictionary<string, int>>("Choices", path);
}
else
{
selectedChoices = new Dictionary<string, int>();
}
}
}
}