feat(Dialogue): 实现基本的对话系统

This commit is contained in:
2025-10-23 15:46:17 +08:00
parent 869d5794f3
commit efcbc8eea5
29 changed files with 1398 additions and 86 deletions

View File

@@ -30,20 +30,25 @@ namespace Script.Gameplay.Player
[SerializeField] private FirstPersonRaycaster raycaster; // 第一人称射线检测器
[SerializeField] private float maxConnectDistance = 10f; // 最大连接距离
private IConnectable previousTarget;
private IConnectable currentTarget;
public IConnectable CurrentTarget
{
get => currentTarget;
set
{
if (value != null)
previousTarget = currentTarget;
currentTarget = value;
if (previousTarget != currentTarget)
{
currentTarget = value;
OnGazeEnter?.Invoke(currentTarget.GetGameObject());
}
else
{
OnGazeExit?.Invoke(null);
if (currentTarget != null)
{
OnGazeEnter?.Invoke((currentTarget as MonoBehaviour)?.gameObject);
}
if (previousTarget != null)
{
OnGazeExit?.Invoke((previousTarget as MonoBehaviour)?.gameObject);
}
}
}
} // 当前注视的可连接对象
@@ -89,12 +94,6 @@ namespace Script.Gameplay.Player
GameObject lookAtObj = raycaster.CurrentLookAtObject;
IConnectable hitConnectable = lookAtObj != null ? lookAtObj.GetComponent<IConnectable>() : null;
// 注视对象变化时触发进入/离开(使用接口方法)
// if (hitConnectable != previousGazedTarget)
// {
// previousGazedTarget = hitConnectable;
// }
CurrentTarget = hitConnectable;
}