diff --git a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSpawner.cs b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSpawner.cs index 8ecc5d9d..5fb0f444 100644 --- a/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSpawner.cs +++ b/Gameton-06/Assets/Gameton/Scripts/Monster/MonsterSpawner.cs @@ -25,6 +25,8 @@ namespace TON private float nextWaveDelay = 5f; // 다음 웨이브 시작 전 대기 시간 private bool isWaitingForNextWave = false; + public bool isTimerRunning = false; // 타이머 실행 여부 + [System.Serializable] public class WaveData { @@ -58,6 +60,7 @@ namespace TON private IEnumerator StartGameWithDelay() { + isTimerRunning = true; // 타이머 시작 // 초기 카운트다운 표시 float timer = initialDelay; while (timer > 0) @@ -74,7 +77,8 @@ namespace TON { waveCounter.text = null; } - + + isTimerRunning = false; // 타이머 종료 gameStarted = true; StartNextWave(); } @@ -284,6 +288,8 @@ namespace TON private IEnumerator StartNextWaveWithDelay() { + isTimerRunning = true; // 타이머 시작 + // 웨이브가 10이면 (즉, 10스테이지가 끝났으면) 또는 웨이브가 11이면 게임 종료 UI를 바로 보여줌 if (currentWave == 10 || currentWave == 11 || GameObject.Find("TON.Player").GetComponentInChildren() == null) { @@ -301,7 +307,8 @@ namespace TON timer -= Time.deltaTime; yield return null; } - + + isTimerRunning = false; // 타이머 종료 waveCounter.text = null; isWaitingForNextWave = false; diff --git a/Gameton-06/Assets/Gameton/Scripts/UI/IngameUI.cs b/Gameton-06/Assets/Gameton/Scripts/UI/IngameUI.cs index cad53c4a..005a1a57 100644 --- a/Gameton-06/Assets/Gameton/Scripts/UI/IngameUI.cs +++ b/Gameton-06/Assets/Gameton/Scripts/UI/IngameUI.cs @@ -17,11 +17,12 @@ namespace TON public TextMeshProUGUI waveText; public TextMeshProUGUI playTimeText; public TextMeshProUGUI scoreText; - + // 플레이 시간 노출하게 하는 변수 private int lastMinutes = -1; private int lastSeconds = -1; private string cachedTimeString = "00:00"; + private MonsterSpawner _monsterSpawner; private string playerType; @@ -39,6 +40,7 @@ namespace TON character.OnSPChanged += UpdateSPBar; } + _monsterSpawner = GameObject.FindObjectOfType(); // UI가 활성화될 때 저장된 값들로 업데이트 RefreshUI(); } @@ -56,8 +58,9 @@ namespace TON private void Update() { waveText.text = $"WAVE {StageManager.Singleton.waveCount + 1}"; - + UpdatePlayTimeDisplay(); + UpdateGameScore(); } @@ -68,18 +71,21 @@ namespace TON private void UpdatePlayTimeDisplay() { - float playTime = StageManager.Singleton.PlayTime; - - int minutes = Mathf.FloorToInt(playTime / 60f); - int seconds = Mathf.FloorToInt(playTime % 60f); - - // 시간이 변경된 경우에만 문자열 생성 - if (minutes != lastMinutes || seconds != lastSeconds) + if (_monsterSpawner != null && !_monsterSpawner.isTimerRunning) { - lastMinutes = minutes; - lastSeconds = seconds; - cachedTimeString = $"time {minutes:00}:{seconds:00}"; - playTimeText.text = cachedTimeString; + float playTime = StageManager.Singleton.PlayTime - ((StageManager.Singleton.waveCount + 1) * 5); + + int minutes = Mathf.FloorToInt(playTime / 60f); + int seconds = Mathf.FloorToInt(playTime % 60f); + + // 시간이 변경된 경우에만 문자열 생성 + if (minutes != lastMinutes || seconds != lastSeconds) + { + lastMinutes = minutes; + lastSeconds = seconds; + cachedTimeString = $"time {minutes:00}:{seconds:00}"; + playTimeText.text = cachedTimeString; + } } }