2026-04-24 캐릭터 상호작용
This commit is contained in:
Binary file not shown.
@@ -8,6 +8,7 @@ public class DialogPlayer : MonoBehaviour
|
||||
[SerializeField] private List<DialogGroup> _dialogGroups;
|
||||
private Dictionary<string, DialogGroup> _dialogGroupMap;
|
||||
private Animator _animator;
|
||||
public bool IsPlaying { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -18,36 +19,44 @@ private void Awake()
|
||||
_animator = GetComponentInChildren<Animator>();
|
||||
}
|
||||
|
||||
// 임시 테스트용
|
||||
private void Update()
|
||||
public async Awaitable Play()
|
||||
{
|
||||
if (Keyboard.current != null && Keyboard.current.tKey.wasPressedThisFrame)
|
||||
_ = Play("BlackDialogGroup1");
|
||||
if(_dialogGroups.Count > 0)
|
||||
_ = Play(_dialogGroups[0].DialogGroupName);
|
||||
}
|
||||
|
||||
public async Awaitable Play(string groupName)
|
||||
{
|
||||
if (IsPlaying) return;
|
||||
if (!_dialogGroupMap.TryGetValue(groupName, out var group))
|
||||
{
|
||||
Debug.LogWarning($"[DialogPlayer] 그룹 없음: {groupName}");
|
||||
return;
|
||||
}
|
||||
|
||||
var node = group.StartNode;
|
||||
while (node != null)
|
||||
IsPlaying = true;
|
||||
try
|
||||
{
|
||||
await PlayNode(node);
|
||||
var node = group.StartNode;
|
||||
while (node != null)
|
||||
{
|
||||
await PlayNode(node);
|
||||
|
||||
if (node.Choices != null && node.Choices.Count > 0)
|
||||
{
|
||||
int picked = await WaitForChoice(node);
|
||||
node = node.Choices[picked].DestinationNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
node = node.Next;
|
||||
if (node.Choices != null && node.Choices.Count > 0)
|
||||
{
|
||||
int picked = await WaitForChoice(node);
|
||||
node = node.Choices[picked].DestinationNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsPlaying = false;
|
||||
}
|
||||
|
||||
Debug.Log("[DialogPlayer] 대화 종료");
|
||||
}
|
||||
|
||||
19
Assets/02_Scripts/Interact/DialogInteractable.cs
Normal file
19
Assets/02_Scripts/Interact/DialogInteractable.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
[RequireComponent(typeof(DialogPlayer))]
|
||||
public class DialogInteractable : MonoBehaviour
|
||||
{
|
||||
private DialogPlayer _player;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_player = GetComponent<DialogPlayer>();
|
||||
}
|
||||
|
||||
public void HandleActivated(ActivateEventArgs args)
|
||||
{
|
||||
if (_player == null || _player.IsPlaying) return;
|
||||
_ = _player.Play();
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Interact/DialogInteractable.cs.meta
Normal file
2
Assets/02_Scripts/Interact/DialogInteractable.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8a22189f0d1e5448bf3e44657410176
|
||||
Binary file not shown.
Reference in New Issue
Block a user