using System; using UnityEngine; // ReSharper disable once CheckNamespace namespace BlueWaterProject { public class CombatLight : MonoBehaviour { public enum TimeOfDay { NONE = -1, BASE, AFTERNOON, SUNSET, NIGHT } [SerializeField] private Light baseDirectionalLight; [SerializeField] private Light afternoonDirectionalLight; [SerializeField] private Light sunsetDirectionalLight; [SerializeField] private Light nightDirectionalLight; [SerializeField] private TimeOfDay currentTimeOfDay; public TimeOfDay CurrentTimeOfDay { get => currentTimeOfDay; set { currentTimeOfDay = value; SetCurrentTimeOfDay(); } } private void OnValidate() { SetCurrentTimeOfDay(); } private void SetCurrentTimeOfDay() { DisableAllLights(); switch (currentTimeOfDay) { case TimeOfDay.NONE: break; case TimeOfDay.BASE: EnableLight(baseDirectionalLight); break; case TimeOfDay.AFTERNOON: EnableLight(afternoonDirectionalLight); break; case TimeOfDay.SUNSET: EnableLight(sunsetDirectionalLight); break; case TimeOfDay.NIGHT: EnableLight(nightDirectionalLight); break; default: throw new ArgumentOutOfRangeException(nameof(currentTimeOfDay), currentTimeOfDay, null); } } private void DisableAllLights() { baseDirectionalLight.enabled = false; afternoonDirectionalLight.enabled = false; sunsetDirectionalLight.enabled = false; nightDirectionalLight.enabled = false; } private void EnableLight(Light enableLight) { enableLight.enabled = true; } } }