70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class JunpyoRescueSequence : MonoBehaviour
|
|
{
|
|
[Header("구준표 구조 연출")]
|
|
[SerializeField] private JunpyoRescueEvent rescueEvent;
|
|
|
|
[Header("대화 시작 타이밍")]
|
|
[Tooltip("구준표가 달려오고 플레이어를 민 뒤, 대화를 시작하기까지의 전체 시간")]
|
|
[SerializeField] private float dialogueStartDelay = 1.5f;
|
|
|
|
[Header("연출 종료 후 실행")]
|
|
[Tooltip("여기에 기존 대화 시작 함수를 연결")]
|
|
[SerializeField] private UnityEvent onRescueFinished;
|
|
|
|
private bool hasPlayed;
|
|
|
|
public void PlaySequence()
|
|
{
|
|
if (hasPlayed)
|
|
return;
|
|
|
|
if (rescueEvent == null)
|
|
{
|
|
Debug.LogWarning(
|
|
"[JunpyoRescueSequence] Rescue Event가 연결되지 않았습니다."
|
|
);
|
|
return;
|
|
}
|
|
|
|
hasPlayed = true;
|
|
StartCoroutine(SequenceRoutine());
|
|
}
|
|
|
|
private IEnumerator SequenceRoutine()
|
|
{
|
|
// 1. 구준표 달려오기 + 플레이어 밀기
|
|
rescueEvent.PlayRescueEvent();
|
|
|
|
// 2. 구조 연출이 끝날 때까지 기다림
|
|
yield return new WaitForSeconds(dialogueStartDelay);
|
|
|
|
// 3. 구조 연출 종료 후 대화 시작
|
|
onRescueFinished?.Invoke();
|
|
}
|
|
|
|
public void ResetSequence()
|
|
{
|
|
StopAllCoroutines();
|
|
|
|
hasPlayed = false;
|
|
|
|
if (rescueEvent != null)
|
|
rescueEvent.ResetEvent();
|
|
}
|
|
|
|
[ContextMenu("Test Sequence")]
|
|
private void TestSequence()
|
|
{
|
|
PlaySequence();
|
|
}
|
|
|
|
[ContextMenu("Reset Sequence")]
|
|
private void TestResetSequence()
|
|
{
|
|
ResetSequence();
|
|
}
|
|
} |