웨이브 카운트 다운 중 플레이 타임 증가하지 않도록 수정

This commit is contained in:
Mingu Kim
2025-03-12 18:33:53 +09:00
parent 1c05f7a32c
commit 29ccef4231
2 changed files with 28 additions and 15 deletions

View File

@@ -25,6 +25,8 @@ namespace TON
private float nextWaveDelay = 5f; // 다음 웨이브 시작 전 대기 시간 private float nextWaveDelay = 5f; // 다음 웨이브 시작 전 대기 시간
private bool isWaitingForNextWave = false; private bool isWaitingForNextWave = false;
public bool isTimerRunning = false; // 타이머 실행 여부
[System.Serializable] [System.Serializable]
public class WaveData public class WaveData
{ {
@@ -58,6 +60,7 @@ namespace TON
private IEnumerator StartGameWithDelay() private IEnumerator StartGameWithDelay()
{ {
isTimerRunning = true; // 타이머 시작
// 초기 카운트다운 표시 // 초기 카운트다운 표시
float timer = initialDelay; float timer = initialDelay;
while (timer > 0) while (timer > 0)
@@ -75,6 +78,7 @@ namespace TON
waveCounter.text = null; waveCounter.text = null;
} }
isTimerRunning = false; // 타이머 종료
gameStarted = true; gameStarted = true;
StartNextWave(); StartNextWave();
} }
@@ -284,6 +288,8 @@ namespace TON
private IEnumerator StartNextWaveWithDelay() private IEnumerator StartNextWaveWithDelay()
{ {
isTimerRunning = true; // 타이머 시작
// 웨이브가 10이면 (즉, 10스테이지가 끝났으면) 또는 웨이브가 11이면 게임 종료 UI를 바로 보여줌 // 웨이브가 10이면 (즉, 10스테이지가 끝났으면) 또는 웨이브가 11이면 게임 종료 UI를 바로 보여줌
if (currentWave == 10 || currentWave == 11 || GameObject.Find("TON.Player").GetComponentInChildren<CharacterBase>() == null) if (currentWave == 10 || currentWave == 11 || GameObject.Find("TON.Player").GetComponentInChildren<CharacterBase>() == null)
{ {
@@ -302,6 +308,7 @@ namespace TON
yield return null; yield return null;
} }
isTimerRunning = false; // 타이머 종료
waveCounter.text = null; waveCounter.text = null;
isWaitingForNextWave = false; isWaitingForNextWave = false;

View File

@@ -22,6 +22,7 @@ namespace TON
private int lastMinutes = -1; private int lastMinutes = -1;
private int lastSeconds = -1; private int lastSeconds = -1;
private string cachedTimeString = "00:00"; private string cachedTimeString = "00:00";
private MonsterSpawner _monsterSpawner;
private string playerType; private string playerType;
@@ -39,6 +40,7 @@ namespace TON
character.OnSPChanged += UpdateSPBar; character.OnSPChanged += UpdateSPBar;
} }
_monsterSpawner = GameObject.FindObjectOfType<MonsterSpawner>();
// UI가 활성화될 때 저장된 값들로 업데이트 // UI가 활성화될 때 저장된 값들로 업데이트
RefreshUI(); RefreshUI();
} }
@@ -58,6 +60,7 @@ namespace TON
waveText.text = $"WAVE {StageManager.Singleton.waveCount + 1}"; waveText.text = $"WAVE {StageManager.Singleton.waveCount + 1}";
UpdatePlayTimeDisplay(); UpdatePlayTimeDisplay();
UpdateGameScore(); UpdateGameScore();
} }
@@ -68,18 +71,21 @@ namespace TON
private void UpdatePlayTimeDisplay() private void UpdatePlayTimeDisplay()
{ {
float playTime = StageManager.Singleton.PlayTime; if (_monsterSpawner != null && !_monsterSpawner.isTimerRunning)
int minutes = Mathf.FloorToInt(playTime / 60f);
int seconds = Mathf.FloorToInt(playTime % 60f);
// 시간이 변경된 경우에만 문자열 생성
if (minutes != lastMinutes || seconds != lastSeconds)
{ {
lastMinutes = minutes; float playTime = StageManager.Singleton.PlayTime - ((StageManager.Singleton.waveCount + 1) * 5);
lastSeconds = seconds;
cachedTimeString = $"time {minutes:00}:{seconds:00}"; int minutes = Mathf.FloorToInt(playTime / 60f);
playTimeText.text = cachedTimeString; int seconds = Mathf.FloorToInt(playTime % 60f);
// 시간이 변경된 경우에만 문자열 생성
if (minutes != lastMinutes || seconds != lastSeconds)
{
lastMinutes = minutes;
lastSeconds = seconds;
cachedTimeString = $"time {minutes:00}:{seconds:00}";
playTimeText.text = cachedTimeString;
}
} }
} }