2026-07-05 16:08:23 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Ichni.Story.UI;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni.Story
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 剧情系统协调器(单例)。持有故事树控制器、剧情页面与章节数据引用,
|
|
|
|
|
|
/// 是外部系统(章节选择、存档等)与剧情系统交互的入口。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class StoryManager : SerializedMonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public static StoryManager instance;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("References")]
|
|
|
|
|
|
public StoryTreeController treeController;
|
|
|
|
|
|
public StoryUIPage storyUIPage;
|
|
|
|
|
|
public CharacterRegistry characterRegistry;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("Chapter Data")]
|
|
|
|
|
|
[Tooltip("章节索引 (chapterIndex) -> 该章节的 StoryData 资产")]
|
|
|
|
|
|
public Dictionary<string, StoryData> storyDatas = new Dictionary<string, StoryData>();
|
|
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
instance = this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开指定章节,构建其故事树。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void OpenChapter(string chapterIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
treeController.BuildChapter(chapterIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据章节索引获取对应的 StoryData,未找到返回 null。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public StoryData GetStoryData(string chapterIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return storyDatas.TryGetValue(chapterIndex, out StoryData data) ? data : null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-07-18 16:51:18 -04:00
|
|
|
|
/// 清除全部剧情存档(所有章节故事树 + 全局变量 + 由剧情授予的内容解锁 Key)。
|
2026-07-05 16:08:23 -04:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Button]
|
|
|
|
|
|
public void ClearAllStorySave()
|
|
|
|
|
|
{
|
|
|
|
|
|
GameSaveManager.instance.StorySaveModule.ClearAllStoryline();
|
2026-07-18 16:51:18 -04:00
|
|
|
|
GameSaveManager.instance.UnlockSaveModule.ClearAllKeys();
|
2026-07-05 16:08:23 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|