59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
// GameSettingsManager.cs
|
|
// Zweck: Zentrale Schalter für SFX/VFX/Musik/Score, Singleton + Weitergabe an Subsysteme.
|
|
using UnityEngine;
|
|
|
|
public class GameSettingsManager : MonoBehaviour
|
|
{
|
|
public static GameSettingsManager Instance { get; private set; }
|
|
|
|
[Header("Defaults")]
|
|
[SerializeField] private bool sfxEnabled = true;
|
|
[SerializeField] private bool vfxEnabled = true;
|
|
[SerializeField] private bool musicEnabled = true;
|
|
[SerializeField] private bool scoreEnabled = true;
|
|
|
|
public bool SfxEnabled => sfxEnabled;
|
|
public bool VfxEnabled => vfxEnabled;
|
|
public bool MusicEnabled => musicEnabled;
|
|
public bool ScoreEnabled => scoreEnabled;
|
|
|
|
private void Awake()
|
|
{
|
|
// Singleton + persistieren
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
|
|
// Startzustand auf Systeme anwenden
|
|
ApplyAll();
|
|
}
|
|
|
|
private void ApplyAll()
|
|
{
|
|
SetMusicEnabled(musicEnabled);
|
|
SetScoreEnabled(scoreEnabled);
|
|
// SFX/VFX werden dort berücksichtigt, wo sie genutzt werden.
|
|
}
|
|
|
|
public void SetSfxEnabled(bool value) { sfxEnabled = value; }
|
|
public void SetVfxEnabled(bool value) { vfxEnabled = value; }
|
|
|
|
public void SetMusicEnabled(bool value)
|
|
{
|
|
musicEnabled = value;
|
|
if (MusicManager.Instance != null)
|
|
MusicManager.Instance.SetMuted(!musicEnabled);
|
|
}
|
|
|
|
public void SetScoreEnabled(bool value)
|
|
{
|
|
scoreEnabled = value;
|
|
if (ScoreHUD.Instance != null)
|
|
ScoreHUD.Instance.SetVisible(scoreEnabled);
|
|
}
|
|
}
|