using UnityEngine; using UnityEngine.Rendering.Universal; using UnityEngine.U2D; namespace ET { public class PeachValleyComponentAwakeSystem: AwakeSystem { public override void Awake(PeachValleyComponent self) { self.Awake(); } } [FriendClass(typeof(PeachValleyComponent))] public static class PeachValleyComponentSystem { private const float MinutePerHouse = 60.0f; public static void Awake(this PeachValleyComponent self) { self.GlobalLight = GameObject.Find("/GlobalLight").GetComponent(); } public static void UpdateLightByTime(this PeachValleyComponent self, int hour, int minute) { if (hour > 0 && hour < 6) { self.GlobalLight.intensity = self.NightIntensity; } else if (hour >= 6 && hour < 16) { self.GlobalLight.color = self.DayColor; self.GlobalLight.intensity = self.DayIntensity; } else if (hour >= 16 && hour < 17) { float percent = minute / MinutePerHouse; self.GlobalLight.color = Color.Lerp(self.DayColor, self.SunsetColor, percent); self.GlobalLight.intensity = Mathf.Lerp(self.DayIntensity, self.SunsetIntensity, percent); } else if (hour >= 17 && hour < 18) { float percent = minute / MinutePerHouse; self.GlobalLight.intensity = Mathf.Lerp(self.SunsetIntensity, self.NightIntensity, percent); } else if (hour >= 18 && hour <= 24) { self.GlobalLight.color = self.DayColor; self.GlobalLight.intensity = self.NightIntensity; } } } }