From 29ccef4231237bef4e4100597524685ecb84c8df Mon Sep 17 00:00:00 2001 From: Mingu Kim Date: Wed, 12 Mar 2025 18:33:53 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9B=A8=EC=9D=B4=EB=B8=8C=20=EC=B9=B4?= =?UTF-8?q?=EC=9A=B4=ED=8A=B8=20=EB=8B=A4=EC=9A=B4=20=EC=A4=91=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=20=ED=83=80=EC=9E=84=20=EC=A6=9D=EA=B0=80?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gameton/Scripts/Monster/MonsterSpawner.cs | 11 +++++-- .../Assets/Gameton/Scripts/UI/IngameUI.cs | 32 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) 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; + } } }