Merge branch 'main' of https://www.nakjungit.site/sharedacc520k/WhaleAdventure_VR
This commit is contained in:
Binary file not shown.
@@ -21,7 +21,16 @@ public class RhythmManager : MonoBehaviour
|
||||
|
||||
[Header("오토플레이 (아이템)")]
|
||||
[SerializeField] private bool _autoPlay; // 켜지면 모든 노트를 판정선 도달 순간 자동 Perfect 처리
|
||||
[SerializeField] private RhythmStick[] _autoPlaySticks; // 인덱스 = Note.Lane. 오토플레이 시 자동으로 휘두를 스틱들
|
||||
[SerializeField] private RhythmStick[] _autoPlaySticks; // 인덱스 = Note.Lane. 오토플레이 시 자동으로 휘두를 "자동 전용" 스틱들 (그랩 X)
|
||||
|
||||
[Header("오토플레이 전환")]
|
||||
[Tooltip("자동 '체크'만 해도 즉시 숨길 수동(그랩) 스틱")]
|
||||
[SerializeField] private GameObject[] _manualSticks;
|
||||
[Tooltip("게임 시작 + 자동일 때만 숨길 실제 손 (체크만 했을 땐 유지 → 시작 버튼 등 조작 가능)")]
|
||||
[SerializeField] private GameObject[] _realHands;
|
||||
[Tooltip("게임 시작 + 자동일 때만 비활성화할 드럼패드 콜라이더")]
|
||||
[SerializeField] private Collider[] _drumPadColliders;
|
||||
// 자동 전용 스틱(손 포함)의 표시/숨김은 위 _autoPlaySticks의 GameObject를 그대로 토글한다.
|
||||
|
||||
[SerializeField] private GameObject StartButtonObj;
|
||||
|
||||
@@ -37,6 +46,8 @@ public class RhythmManager : MonoBehaviour
|
||||
private int _nextNoteIndex; // 다음에 소환할 노트 인덱스
|
||||
private bool _isPlaying; //곡이 재생 중인지 (종료 감지용)
|
||||
private bool _isCountingDown; // 시작 카운트다운 진행 중 여부 (중복 클릭 방지용)
|
||||
private bool _armedApplied; // 반영된 armed 상태 (자동 체크 → 수동 스틱 숨김)
|
||||
private bool _activeApplied; // 반영된 active 상태 (자동+진행 중 → 자동 스틱/손/드럼패드)
|
||||
private double _dspSongStart; // 오디오가 실제 시작되는 dsp 시각 (= SongTime 0 지점)
|
||||
private float _clipLength; // 곡 길이 캐시 (종료 감지용)
|
||||
private Func<float> _songTimeProvider; // 노트에 넘길 시간 제공자 (매 스폰마다 람다 재생성 방지용 캐시)
|
||||
@@ -69,10 +80,17 @@ private void Start()
|
||||
InputManager.Instance.OnKey_Right_Event += OnPlayerInput;
|
||||
|
||||
_rhythmCats = FindObjectsByType<RhythmCat>(FindObjectsSortMode.None);
|
||||
|
||||
// 첫 Sync가 현재 상태를 반드시 한 번 반영하도록 반대값으로 초기화
|
||||
_armedApplied = !_autoPlay;
|
||||
_activeApplied = !AutoPlayActive;
|
||||
SyncAutoPlayState();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SyncAutoPlayState(); // _autoPlay 변화를 매 프레임 감지(변화 없으면 즉시 반환) — 인스펙터 토글도 반영
|
||||
|
||||
if (!_isPlaying) return;
|
||||
|
||||
//곡이 끝나면(리드인 지나 곡 길이 도달) 정지·주변음 복구
|
||||
@@ -159,7 +177,70 @@ public void ChangeSong()
|
||||
}
|
||||
|
||||
// 오토플레이 아이템 사용: 곡 시작 전(또는 도중)에 호출하면 남은 노트가 전부 자동 Perfect
|
||||
public void EnableAutoPlay() => _autoPlay = true;
|
||||
public void EnableAutoPlay()
|
||||
{
|
||||
_autoPlay = true;
|
||||
SyncAutoPlayState(); // 자동 스틱 켜고, 수동 스틱·손·드럼패드 콜라이더 끔
|
||||
}
|
||||
|
||||
// UI Toggle 등에서 직접 연결용. 토글의 On Value Changed(bool)가 넘기는 값으로 켜고/끈다.
|
||||
public void SetAutoPlay(bool on)
|
||||
{
|
||||
if (on) EnableAutoPlay();
|
||||
else DisableAutoPlay();
|
||||
}
|
||||
|
||||
// 오토플레이 수동 해제 (곡 도중에 꺼야 할 때). 곡 종료 시엔 StopSong이 알아서 끈다.
|
||||
public void DisableAutoPlay()
|
||||
{
|
||||
_autoPlay = false;
|
||||
|
||||
if (_autoPlaySticks != null) // 들려있던 자동 스틱 대기 자세로 복귀
|
||||
foreach (RhythmStick stick in _autoPlaySticks)
|
||||
if (stick != null) stick.ResetPose();
|
||||
|
||||
SyncAutoPlayState(); // 수동 스틱·손·드럼패드 콜라이더 복구
|
||||
}
|
||||
|
||||
// 오토플레이 상태를 두 단계로 나눠 비주얼에 반영 (변화 있을 때만):
|
||||
// - armed = 자동 '체크'만 해도 ON → 수동 스틱 숨김 (손/자동스틱은 그대로)
|
||||
// - active = 자동 + 곡 진행 중 → 자동 스틱 표시 + 실제 손 숨김 + 드럼패드 콜라이더 OFF
|
||||
// 자동 스틱/손 전환 기준: 자동이면서 카운트다운 시작~곡 종료 사이
|
||||
private bool AutoPlayActive => _autoPlay && (_isCountingDown || _isPlaying);
|
||||
|
||||
private void SyncAutoPlayState()
|
||||
{
|
||||
bool armed = _autoPlay;
|
||||
bool active = AutoPlayActive;
|
||||
|
||||
if (armed != _armedApplied)
|
||||
{
|
||||
_armedApplied = armed;
|
||||
SetActiveAll(_manualSticks, !armed); // 자동 체크 시 수동 스틱만 숨김
|
||||
}
|
||||
|
||||
if (active != _activeApplied)
|
||||
{
|
||||
_activeApplied = active;
|
||||
|
||||
if (_autoPlaySticks != null) // 자동 전용 스틱(손 포함) 표시/숨김
|
||||
foreach (RhythmStick s in _autoPlaySticks)
|
||||
if (s != null) s.gameObject.SetActive(active);
|
||||
|
||||
SetActiveAll(_realHands, !active); // 진행 중일 때만 실제 손 숨김
|
||||
|
||||
if (_drumPadColliders != null)
|
||||
foreach (Collider col in _drumPadColliders)
|
||||
if (col != null) col.enabled = !active;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetActiveAll(GameObject[] objs, bool on)
|
||||
{
|
||||
if (objs == null) return;
|
||||
foreach (GameObject go in objs)
|
||||
if (go != null) go.SetActive(on);
|
||||
}
|
||||
|
||||
// 시작 버튼 핸들러: 곧장 시작하지 않고 VR 준비 시간(카운트다운) 후 BeginSong 호출
|
||||
public void StartSong()
|
||||
@@ -175,6 +256,7 @@ public void StartSong()
|
||||
private async Awaitable CountdownThenBeginAsync()
|
||||
{
|
||||
_isCountingDown = true;
|
||||
SyncAutoPlayState(); // 자동이면 카운트다운 시작 순간 자동 스틱 표시 + 실제 손 숨김
|
||||
try
|
||||
{
|
||||
OnCountdownStarted?.Invoke(); // CountdownHud 표시
|
||||
@@ -227,6 +309,7 @@ private void BeginSong()
|
||||
_audioSource.PlayScheduled(_dspSongStart);
|
||||
|
||||
_isPlaying = true;
|
||||
SyncAutoPlayState(); // 자동이면 이 순간 자동 스틱 표시 + 실제 손 숨김
|
||||
|
||||
//BGM·환경음을 낮춰 리듬게임 소리만 들리게
|
||||
if (SoundManager.Instance != null) SoundManager.Instance.EnterMinigameMode();
|
||||
@@ -250,6 +333,7 @@ public void StopSong()
|
||||
if (stick != null) stick.ResetPose();
|
||||
|
||||
_autoPlay = false; // 아이템 효과는 한 곡만 — 곡이 끝나면 자동 해제
|
||||
SyncAutoPlayState(); // 수동 스틱·손·드럼패드 콜라이더 복구
|
||||
|
||||
if (SoundManager.Instance != null) SoundManager.Instance.ExitMinigameMode();
|
||||
|
||||
|
||||
Binary file not shown.
BIN
Assets/04_Models/Objects/WoodStick/Prefabs/WoodStick_L_Auto.prefab
LFS
Normal file
BIN
Assets/04_Models/Objects/WoodStick/Prefabs/WoodStick_L_Auto.prefab
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5a31f7553931d040929ae493c235d80
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
BIN
Assets/04_Models/Objects/WoodStick/Prefabs/WoodStick_R_Auto.prefab
LFS
Normal file
BIN
Assets/04_Models/Objects/WoodStick/Prefabs/WoodStick_R_Auto.prefab
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca6f82f80c095564aa50394261deab85
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user