using UnityEngine; using System.Collections.Generic; public class GameManager : MonoBehaviour { public static GameManager Instance; public List allSwitches = new List(); void Awake() { if (Instance == null) Instance = this; else Destroy(gameObject); } public void RegisterSwitch(LightSwitch sw) { if (!allSwitches.Contains(sw)) allSwitches.Add(sw); } public void CheckLights() { bool anyLightsOn = false; foreach (LightSwitch sw in allSwitches) { if (sw.isLightOn) anyLightsOn = true; } if (!anyLightsOn) { Debug.Log("All lights are off. Player can go to bed."); // You can enable the "Bed" interaction collider here } } public void SpookyRelightEvent() { // Find all switches that are currently OFF List offSwitches = new List(); foreach (LightSwitch sw in allSwitches) { if (!sw.isLightOn) offSwitches.Add(sw); } // If we found any off switches, turn one back on randomly if (offSwitches.Count > 0) { LightSwitch target = offSwitches[Random.Range(0, offSwitches.Count)]; target.ForceLightOn(); Debug.Log("A light turned back on!"); } } public bool AreAnyLightsOn() { foreach (LightSwitch sw in allSwitches) { if (sw.isLightOn) return true; } return false; } }