84 lines
2.1 KiB
C#
84 lines
2.1 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class JunpyoRescueEvent : MonoBehaviour
|
|
{
|
|
[Header("Event Components")]
|
|
[SerializeField] private JunpyoRunToPoint junpyoRun;
|
|
[SerializeField] private PlayerPushToPoint playerPush;
|
|
[SerializeField] private SpotlightFall spotlightFall;
|
|
|
|
[Header("Timing")]
|
|
[Tooltip("구준표가 출발한 뒤 플레이어를 밀 때까지 시간")]
|
|
[SerializeField] private float pushDelay = 1.0f;
|
|
|
|
[Tooltip("플레이어를 민 뒤 조명이 떨어질 때까지 시간")]
|
|
[SerializeField] private float spotlightDelayAfterPush = 0.1f;
|
|
|
|
private bool hasPlayed;
|
|
|
|
public void PlayRescueEvent()
|
|
{
|
|
if (hasPlayed)
|
|
return;
|
|
|
|
if (junpyoRun == null ||
|
|
playerPush == null ||
|
|
spotlightFall == null)
|
|
{
|
|
Debug.LogWarning(
|
|
"[JunpyoRescueEvent] 연결되지 않은 컴포넌트가 있습니다."
|
|
);
|
|
return;
|
|
}
|
|
|
|
hasPlayed = true;
|
|
StartCoroutine(RescueRoutine());
|
|
}
|
|
|
|
private IEnumerator RescueRoutine()
|
|
{
|
|
// 1. 구준표가 달려오기 시작
|
|
junpyoRun.RunToStopPoint();
|
|
|
|
// 2. 구준표가 거의 도착할 때까지 대기
|
|
yield return new WaitForSeconds(pushDelay);
|
|
|
|
// 3. 플레이어 밀기
|
|
playerPush.PushPlayerOnce();
|
|
|
|
// 4. 밀린 직후 잠깐 기다림
|
|
yield return new WaitForSeconds(spotlightDelayAfterPush);
|
|
|
|
// 5. 조명 떨어뜨리기
|
|
spotlightFall.DropSpotlight();
|
|
}
|
|
|
|
public void ResetEvent()
|
|
{
|
|
StopAllCoroutines();
|
|
|
|
hasPlayed = false;
|
|
|
|
if (junpyoRun != null)
|
|
junpyoRun.ResetMovement();
|
|
|
|
if (playerPush != null)
|
|
playerPush.ResetPush();
|
|
|
|
if (spotlightFall != null)
|
|
spotlightFall.ResetFall();
|
|
}
|
|
|
|
[ContextMenu("Test Rescue Event")]
|
|
private void TestRescueEvent()
|
|
{
|
|
PlayRescueEvent();
|
|
}
|
|
|
|
[ContextMenu("Reset Rescue Event")]
|
|
private void TestResetEvent()
|
|
{
|
|
ResetEvent();
|
|
}
|
|
} |