Menu基本完成
This commit is contained in:
13
Assets/Scripts/Saving/BeatmapSave.cs
Normal file
13
Assets/Scripts/Saving/BeatmapSave.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class BeatmapSave
|
||||
{
|
||||
public float accuracy;
|
||||
public bool isFullCombo;
|
||||
public bool isAllPerfect;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Saving/BeatmapSave.cs.meta
Normal file
11
Assets/Scripts/Saving/BeatmapSave.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b751bb37660d844780656591830afff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
192
Assets/Scripts/Saving/GameSaveManager.cs
Normal file
192
Assets/Scripts/Saving/GameSaveManager.cs
Normal 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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Saving/GameSaveManager.cs.meta
Normal file
11
Assets/Scripts/Saving/GameSaveManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cffb558157bfb9a49a2a624f025f8958
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Scripts/Saving/SongStatusSave.cs
Normal file
13
Assets/Scripts/Saving/SongStatusSave.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class SongStatusSave
|
||||
{
|
||||
public bool isCompleted;
|
||||
public string additionalInfo;
|
||||
public Dictionary<string, BeatmapSave> beatmapSaves;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Saving/SongStatusSave.cs.meta
Normal file
11
Assets/Scripts/Saving/SongStatusSave.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e15d295a0ae77041ad0269ab3801bc3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/Scripts/Saving/StorySave.cs
Normal file
53
Assets/Scripts/Saving/StorySave.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Story
|
||||
{
|
||||
public class StoryBlockSave
|
||||
{
|
||||
public string blockName;
|
||||
public Vector2 position;
|
||||
public StoryBlockState state;
|
||||
|
||||
public StoryBlockSave(string blockName, Vector2 position, StoryBlockState state)
|
||||
{
|
||||
this.blockName = blockName;
|
||||
this.state = state;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
public class TutorialBlockSave : StoryBlockSave
|
||||
{
|
||||
public TutorialBlockSave(string blockName, Vector2 position, StoryBlockState state) : base(blockName, position, state)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class DialogBlockSave : StoryBlockSave
|
||||
{
|
||||
public DialogBlockSave(string blockName, Vector2 position, StoryBlockState state) : base(blockName, position, state)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class SongBlockSave : StoryBlockSave
|
||||
{
|
||||
public SongBlockSave(string blockName, Vector2 position, StoryBlockState state) : base(blockName, position, state)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class BlockConnectorSave
|
||||
{
|
||||
public string startBlockName;
|
||||
public string endBlockName;
|
||||
|
||||
public BlockConnectorSave(string startBlockName, string endBlockName)
|
||||
{
|
||||
this.startBlockName = startBlockName;
|
||||
this.endBlockName = endBlockName;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Saving/StorySave.cs.meta
Normal file
11
Assets/Scripts/Saving/StorySave.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ff8f51d49d96524fab4c38c7f846368
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user