存档重构,游戏内容解锁机制;教程完善(未完成)
This commit is contained in:
@@ -9,6 +9,35 @@ namespace Ichni.Menu
|
||||
[CreateAssetMenu(fileName = "TutorialCollection", menuName = "Ichni/TutorialCollection")]
|
||||
public class TutorialCollection : SerializedScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 教程 Key 到教程曲目配置的映射。
|
||||
/// Key 必须使用小写英文、数字和下划线,例如 <c>chapter0_intro</c>;
|
||||
/// 不要使用章节展示名、曲名或点号作为 Key。
|
||||
/// </summary>
|
||||
public Dictionary<string, SongItemData> songs = new Dictionary<string, SongItemData>();
|
||||
|
||||
/// <summary>
|
||||
/// 按 TutorialBlock 配置的稳定 Key 查找教程曲目。
|
||||
/// 教程运行流程只通过此函数读取集合,避免各处直接访问字典而产生空引用或不一致的错误信息。
|
||||
/// </summary>
|
||||
public bool TryGetTutorialSong(string tutorialKey, out SongItemData song)
|
||||
{
|
||||
song = null;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(tutorialKey))
|
||||
{
|
||||
Debug.LogWarning("[TutorialCollection] Tutorial Key 为空,无法查找教程曲目。");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (songs == null || !songs.TryGetValue(tutorialKey, out song) || song == null)
|
||||
{
|
||||
Debug.LogWarning($"[TutorialCollection] 未找到 Tutorial Key '{tutorialKey}' 对应的教程曲目。");
|
||||
song = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user