剧情+对话完善

This commit is contained in:
SoulliesOfficial
2026-07-21 15:24:42 -04:00
parent 8f230831e9
commit 810d019619
161 changed files with 7271 additions and 1893 deletions

View File

@@ -20,6 +20,10 @@ namespace Ichni.Story.UI
public RectTransform outPort;
public Button button;
// 运行时实际承载点击事件的 Button。TextBlock 会在切换状态视觉时替换其背景,
// 因此不能只依赖 Prefab 初始序列化的 button 引用。
private Button _boundInteractionButton;
// 关联的定义,供子类读取类型专属字段
protected StoryBlockDefinition definition;
@@ -48,8 +52,7 @@ namespace Ichni.Story.UI
// 都可保留各自的宽高StoryTreeController 会据此计算 Content 边界和连接线端口。
blockRect.anchoredPosition = position;
if (button != null)
button.onClick.AddListener(HandleClick);
BindInteractionButton(button);
ApplyState(state);
}
@@ -62,8 +65,43 @@ namespace Ichni.Story.UI
{
state = newState;
if (button != null)
button.interactable = state != StoryBlockState.Locked && state != StoryBlockState.Forbidden;
RefreshButtonInteractable();
}
/// <summary>
/// 绑定当前 Block 的交互 Button。
/// TextBlock 更换状态背景时会销毁旧背景并生成新的 Button必须先解绑旧对象、
/// 再绑定新对象,才能避免点击监听丢失或因重复绑定而触发多次。
/// </summary>
protected void BindInteractionButton(Button newButton)
{
if (_boundInteractionButton == newButton)
{
RefreshButtonInteractable();
return;
}
if (_boundInteractionButton != null)
_boundInteractionButton.onClick.RemoveListener(HandleClick);
_boundInteractionButton = newButton;
button = newButton;
if (_boundInteractionButton != null)
_boundInteractionButton.onClick.AddListener(HandleClick);
RefreshButtonInteractable();
}
/// <summary>
/// 依据剧情状态刷新当前交互 Button。Completed 仍允许回顾,只有 Locked 与
/// Forbidden 状态禁止点击。
/// </summary>
protected void RefreshButtonInteractable()
{
if (_boundInteractionButton != null)
_boundInteractionButton.interactable =
state != StoryBlockState.Locked && state != StoryBlockState.Forbidden;
}
private void HandleClick()