코어, 벽, 적의 생성 및 충돌, 데미지 판정
This commit is contained in:
36
Assets/Scripts/GameBase/GameManager.cs
Normal file
36
Assets/Scripts/GameBase/GameManager.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement; // 씬 재시작용
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
private bool _isGameOver = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// Core의 파괴 이벤트를 구독
|
||||
Core.OnCoreDestroyed += GameOver;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Core.OnCoreDestroyed -= GameOver;
|
||||
}
|
||||
|
||||
private void GameOver()
|
||||
{
|
||||
if (_isGameOver) return;
|
||||
|
||||
_isGameOver = true;
|
||||
Debug.Log("Game Over! Core has been destroyed.");
|
||||
|
||||
// 여기에 패배 UI 표시 로직 등을 넣습니다.
|
||||
// 예: 3초 후 게임 재시작
|
||||
Invoke(nameof(RestartGame), 3f);
|
||||
}
|
||||
|
||||
private void RestartGame()
|
||||
{
|
||||
// 현재 활성화된 씬을 다시 로드
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user