2026-05-29 웨이브 시스템

This commit is contained in:
2026-05-29 11:10:00 +09:00
parent fbb2a53ea1
commit 7ad70e7997
31 changed files with 903 additions and 9 deletions

View File

@@ -72,4 +72,9 @@ private async void RunPhaseTransition()
_isTransitioning = false;
OnPhaseChanged?.Invoke(_currentPhase);
}
private void OnDestroy()
{
GameManager.Instance.WaveM.GameClear();
}
}

View File

@@ -1,7 +1,11 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Threading;
using TMPro;
using UnityEditor.Playables;
using UnityEngine;
using UnityEngine.UI;
// ============================================================================
// WaveManager
@@ -61,8 +65,15 @@ public class WaveManager : MonoBehaviour
private readonly List<Enemy> _aliveEnemies = new();
private CancellationTokenSource _waveCts; // 전체 웨이브 진행 취소 토큰 (OnDestroy/StopWaves에서 취소)
[SerializeField] private Button BossZoneButton;
public TMP_Text WaveText;
public TMP_Text GameClearText;
private void Start()
{
OnAllWavesCleared += StageClearEvent;
if (_startOnAwake) StartWaves();
}
@@ -72,11 +83,33 @@ private void OnDestroy()
_waveCts?.Dispose();
}
private async Awaitable WaveUIOn()
{
try
{
WaveText.text = $"Wave {CurrentWaveIndex + 1}";
WaveText.gameObject.SetActive(true);
await Awaitable.WaitForSecondsAsync(3.0f, destroyCancellationToken);
WaveText.gameObject.SetActive(false);
}
catch (System.OperationCanceledException)
{
}
}
// 외부에서 호출해 웨이브 시작 (예: UI 버튼, 트리거).
public void StartWaves()
{
Debug.Log("aaaa");
if (_waves == null || _waves.Count == 0) return;
RunAllWaves();
_ = WaveUIOn();
}
// 진행 중인 웨이브 강제 중단. 게임 오버/메뉴 진입 등에 사용.
@@ -249,6 +282,7 @@ private void DestroyAliveEnemies()
// 디버그용 OnGUI 표시. 실제 게임 UI는 별도로 구성하고 이건 빠르게 확인용.
private void OnGUI()
{
/*
GUIStyle style = new GUIStyle(GUI.skin.box)
{
fontSize = 22,
@@ -280,6 +314,7 @@ private void OnGUI()
}
GUI.Box(new Rect(Screen.width / 2f - 180f, 20f, 360f, 110f), text, style);
*/
}
private void OnDrawGizmosSelected()
@@ -312,4 +347,15 @@ private void OnDrawGizmosSelected()
}
}
}
public void StageClearEvent()
{
BossZoneButton.gameObject.SetActive(true);
}
public void GameClear()
{
GameClearText.gameObject.SetActive(true);
}
}

View File

@@ -1,3 +1,4 @@
using TMPro;
using UnityEngine;
public class GameManager : MonoBehaviour,ISceneInitializable
@@ -7,6 +8,8 @@ public class GameManager : MonoBehaviour,ISceneInitializable
public SkillSupport SkillSupporter {get; private set;}
public PlayerController LocalPlayer {get; private set;}
public WaveManager WaveM {get; private set;}
private void Awake()
{
@@ -22,8 +25,8 @@ private void Awake()
public void OnSceneLoaded()
{
Debug.Log("aaaa");
SkillSupporter = Object.FindFirstObjectByType<SkillSupport>();
LocalPlayer = Object.FindFirstObjectByType<PlayerController>();
WaveM = Object.FindFirstObjectByType<WaveManager>();
}
}