chore(merge): 合并 develop 并整合 Day2 梦境剧情与演出
This commit is contained in:
@@ -16,9 +16,13 @@ namespace AibisDream
|
||||
[YarnCommand("NextYarn")]
|
||||
public static void NextYarn(string exitName = null)
|
||||
{
|
||||
if (!GameManager.Instance.TryAdvanceChapterFromYarn(exitName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnumEventSystem.Global.Send(EventEnum.NextYarn);
|
||||
YarnVariableStorage.Instance.ClearLocal();
|
||||
DialogController.Instance.StartCoroutine(GameManager.Instance.NextSceneSo(exitName));
|
||||
}
|
||||
|
||||
[YarnCommand("OpenEndMenu")]
|
||||
@@ -30,14 +34,13 @@ namespace AibisDream
|
||||
[YarnCommand("load_scene")]
|
||||
public static IEnumerator LoadScene(string sceneName, float _unusedFadeDuration = 0f)
|
||||
{
|
||||
HideDialog();
|
||||
yield return SceneLoader.Instance.LoadSceneAsync(sceneName);
|
||||
yield return GameManager.Instance.LoadSceneFromYarn(sceneName);
|
||||
}
|
||||
|
||||
[YarnCommand("unload_scene")]
|
||||
public static IEnumerator UnloadScene()
|
||||
{
|
||||
yield return SceneLoader.Instance.UnloadSceneAsync();
|
||||
yield return GameManager.Instance.UnloadSceneFromYarn();
|
||||
}
|
||||
|
||||
[YarnCommand("set_volume_weight")]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.SaveSystem;
|
||||
@@ -11,6 +12,8 @@ namespace AibisDream
|
||||
{
|
||||
public class DialogController : Singleton<DialogController>
|
||||
{
|
||||
public event Action<bool> DialogueActivityChanged;
|
||||
|
||||
private DialogueRunner _dialogueRunner;
|
||||
|
||||
public DialogueRunner DialogueRunner => _dialogueRunner;
|
||||
@@ -30,11 +33,13 @@ namespace AibisDream
|
||||
|
||||
_dialogueRunner.onDialogueStart.AddListener(() =>
|
||||
{
|
||||
DialogueActivityChanged?.Invoke(true);
|
||||
EnumEventSystem.Global.Send(InteractionEventEnum.DialogStart);
|
||||
});
|
||||
|
||||
_dialogueRunner.onDialogueComplete.AddListener(() =>
|
||||
{
|
||||
DialogueActivityChanged?.Invoke(false);
|
||||
EnumEventSystem.Global.Send(InteractionEventEnum.DialogEnd);
|
||||
ClearCurrentNodeContext();
|
||||
});
|
||||
@@ -47,8 +52,8 @@ namespace AibisDream
|
||||
{
|
||||
SingleCastEventSystem.Global.Register<DialogEventEnum, string>(DialogEventEnum.StartNode, StartDialogNode);
|
||||
|
||||
EnumEventSystem.Global.Register(GameLoopEnum.GameStart, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionStarted, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionEnded, ResetAdvanceMode);
|
||||
|
||||
EnumEventSystem.Global.Register(DialogEventEnum.OptionShow, OnOptionShow);
|
||||
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, OnOptionSelected);
|
||||
@@ -58,8 +63,8 @@ namespace AibisDream
|
||||
{
|
||||
SingleCastEventSystem.Global.Unregister(DialogEventEnum.StartNode);
|
||||
|
||||
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameStart, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameQuit, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionStarted, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionEnded, ResetAdvanceMode);
|
||||
|
||||
EnumEventSystem.Global.UnRegister(DialogEventEnum.OptionShow, OnOptionShow);
|
||||
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, OnOptionSelected);
|
||||
@@ -94,10 +99,20 @@ namespace AibisDream
|
||||
|
||||
public void StopDialog()
|
||||
{
|
||||
_ = _dialogueRunner.Stop();
|
||||
StartCoroutine(StopDialogRoutine());
|
||||
}
|
||||
|
||||
public IEnumerator StopDialogRoutine()
|
||||
{
|
||||
if (_dialogueRunner != null && _dialogueRunner.IsDialogueRunning)
|
||||
{
|
||||
yield return _dialogueRunner.Stop();
|
||||
}
|
||||
|
||||
SavePointEvaluator.ResetForProject(null);
|
||||
YarnVariableStorage.Instance.Clear();
|
||||
DialogUIManager.Instance.HideDialog();
|
||||
DialogueActivityChanged?.Invoke(false);
|
||||
}
|
||||
|
||||
public void LoadDialog(YarnProject yarnProject)
|
||||
@@ -314,4 +329,4 @@ namespace AibisDream
|
||||
Auto,
|
||||
Quick
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace AibisDream
|
||||
|
||||
private bool IsInputAvailable()
|
||||
{
|
||||
return GameManager.Instance.state.IsInputAvailable()
|
||||
return GameManager.Session.CanAdvanceDialogue
|
||||
&& _curSyncToken != null
|
||||
&& _curSyncToken.state != LineSyncState.Advanced;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,13 @@ namespace AibisDream
|
||||
|
||||
public override async YarnTask RunLineAsync(LocalizedLine dialogueLine, LineCancellationToken token)
|
||||
{
|
||||
// 选项提示语由 OptionView 暂存,并在 Dream Options 出现时直接显示。
|
||||
// 不创建 LineSyncToken,避免进入普通台词的动画、推进和音频流程。
|
||||
if (dialogueLine.IsOptionPromptLine())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lineSyncEvent = BuildSyncToken(dialogueLine);
|
||||
DialogController.Instance.lineSyncToken = lineSyncEvent;
|
||||
DispatchToView(dialogueLine, lineSyncEvent);
|
||||
|
||||
@@ -27,8 +27,8 @@ namespace AibisDream
|
||||
EnumEventSystem.Global.Register<StorageEvent, VariableItem>(StorageEvent.VariableSet, OnVariableSet);
|
||||
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, OnOptionSelected);
|
||||
EnumEventSystem.Global.Register(DialogEventEnum.OptionShow, OnOptionShow);
|
||||
EnumEventSystem.Global.Register(GameLoopEnum.GameStart, Clear);
|
||||
EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, Clear);
|
||||
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionStarted, Clear);
|
||||
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionEnded, Clear);
|
||||
EnumEventSystem.Global.Register(EventEnum.NextYarn, Clear);
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace AibisDream
|
||||
EnumEventSystem.Global.UnRegister<StorageEvent, VariableItem>(StorageEvent.VariableSet, OnVariableSet);
|
||||
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, OnOptionSelected);
|
||||
EnumEventSystem.Global.UnRegister(DialogEventEnum.OptionShow, OnOptionShow);
|
||||
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameStart, Clear);
|
||||
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameQuit, Clear);
|
||||
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionStarted, Clear);
|
||||
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionEnded, Clear);
|
||||
EnumEventSystem.Global.UnRegister(EventEnum.NextYarn, Clear);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Utility;
|
||||
using UnityEngine;
|
||||
using Yarn.Unity;
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace AibisDream
|
||||
[SerializeField] private DialogViewType defaultViewType = DialogViewType.StandardBubble;
|
||||
|
||||
private OptionExploreTracker? _tracker;
|
||||
private LineInfo? _pendingOptionPrompt;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -32,20 +34,36 @@ namespace AibisDream
|
||||
|
||||
public override YarnTask OnDialogueStartedAsync()
|
||||
{
|
||||
ClearPendingOptionPrompt();
|
||||
return YarnTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override YarnTask OnDialogueCompleteAsync()
|
||||
{
|
||||
ClearPendingOptionPrompt();
|
||||
HideDialog();
|
||||
return YarnTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override YarnTask RunLineAsync(LocalizedLine line, LineCancellationToken token)
|
||||
{
|
||||
if (line.IsOptionPromptLine())
|
||||
{
|
||||
_pendingOptionPrompt = LineInfo.Generate(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearPendingOptionPrompt();
|
||||
}
|
||||
|
||||
return YarnTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override void OnNodeExit(string nodeName)
|
||||
{
|
||||
ClearPendingOptionPrompt();
|
||||
}
|
||||
|
||||
public void LoadBubbles(BubbleSlotGroupData data)
|
||||
{
|
||||
defaultViewType = data.dialogViewType;
|
||||
@@ -68,6 +86,8 @@ namespace AibisDream
|
||||
optionId => optionSelectedSource.TrySetResult(optionId));
|
||||
|
||||
var viewType = GetCurrentViewType(options);
|
||||
var optionPrompt = _pendingOptionPrompt;
|
||||
ClearPendingOptionPrompt();
|
||||
|
||||
switch (viewType)
|
||||
{
|
||||
@@ -76,7 +96,13 @@ namespace AibisDream
|
||||
defaultOptions.ShowOptions(options);
|
||||
break;
|
||||
case DialogViewType.OnelineBox:
|
||||
onelineOptions.ShowOptions(options);
|
||||
onelineOptions.ShowOptions(options, optionPrompt?.lineText);
|
||||
if (optionPrompt.HasValue)
|
||||
{
|
||||
EnumEventSystem.Global.Send(
|
||||
DialogEventEnum.LineHistoryAppend,
|
||||
optionPrompt.Value);
|
||||
}
|
||||
break;
|
||||
case DialogViewType.CenterOption:
|
||||
centerOptions.ShowOptions(options);
|
||||
@@ -106,10 +132,16 @@ namespace AibisDream
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
HideDialog();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearPendingOptionPrompt()
|
||||
{
|
||||
_pendingOptionPrompt = null;
|
||||
}
|
||||
|
||||
private DialogViewType GetCurrentViewType(DialogOption[] options)
|
||||
{
|
||||
var optionViewType = options[0].Character.dialogViewType;
|
||||
|
||||
Reference in New Issue
Block a user