Files
WhaleAdventure_VR/Assets/02_Scripts/Managers/GameManager.cs
2026-06-11 15:32:56 +09:00

39 lines
1.1 KiB
C#

using System;
using UnityEngine;
public class GameManager : MonoBehaviour,ISceneInitializable
{
public static GameManager Instance;
//현재 플레이어가 위치한 구역 (구역 상태의 단일 진실 출처)
public Zone CurrentZone { get; private set; } = Zone.None;
//구역이 바뀌면 발생. 사운드 등 여러 시스템이 구독해서 반응한다.
public event Action<Zone> OnZoneChanged;
private void Awake()
{
if (Instance == null)
{
Instance = this; //만들어진 자신을 인스턴스로 설정
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject); //이미 인스턴스가 있으면 자신을 파괴
}
}
//구역 변경 요청 (ZoneTrigger 등에서 호출)
public void SetZone(Zone zone)
{
if (zone == CurrentZone) return; //같은 구역이면 무시
CurrentZone = zone;
OnZoneChanged?.Invoke(zone); //구독자(SoundManager 등)에게 통지
}
public void OnSceneLoaded()
{
}
}