2026-06-23 클리어시 문생성 (진행중)

This commit is contained in:
2026-06-23 11:00:03 +09:00
parent 5ef59f1c21
commit f5a93875f6
3 changed files with 32 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
public enum Result { Perfect, Good, Bad, Miss } public enum Result { Perfect, Good, Bad, Miss }
@@ -40,6 +41,12 @@ public class RhythmManager : MonoBehaviour
[SerializeField] private AudioClip _countdownBeep; // 매초 카운트 효과음 (5,4,3,2,1) [SerializeField] private AudioClip _countdownBeep; // 매초 카운트 효과음 (5,4,3,2,1)
[SerializeField] private AudioClip _countdownGoSfx; // 카운트 끝(GO) 효과음 (선택) [SerializeField] private AudioClip _countdownGoSfx; // 카운트 끝(GO) 효과음 (선택)
[Header("게임 종료 후 이벤트")]
[SerializeField] private int _targetScore = 1000; // 이 점수 이상이면 성공(OnCleared), 미만이면 실패(OnFailed)
[SerializeField] private float _postGameDelay = 3f; // 곡 종료 후 이벤트까지 대기 시간(초)
[SerializeField] private UnityEvent _onCleared; // 성공 시 (지연 후) 호출 — 인스펙터에서 연결
[SerializeField] private UnityEvent _onFailed; // 실패 시 (지연 후) 호출 — 인스펙터에서 연결
// 모든 타이밍의 기준. 오디오 클럭(dspTime) 기반이라 리드인 동안 음수(-leadTime→0)로 흐른다 // 모든 타이밍의 기준. 오디오 클럭(dspTime) 기반이라 리드인 동안 음수(-leadTime→0)로 흐른다
public float SongTime => (float)(AudioSettings.dspTime - _dspSongStart); public float SongTime => (float)(AudioSettings.dspTime - _dspSongStart);
@@ -341,12 +348,33 @@ public void StopSong()
OnSongFinished?.Invoke(Score); // 결과창 표시 OnSongFinished?.Invoke(Score); // 결과창 표시
// 게임 종료 후 지연 이벤트 (목표 점수 도달 여부로 성공/실패 분기)
_ = PostGameEventAsync(Score.Score >= _targetScore);
for(int i=0;i<_rhythmCats.Length;i++) for(int i=0;i<_rhythmCats.Length;i++)
{ {
_rhythmCats[i].DanceStop(); _rhythmCats[i].DanceStop();
} }
} }
// 곡 종료 후 _postGameDelay초 대기한 뒤 성공/실패 이벤트 호출.
// cleared는 종료 시점에 판정해서 넘긴다(지연 중 점수가 바뀌지 않지만 의도 명확화).
private async Awaitable PostGameEventAsync(bool cleared)
{
try
{
if (_postGameDelay > 0f)
await Awaitable.WaitForSecondsAsync(_postGameDelay, destroyCancellationToken);
}
catch (OperationCanceledException)
{
return; // 대기 중 오브젝트 파괴 시 이벤트 호출 안 함
}
if (cleared) _onCleared?.Invoke();
else _onFailed?.Invoke();
}
// 노트가 판정선을 지나쳐 스스로 Miss 처리될 때 호출 (노트는 이미 자기 파괴됨) // 노트가 판정선을 지나쳐 스스로 Miss 처리될 때 호출 (노트는 이미 자기 파괴됨)
private void OnNoteMissed(RhythmNoteInstance note) private void OnNoteMissed(RhythmNoteInstance note)
{ {