Merge remote-tracking branch 'origin/保底全流程包' into develop

This commit is contained in:
2025-07-24 17:12:36 +08:00
222 changed files with 34030 additions and 9870 deletions
@@ -72,6 +72,13 @@ namespace AibisDream
public void StartDialogNode(string nodeName)
{
// 检查对话是否正在运行
if (_dialogueRunner.IsDialogueRunning)
{
Debug.LogWarning($"对话正在运行中,无法启动新节点: {nodeName}");
return;
}
if (CheckIfNodeExistInCurrentYarnProject(nodeName))
{
_dialogueRunner.StartDialogue(nodeName);
+30 -1
View File
@@ -1,6 +1,8 @@
using System;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using UnityEngine;
using Yarn.Unity;
namespace AibisDream
@@ -9,25 +11,52 @@ namespace AibisDream
{
public override void RunLine(LocalizedLine dialogueLine, Action onDialogueLineFinished)
{
string lineId = dialogueLine.TextID;
string shortText = dialogueLine.TextWithoutCharacterName.Text.Length > 30
? dialogueLine.TextWithoutCharacterName.Text.Substring(0, 30) + "..."
: dialogueLine.TextWithoutCharacterName.Text;
Debug.Log($"[对话流程] [{lineId}] ===== 开始处理 =====");
Debug.Log($"[对话流程] [{lineId}] 文本内容: {shortText}");
EnumEventSystem.Global.Send(DialogEventEnum.LineStart, DialogText.GetLine(dialogueLine));
HandleLineOutput(dialogueLine, onDialogueLineFinished);
if (DialogController.Instance.quickRunMode)
{
DialogCanvasManager.Instance.TrySkipLine(true);
Debug.Log($"[快速模式] [{lineId}] ===== 快速处理开始 =====");
// 快速模式:直接跳过文本显示并继续
bool skipResult = DialogCanvasManager.Instance.TrySkipLine(true);
Debug.Log($"[快速模式] [{lineId}] TrySkipLine结果: {skipResult}");
EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
Debug.Log($"[快速模式] [{lineId}] LineShown事件已发送");
DialogCanvasManager.Instance.NextStep();
Debug.Log($"[快速模式] [{lineId}] NextStep已调用");
Debug.Log($"[快速模式] [{lineId}] ===== 快速处理完成 =====");
}
else
{
Debug.Log($"[正常模式] [{lineId}] 等待用户交互");
}
Debug.Log($"[对话流程] [{lineId}] ===== 处理完成 =====");
}
private void HandleLineOutput(LocalizedLine dialogueLine, Action onDialogueLineFinished)
{
string lineId = dialogueLine.TextID;
Debug.Log($"[文本显示] [{lineId}] 开始显示文本");
DialogCanvasManager.Instance.ShowLine(dialogueLine.TextWithoutCharacterName.Text,
dialogueLine.GetCharacterVo(), onDialogueLineFinished, dialogueLine.TextID, dialogueLine.IsAutoSkipLine());
}
public override void RunOptions(DialogueOption[] dialogueOptions, Action<int> onOptionSelected)
{
Debug.Log($"[选项显示] ===== 显示 {dialogueOptions.Length} 个选项 =====");
EnumEventSystem.Global.Send(DialogEventEnum.OptionShow);
var options = DialogOption.GeneOptions(dialogueOptions, onOptionSelected);
DialogCanvasManager.Instance.ShowOptions(options);
@@ -9,7 +9,7 @@ public class ScreenEffectManager : MonoBehaviour
public Volume saturation;
private ColorAdjustments colorAdjustments;
// private ColorAdjustments colorAdjustments;
private void Awake()
{
@@ -28,26 +28,31 @@ public class ScreenEffectManager : MonoBehaviour
private void Start()
{
// 获取 ColorAdjustments 设置
if (saturation.profile.TryGet(out colorAdjustments))
{
Debug.Log("ColorAdjustments is available.");
}
else
{
Debug.LogError("ColorAdjustments settings not found in PostProcessProfile.");
}
// if (saturation.profile.TryGet(out colorAdjustments))
// {
// Debug.Log("ColorAdjustments is available.");
// }
// else
// {
// Debug.LogError("ColorAdjustments settings not found in PostProcessProfile.");
// }
}
// 动态调整饱和度
public Tween TweenSaturation(float targetSaturation, float duration)
{
if (colorAdjustments != null)
if (saturation != null)
{
// 使用 DOTween 创建一个饱和度过渡动画
// 将targetSaturation (0~1) 转换为weight (1~0)
// targetSaturation = 0 时,weight = 1 (完全褪色)
// targetSaturation = 1 时,weight = 0 (正常颜色)
float targetWeight = 1f - targetSaturation;
// 使用 DOTween 创建一个weight过渡动画
Tween tween = DOTween.To(
() => colorAdjustments.saturation.value, // 获取当前饱和度
x => colorAdjustments.saturation.value = x, // 设置新的饱和度
targetSaturation, // 目标饱和度
() => saturation.weight, // 获取当前weight
x => saturation.weight = x, // 设置新的weight
targetWeight, // 目标weight
duration // 过渡持续时间
);
@@ -55,8 +60,18 @@ public class ScreenEffectManager : MonoBehaviour
}
else
{
Debug.LogError("ColorAdjustments settings not found.");
Debug.LogError("Saturation Volume not found.");
return null; // 如果找不到设置,返回 null
}
}
// 重置饱和度效果
public void ResetSaturation()
{
if (saturation != null)
{
// 直接设置weight为0,恢复正常颜色
saturation.weight = 0f;
}
}
}
@@ -162,9 +162,6 @@ namespace AibisDream.FixSystem
DialogController.Instance?.StartDialogNode($"{data.moduleName}CutDown");
EnumEventSystem.Global.Send(EventEnum.CutEnd);
Destroy(gameObject);
DialogController.Instance?.StartDialogNode($"{data.moduleName}CutDown");
EnumEventSystem.Global.Send(EventEnum.CutEnd);
Destroy(gameObject);
}
public void SetCutTextVisible(bool visible)
@@ -87,10 +87,14 @@ namespace AibisDream.FixSystem
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false)
{
Debug.Log($"[ScreenSystem] ShowLine - 原始文本: '{dialogLine}'");
if (string.IsNullOrWhiteSpace(dialogLine))
{
dialogLine = " ";
dialogLine = " ";
// Debug.Log("[ScreenSystem] ShowLine - 空文本被替换为空格");
}
ShowTitle(character.GetActorName());
// 生成新文本组件
var textItem = Instantiate(_textItemPrefab, textRoot);
@@ -103,20 +107,29 @@ namespace AibisDream.FixSystem
Destroy(_lineQueue.Dequeue().gameObject);
}
_lineQueue.Enqueue(textItemTypewriter);
// 播放文本
textItemTypewriter.ShowText(dialogLine);
textItemTypewriter.onTextShowed.AddListener(() => AfterLineShown(textItemTypewriter, nextStep));
// 强制更新布局
LayoutRebuilder.ForceRebuildLayoutImmediate(textRoot);
Debug.Log($"[ScreenSystem] ShowLine - 文本播放开始,nextStep是否为null: {nextStep == null}");
}
private void AfterLineShown(TypewriterByCharacter typewriter, Action nextStop)
{
Debug.Log("[ScreenSystem] AfterLineShown - 文本显示完成");
Debug.Log($"[ScreenSystem] AfterLineShown - nextStop是否为null: {nextStop == null}");
EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
ActionKit.Delay(0.3f, () =>
ActionKit.Delay(0.1f, () =>
{
Debug.Log("[ScreenSystem] AfterLineShown - 延迟结束,调用回调");
EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
nextStop.Invoke();
Debug.Log("[ScreenSystem] AfterLineShown - 回调调用完成");
}).StartGlobal();
typewriter.onTextShowed.RemoveAllListeners();
}
+6
View File
@@ -85,6 +85,8 @@ namespace AibisDream
{
// 游戏开始
EnumEventSystem.Global.Send(GameLoopEnum.GameStart);
// 重置屏幕效果
ScreenEffectManager.Instance?.ResetSaturation();
// 序列
_currentTalkSceneSo.Value = firstTalkSo;
StartCoroutine(LoadFirstScene());
@@ -94,6 +96,8 @@ namespace AibisDream
{
// 游戏开始
EnumEventSystem.Global.Send(GameLoopEnum.GameStart);
// 重置屏幕效果
ScreenEffectManager.Instance?.ResetSaturation();
_currentTalkSceneSo.Value = sceneSo;
StartCoroutine(LoadFirstScene());
@@ -142,6 +146,8 @@ namespace AibisDream
{
// 系统继续
Time.timeScale = 1;
// 重置屏幕效果
ScreenEffectManager.Instance?.ResetSaturation();
// 卸载当前场景
StartCoroutine(RestartCoroutine());
}
+2 -2
View File
@@ -294,7 +294,7 @@ namespace AibisDream
var panelShafts = new Shaft[gearSystemData.panelShaftArray.Length];
for (int i = 0; i < gearSystemData.panelShaftArray.Length; i++)
{
var newShaft = Instantiate(shaftPrefab, panelShaftRoot).GetComponent<Shaft>();
var newShaft = Instantiate(shaftPrefab, panelShaftRoot, true).GetComponent<Shaft>();
newShaft.Load(gearSystemData.panelShaftArray[i]);
panelShafts[i] = newShaft;
}
@@ -365,7 +365,7 @@ namespace AibisDream
var newPanelShafts = new Shaft[data.panelShaftArray.Length];
for (int i = 0; i < data.panelShaftArray.Length; i++)
{
var newShaft = Instantiate(shaftPrefab, panelShaftRoot).GetComponent<Shaft>();
var newShaft = Instantiate(shaftPrefab, panelShaftRoot, true).GetComponent<Shaft>();
newShaft.Load(data.panelShaftArray[i]);
newPanelShafts[i] = newShaft;
}
@@ -260,14 +260,11 @@ namespace AibisDream
Material material = eyeImage.material;
Sequence saturationSequence = DOTween.Sequence();
// 使用映射函数将目标饱和度转换为 ColorAdjustments 的范围
float mappedSaturation = MapSaturation(targetSaturation);
// 同时启动材质的饱和度变化和 ColorAdjustments 的饱和度变化
// 同时启动材质的饱和度变化和 Volume 的weight变化
saturationSequence.Join(material.DOFloat(targetSaturation, "_HsvSaturation", duration));
// 获取 Tween 对象并添加到序列中
Tween saturationTween = ScreenEffectManager.Instance.TweenSaturation(mappedSaturation, duration);
Tween saturationTween = ScreenEffectManager.Instance.TweenSaturation(targetSaturation, duration);
if (saturationTween != null)
{
saturationSequence.Join(saturationTween);
@@ -277,10 +274,7 @@ namespace AibisDream
yield return saturationSequence.WaitForCompletion();
}
private float MapSaturation(float input)
{
return Mathf.Lerp(-100, 0, input);
}
private Sequence glitchin;
@@ -20,8 +20,17 @@ namespace AibisDream
var timeArray = activePartAssets.Where(item => item.time == time).ToArray();
if (timeArray.Length == 0) return;
var res = timeArray.DefaultIfEmpty(timeArray[0]).First(item => item.weather == curWeather);
gameObject.SetActive(res.active);
// 先尝试找到匹配当前天气的配置
var matchingWeather = timeArray.FirstOrDefault(item => item.weather == curWeather);
if (matchingWeather.time != default) // 如果找到了匹配的天气配置
{
gameObject.SetActive(matchingWeather.active);
return;
}
// 如果没有找到匹配的天气配置,使用第一个时间匹配的配置
gameObject.SetActive(timeArray[0].active);
}
public override void OnWeatherChange(Weather weather)
@@ -30,8 +39,17 @@ namespace AibisDream
var weatherArray = activePartAssets.Where(item => item.weather == weather).ToArray();
if (weatherArray.Length == 0) return;
var res = weatherArray.DefaultIfEmpty(weatherArray[0]).First(item => item.time == curTime);
gameObject.SetActive(res.active);
// 先尝试找到匹配当前时间的配置
var matchingTime = weatherArray.FirstOrDefault(item => item.time == curTime);
if (matchingTime.time != default) // 如果找到了匹配的时间配置
{
gameObject.SetActive(matchingTime.active);
return;
}
// 如果没有找到匹配的时间配置,使用第一个天气匹配的配置
gameObject.SetActive(weatherArray[0].active);
}
}
@@ -96,6 +96,9 @@ namespace AibisDream
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId,
bool isAutoSkip = false)
{
Debug.Log($"[BubbleGroup] ShowLine - 开始显示对话: {lineId}");
Debug.Log($"[BubbleGroup] ShowLine - nextStep是否为null: {nextStep == null}");
gameObject.SetActive(true);
if (TryGetBubble(character.role, character.bubbleIdx, out var bubble))
@@ -114,6 +117,8 @@ namespace AibisDream
// 保留信息
_nextStep = nextStep;
_curBubble = bubble;
Debug.Log($"[BubbleGroup] ShowLine - 设置完成,_nextStep是否为null: {_nextStep == null}");
}
public void ShowOptions(DialogOption[] dialogueOptions)
@@ -161,16 +166,26 @@ namespace AibisDream
public void NextStep()
{
if (_nextStep == null) return;
Debug.Log($"[BubbleGroup] NextStep - _nextStep是否为null: {_nextStep == null}");
if (_nextStep == null)
{
Debug.Log("[BubbleGroup] NextStep - _nextStep为null,提前返回");
return;
}
Debug.Log("[BubbleGroup] NextStep - 发送LineEnd事件");
EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
var next = _nextStep;
_nextStep = null;
_curBubble?.Hide();
_curBubble = null;
Debug.Log("[BubbleGroup] NextStep - 调用回调");
next?.Invoke();
Debug.Log("[BubbleGroup] NextStep - 回调调用完成");
}
public void OnLocalizationChanged(string value)
@@ -75,22 +75,32 @@ namespace AibisDream
private void OnTextShown()
{
// 阻塞部分
Debug.Log("[事件处理] OnTextShown - 文本显示完成事件");
// 在快速模式下,不设置阻塞,因为快速模式会立即处理
if (DialogController.Instance.quickRunMode)
{
Debug.Log("[事件处理] OnTextShown - 快速模式,跳过阻塞设置");
return;
}
// 阻塞部分 - 只在非快速模式下阻塞,确保文本能够显示
_isNextBlocked = true;
_block = ActionKit.Delay(blockDuration, () =>
{
Debug.Log("[事件处理] OnTextShown - 阻塞时间结束");
_isNextBlocked = false;
_block = null;
}
).Start(this);
// 自动跳过部分
if (DialogController.Instance.quickRunMode) return;
// 自动跳过部分 - 只在非快速模式下执行
if (DialogController.Instance.autoRunMode || _isNextAutoSkip)
{
Debug.Log("[事件处理] OnTextShown - 设置自动跳过定时器");
_autoNext = ActionKit.Delay(autoSkipDelay, () =>
{
Debug.Log("[事件处理] OnTextShown - 自动跳过定时器触发");
_autoNext = null;
NextStep();
}).Start(this);
@@ -100,12 +110,26 @@ namespace AibisDream
private void OnTextEnd()
{
_block?.Deinit();
_block = null;
Debug.Log("[事件处理] OnTextEnd - 文本结束事件");
// 清理阻塞定时器
if (_block != null)
{
Debug.Log("[事件处理] OnTextEnd - 清理阻塞定时器");
_block.Deinit();
_block = null;
}
_isNextBlocked = false;
_autoNext?.Deinit();
_autoNext = null;
// 清理自动跳过定时器
if (_autoNext != null)
{
Debug.Log("[事件处理] OnTextEnd - 清理自动跳过定时器");
_autoNext.Deinit();
_autoNext = null;
}
Debug.Log("[事件处理] OnTextEnd - 清理完成");
}
public override void OnSingletonDestroy()
@@ -156,10 +180,14 @@ namespace AibisDream
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId,
bool isAutoSkip = false)
{
Debug.Log($"[DialogCanvasManager] ShowLine - 角色对话框类型: {character.dialogViewType}");
Debug.Log($"[DialogCanvasManager] ShowLine - nextStep是否为null: {nextStep == null}");
_isNextAutoSkip = isAutoSkip;
// 根据DialogViewType确定在哪个对话框显示
if (character.dialogViewType == DialogViewType.Default)
{
Debug.Log("[DialogCanvasManager] ShowLine - 使用默认对话框");
if (_showingView != _defaultView)
{
_showingView?.HideDialog();
@@ -176,6 +204,7 @@ namespace AibisDream
}
else if (_dialogViewDict.TryGetValue(character.dialogViewType, out var view))
{
Debug.Log($"[DialogCanvasManager] ShowLine - 使用指定对话框: {view.GetType().Name}");
if (_showingView != view)
{
_showingView?.HideDialog();
@@ -195,6 +224,8 @@ namespace AibisDream
{
Debug.Log($"{character.dialogViewType.ToString()}类型对话框不存在");
}
Debug.Log($"[DialogCanvasManager] ShowLine - 当前_showingView类型: {_showingView?.GetType().Name}");
}
public void ShowOptions(DialogOption[] dialogueOptions)
@@ -239,23 +270,51 @@ namespace AibisDream
public bool TrySkipLine(bool isForceSkip = false)
{
string skipType = isForceSkip ? "强制跳过" : "用户跳过";
Debug.Log($"[跳过操作] {skipType} - 阻塞状态: {_isNextBlocked}");
if (_isNextBlocked)
{
Debug.Log("[跳过操作] ❌ 被阻塞,返回true");
return true;
}
return _showingView != null && _showingView.TrySkipLine(isForceSkip);
bool result = _showingView != null && _showingView.TrySkipLine(isForceSkip);
Debug.Log($"[跳过操作] {skipType} - 结果: {(result ? " " : " ")}");
return result;
}
public void NextStep()
{
var view = _showingView;
_hideDialog = ActionKit.Delay(autoHideDuration, () =>
Debug.Log("[对话继续] ===== NextStep开始 =====");
Debug.Log($"[对话继续] 当前显示的对话框类型: {_showingView?.GetType().Name}");
// 在快速模式下,不设置延迟隐藏,避免定时器冲突
if (!DialogController.Instance.quickRunMode)
{
_hideDialog = null;
view.HideDialog();
}).Start(this);
var view = _showingView;
_hideDialog = ActionKit.Delay(autoHideDuration, () =>
{
Debug.Log("[对话继续] 延迟隐藏对话框");
_hideDialog = null;
view.HideDialog();
}).Start(this);
}
else
{
Debug.Log("[对话继续] 快速模式,跳过延迟隐藏设置");
// 清理可能存在的延迟隐藏定时器
if (_hideDialog != null)
{
_hideDialog.Deinit();
_hideDialog = null;
}
}
Debug.Log("[对话继续] 调用对话框NextStep");
_showingView?.NextStep();
Debug.Log("[对话继续] ===== NextStep完成 =====");
}
public void OnLocalizationChanged(string value)
+3
View File
@@ -91,6 +91,9 @@ namespace AibisDream.Utility
case "role":
vo.role = Enum.TryParse<ActorRole>(pair.Value.StringValue, out var type) ? type : ActorRole.Aside;
break;
case "dialogViewType":
vo.dialogViewType = Enum.TryParse<DialogViewType>(pair.Value.StringValue, out var viewType) ? viewType : DialogViewType.Default;
break;
}
}