Files
ichni_Official/Assets/Scripts/Menu/ChapterSelection/ChapterSelectionUnit.cs

174 lines
5.4 KiB
C#
Raw Normal View History

2025-06-03 02:42:28 -04:00
using System;
using System.Collections;
using System.Collections.Generic;
2025-06-06 10:14:55 -04:00
using System.Linq;
using AK.Wwise;
2025-08-22 14:54:40 -04:00
using Ichni.RhythmGame;
2025-06-03 02:42:28 -04:00
using Sirenix.OdinInspector;
2026-03-14 03:13:10 -04:00
using SLSUtilities.WwiseAssistance;
2025-06-03 02:42:28 -04:00
using UnityEngine;
2025-06-14 14:42:49 -04:00
using UnityEngine.Serialization;
2025-06-03 02:42:28 -04:00
namespace Ichni.Menu
{
[CreateAssetMenu(fileName = "DefaultChapter", menuName = "Ichni/UI/ChapterSelectionUnit", order = 0)]
2025-08-11 14:04:06 -04:00
public partial class ChapterSelectionUnit : SerializedScriptableObject
2025-06-03 02:42:28 -04:00
{
public string chapterIndex;
public string chapterName;
public string chapterSubtitle;
public Color themeColor;
public Sprite avatar;
2025-06-06 10:14:55 -04:00
public Switch chapterSwitch;
2025-08-11 14:04:06 -04:00
[Searchable]
2025-06-03 02:42:28 -04:00
public List<SongItemData> songs = new List<SongItemData>();
2025-06-06 10:14:55 -04:00
[Button]
public void SetUpDefaultDifficulties()
{
foreach (SongItemData song in songs)
{
if(song.difficultyDataList.All(d => d.difficultyName != "Easy"))
{
2025-07-26 04:20:25 -04:00
song.difficultyDataList.Add(new DifficultyData(
0, "Easy","Easy", 0, "",
2025-06-06 10:14:55 -04:00
new Color(0f, 0.7f, 0.2f, 1f)));
}
if (song.difficultyDataList.All(d => d.difficultyName != "Hard"))
{
2025-07-26 04:20:25 -04:00
song.difficultyDataList.Add(new DifficultyData(
1,"Hard", "Hard", 0, "",
2025-06-06 10:14:55 -04:00
new Color(1f, 0.2f, 0.2f, 1f)));
}
}
2025-07-10 08:42:30 -04:00
}
[Button]
public void SelectSwitch()
{
2026-03-14 03:13:10 -04:00
AudioManager.SetSwitch(chapterSwitch);
2025-06-06 10:14:55 -04:00
}
2025-06-03 02:42:28 -04:00
}
2025-08-11 14:04:06 -04:00
public partial class ChapterSelectionUnit
{
public List<string> GetRelatedSongNamesOfUnlockKey(string key)
{
return (from song in songs where song.storyUnlockKey == key select song.songName).ToList();
}
2025-08-22 14:54:40 -04:00
public (int, int, int, int, int) GetChapterSaveInfo()
{
int beatmapCount = 0;
int finishedSongCount = 0;
int finishedBeatmapCount = 0;
int fullComboCount = 0;
int allPerfectCount = 0;
foreach (SongItemData song in songs)
{
if (GameSaveManager.instance.SongSaveModule.songStatusSaves.TryGetValue(song.songName, out var songStatus))
{
bool thisSongFinished = false;
foreach (BeatmapSave beatmapSave in songStatus.beatmapSaves)
{
beatmapCount++;
if (!beatmapSave.IsEmpty())
{
thisSongFinished = true;
finishedBeatmapCount++;
if (beatmapSave.isFullCombo)
{
fullComboCount++;
}
if (beatmapSave.isAllPerfect)
{
allPerfectCount++;
}
}
}
if (thisSongFinished)
{
finishedSongCount++;
}
}
}
return (beatmapCount, finishedSongCount, finishedBeatmapCount, fullComboCount, allPerfectCount);
}
2025-08-11 14:04:06 -04:00
}
2025-06-03 02:42:28 -04:00
[InlineProperty]
[Serializable]
public class SongItemData
{
2025-08-11 14:04:06 -04:00
[FoldoutGroup("$songName", false)]
2025-06-03 02:42:28 -04:00
public string songName;
[FoldoutGroup("$songName")]
public string displaySongName;
[FoldoutGroup("$songName")]
2025-07-21 05:42:20 -04:00
public string composer;
2025-06-03 02:42:28 -04:00
[FoldoutGroup("$songName")]
2025-06-06 10:14:55 -04:00
public Switch songSwitch;
2025-06-03 02:42:28 -04:00
[FoldoutGroup("$songName")]
2025-07-21 05:42:20 -04:00
public Sprite illustration;
2025-06-03 02:42:28 -04:00
[FoldoutGroup("$songName")]
public string illustratorName;
[FoldoutGroup("$songName")]
public string additionalInformation;
[FoldoutGroup("$songName")]
public List<DifficultyData> difficultyDataList;
2025-08-11 14:04:06 -04:00
[FoldoutGroup("$songName")]
public string storyUnlockKey;
2025-07-26 04:20:25 -04:00
[FoldoutGroup("$songName")]
2025-08-11 14:04:06 -04:00
public string paymentUnlockKey;
2025-06-03 02:42:28 -04:00
}
[Serializable]
public class DifficultyData
{
2025-07-21 05:42:20 -04:00
public int difficultyIndex;
2025-06-03 02:42:28 -04:00
public string difficultyName;
public string displayDifficultyName;
2025-06-14 14:42:49 -04:00
public int difficultyValue;
2025-07-21 05:42:20 -04:00
public string charterName;
2025-06-03 02:42:28 -04:00
public Color color;
2025-08-11 14:04:06 -04:00
public bool isAvailable;
public DifficultyData()
{
}
2025-07-21 05:42:20 -04:00
public DifficultyData(int difficultyIndex, string difficultyName, string displayDifficultyName, int difficultyValue, string charterName, Color color)
2025-06-03 02:42:28 -04:00
{
2025-07-21 05:42:20 -04:00
this.difficultyIndex = difficultyIndex;
2025-06-03 02:42:28 -04:00
this.difficultyName = difficultyName;
this.displayDifficultyName = displayDifficultyName;
2025-07-21 05:42:20 -04:00
this.charterName = charterName;
2025-06-14 14:42:49 -04:00
this.difficultyValue = difficultyValue;
2025-06-03 02:42:28 -04:00
this.color = color;
2025-08-11 14:04:06 -04:00
this.isAvailable = true;
2025-06-03 02:42:28 -04:00
}
2025-07-21 05:42:20 -04:00
public string GetDifficultyName()
{
return string.IsNullOrEmpty(displayDifficultyName) ? difficultyName : displayDifficultyName;
}
2025-06-03 02:42:28 -04:00
}
}