存档重构,游戏内容解锁机制;教程完善(未完成)
This commit is contained in:
@@ -7,12 +7,26 @@ using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
/// <summary>
|
||||
/// GameScene 返回 MenuScene 后应恢复的页面。
|
||||
/// 该枚举替代互斥的布尔标记,避免普通歌曲与教程返回状态同时残留。
|
||||
/// </summary>
|
||||
public enum MenuReturnDestination
|
||||
{
|
||||
None,
|
||||
SongSelection,
|
||||
Story
|
||||
}
|
||||
|
||||
public class InformationTransistor : MonoBehaviour
|
||||
{
|
||||
public static InformationTransistor instance;
|
||||
|
||||
public bool isReturnedFromGame;
|
||||
public bool isReturnedFromTutorial;
|
||||
|
||||
/// <summary>
|
||||
/// 当前游戏运行结束后,MenuScene 应恢复的唯一目标页面。
|
||||
/// 运行期间保存在 DontDestroyOnLoad 对象中,不写入玩家存档。
|
||||
/// </summary>
|
||||
public MenuReturnDestination menuReturnDestination;
|
||||
|
||||
public ChapterSelectionUnit chapter;
|
||||
public SongItemData song;
|
||||
@@ -30,8 +44,7 @@ namespace Ichni
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
isReturnedFromGame = false;
|
||||
isReturnedFromTutorial = false;
|
||||
menuReturnDestination = MenuReturnDestination.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -42,11 +55,48 @@ namespace Ichni
|
||||
public void SetInformation(ChapterSelectionUnit chapter,
|
||||
SongItemData song, DifficultyData difficulty)
|
||||
{
|
||||
// 保留旧入口,供现有选曲流程在播放过场前预先写入歌曲信息。
|
||||
// 真正进入 GameScene 时,MenuManager.EnterGame 会补充 SongSelection 返回目标。
|
||||
PrepareGameLaunch(chapter, song, difficulty, MenuReturnDestination.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 统一准备一次 GameScene 运行所需的上下文。
|
||||
/// 普通选曲和 TutorialBlock 都必须通过此入口写入,防止章节、歌曲、难度与返回目标来自不同旧运行。
|
||||
/// </summary>
|
||||
public bool PrepareGameLaunch(ChapterSelectionUnit chapter, SongItemData song,
|
||||
DifficultyData difficulty, MenuReturnDestination returnDestination)
|
||||
{
|
||||
if (chapter == null || song == null || difficulty == null)
|
||||
{
|
||||
Debug.LogWarning("[InformationTransistor] 缺少章节、歌曲或难度,无法准备 GameScene 上下文。");
|
||||
return false;
|
||||
}
|
||||
|
||||
this.chapter = chapter;
|
||||
this.song = song;
|
||||
this.difficulty = difficulty;
|
||||
this.chapterSwitch = chapter.chapterSwitch;
|
||||
this.songSwitch = song.songSwitch;
|
||||
chapterSwitch = chapter.chapterSwitch;
|
||||
songSwitch = song.songSwitch;
|
||||
menuReturnDestination = returnDestination;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 由现有选曲过场在真正激活 GameScene 前设置返回目标。
|
||||
/// </summary>
|
||||
public void SetMenuReturnDestination(MenuReturnDestination returnDestination)
|
||||
{
|
||||
menuReturnDestination = returnDestination;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MenuScene 已依据返回目标完成恢复后调用。
|
||||
/// 只清除一次性路由,不清除歌曲与难度,以免当前 UI 的运行时缓存被意外破坏。
|
||||
/// </summary>
|
||||
public void ClearMenuReturnDestination()
|
||||
{
|
||||
menuReturnDestination = MenuReturnDestination.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user