This commit is contained in:
SoulliesOfficial
2025-07-26 04:20:25 -04:00
parent bae0bfbc20
commit abf81ece7b
196 changed files with 3909 additions and 964 deletions

View File

@@ -9,5 +9,17 @@ namespace Ichni.RhythmGame
public float accuracy;
public bool isFullCombo;
public bool isAllPerfect;
public BeatmapSave()
{
}
public BeatmapSave(float accuracy, bool isFullCombo, bool isAllPerfect)
{
this.accuracy = accuracy;
this.isFullCombo = isFullCombo;
this.isAllPerfect = isAllPerfect;
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.Menu;
using Ichni.RhythmGame;
using Ichni.Story;
using Sirenix.OdinInspector;
@@ -14,20 +15,15 @@ namespace Ichni
public SongSaveModule SongSaveModule;
public StorySaveModule StorySaveModule;
[Title("Debug")]
public UnlockKeysCollection unlockKeysCollection;
private void Awake()
{
if (instance == null)
{
instance = this;
SongSaveModule = new SongSaveModule();
SongSaveModule.LoadSongStatuses();
StorySaveModule = new StorySaveModule();
StorySaveModule.LoadStoryVariables();
StorySaveModule.LoadChoices();
DontDestroyOnLoad(gameObject);
}
else
@@ -35,22 +31,117 @@ namespace Ichni
Destroy(gameObject);
}
}
private void Start()
{
SongSaveModule = new SongSaveModule();
SongSaveModule.LoadSongStatuses();
SongSaveModule.LoadUnlockKeys();
StorySaveModule = new StorySaveModule();
StorySaveModule.LoadStoryVariables();
StorySaveModule.LoadChoices();
}
}
public partial class SongSaveModule
{
public HashSet<string> unlockKeys;
public Dictionary<string, SongStatusSave> songStatusSaves;
private string SongSavePath => Application.streamingAssetsPath + "/GameSaves/SongSaves.json";
private string SongSavePath => Application.persistentDataPath + "/GameSaves/SongSaves.json";
private string UnlockKeysPath => Application.persistentDataPath + "/GameSaves/UnlockKeys.json";
public SongSaveModule()
{
songStatusSaves = new Dictionary<string, SongStatusSave>();
unlockKeys = new HashSet<string>();
Debug.Log("Song save path: " + SongSavePath);
}
}
public partial class SongSaveModule
{
public void InitializeUnlockKeys()
{
unlockKeys = new HashSet<string>(GameSaveManager.instance.unlockKeysCollection.unlockKeys);
SaveUnlockKeys();
}
public void SaveUnlockKeys()
{
ES3.Save("UnlockKeys", unlockKeys, UnlockKeysPath);
}
public void LoadUnlockKeys()
{
if (ES3.FileExists(UnlockKeysPath))
{
unlockKeys = ES3.Load<HashSet<string>>("UnlockKeys", UnlockKeysPath);
}
else
{
InitializeUnlockKeys();
}
}
public bool CheckUnlock(string key)
{
return key == string.Empty || unlockKeys.Contains(key);
}
public void ClearUnlock()
{
unlockKeys.Clear();
SaveUnlockKeys();
}
}
public partial class SongSaveModule
{
private void InitializeSongStatuses()
{
foreach (ChapterSelectionUnit chapter in ChapterSelectionManager.instance.chapters)
{
foreach (SongItemData song in chapter.songs)
{
SongStatusSave songStatus = new SongStatusSave(false, string.Empty, new List<BeatmapSave>());
foreach (DifficultyData difficulty in song.difficultyDataList)
{
songStatus.beatmapSaves.Add(new BeatmapSave(0f,false, false));
}
songStatusSaves.Add(song.songName, songStatus);
}
}
SaveSongStatuses();
}
private void CheckSongStatuses()
{
foreach (ChapterSelectionUnit chapter in ChapterSelectionManager.instance.chapters)
{
foreach (SongItemData song in chapter.songs)
{
SongStatusSave songStatus = songStatusSaves[song.songName];
int difficultiesCount = song.difficultyDataList.Count;
if (songStatus.beatmapSaves.Count < difficultiesCount)
{
for (int i = songStatus.beatmapSaves.Count; i < difficultiesCount; i++)
{
songStatus.beatmapSaves.Add(new BeatmapSave(0f, false, false));
}
}
else if (songStatus.beatmapSaves.Count > difficultiesCount)
{
songStatus.beatmapSaves.RemoveRange(difficultiesCount, songStatus.beatmapSaves.Count - difficultiesCount);
}
}
}
SaveSongStatuses();
}
[Button]
public void SaveSongStatuses()
{
@@ -62,23 +153,11 @@ namespace Ichni
if (ES3.FileExists(SongSavePath))
{
songStatusSaves = ES3.Load<Dictionary<string, SongStatusSave>>("SongSaves", SongSavePath);
CheckSongStatuses();
}
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 } }
}
});
InitializeSongStatuses();
}
}
@@ -87,7 +166,7 @@ namespace Ichni
{
foreach (var songStatus in songStatusSaves.Values)
{
foreach (var beatmapSave in songStatus.beatmapSaves.Values)
foreach (var beatmapSave in songStatus.beatmapSaves)
{
beatmapSave.accuracy = 0.0f;
beatmapSave.isFullCombo = false;
@@ -97,6 +176,17 @@ namespace Ichni
SaveSongStatuses();
}
public SongStatusSave GetSongStatusSave(string songName)
{
if (songStatusSaves.TryGetValue(songName, out SongStatusSave save))
{
return save;
}
Debug.LogWarning("Song status save for " + songName + " does not exist.");
return null;
}
}
public partial class StorySaveModule
@@ -152,6 +242,20 @@ namespace Ichni
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

View File

@@ -8,6 +8,18 @@ namespace Ichni.RhythmGame
{
public bool isCompleted;
public string additionalInfo;
public Dictionary<string, BeatmapSave> beatmapSaves;
public List<BeatmapSave> beatmapSaves;
public SongStatusSave()
{
}
public SongStatusSave(bool isCompleted, string additionalInfo, List<BeatmapSave> beatmapSaves)
{
this.isCompleted = isCompleted;
this.additionalInfo = additionalInfo;
this.beatmapSaves = beatmapSaves;
}
}
}

View File

@@ -0,0 +1,41 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 15eae34b5665c7141ae96e00af60b2d0, type: 3}
m_Name: UnlockKeysCollection
m_EditorClassIdentifier:
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes:
- Name: unlockKeys
Entry: 7
Data: 0|System.Collections.Generic.HashSet`1[[System.String, mscorlib]], System.Core
- Name:
Entry: 12
Data: 2
- Name:
Entry: 1
Data: Test_Key
- Name:
Entry: 1
Data: Omega
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7dabd6d0cf475864c819364a7a359a8b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Ichni.RhythmGame
{
[CreateAssetMenu(fileName = "UnlockKeysCollection", menuName = "Ichni/RhythmGame/UnlockKeysCollection")]
public class UnlockKeysCollection : SerializedScriptableObject
{
public HashSet<string> unlockKeys;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 15eae34b5665c7141ae96e00af60b2d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: