summaryrefslogtreecommitdiff
path: root/GameCode/DaytimeSensitiveLight.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-19 16:05:01 +0800
committerchai <215380520@qq.com>2024-05-19 16:05:01 +0800
commitc5f145786f4c6d2fe4bea831dfc16e52228920a5 (patch)
treea6ead7ea8266c767d58ed0f816dcd7a1dd75bd65 /GameCode/DaytimeSensitiveLight.cs
parent48b64e573a1709dc923cb9162b55be0246b3ff63 (diff)
* move
Diffstat (limited to 'GameCode/DaytimeSensitiveLight.cs')
-rw-r--r--GameCode/DaytimeSensitiveLight.cs83
1 files changed, 0 insertions, 83 deletions
diff --git a/GameCode/DaytimeSensitiveLight.cs b/GameCode/DaytimeSensitiveLight.cs
deleted file mode 100644
index da571d3..0000000
--- a/GameCode/DaytimeSensitiveLight.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System.Collections;
-using UnityEngine;
-
-[RequireComponent(typeof(Light))]
-public class DaytimeSensitiveLight : MonoBehaviour, DayNightCycle.IDaytimeSensitive
-{
- [SerializeField]
- private Color dayColor = Color.white;
-
- [SerializeField]
- private Color sunsetColor;
-
- [SerializeField]
- private Color nightColor;
-
- [SerializeField]
- private float dayToSunsetDuration = 2f;
-
- [SerializeField]
- private float sunsetToNightDuration = 2f;
-
- private Light targetLight;
-
- private void Start()
- {
- targetLight = GetComponent<Light>();
- DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this);
- }
-
- public void OnDawn_AfterSunrise()
- {
- }
-
- public void OnDusk()
- {
- StopAllCoroutines();
- StartCoroutine(ToNight());
- }
-
- public void OnDawn_BeforeSunrise()
- {
- StopAllCoroutines();
- StartCoroutine(ToDay());
- }
-
- private IEnumerator ToDay()
- {
- float timer2 = 0f;
- while (timer2 <= sunsetToNightDuration)
- {
- timer2 += Time.deltaTime;
- targetLight.color = Color.Lerp(nightColor, sunsetColor, timer2 / sunsetToNightDuration);
- yield return null;
- }
- timer2 = 0f;
- while (timer2 <= dayToSunsetDuration)
- {
- timer2 += Time.deltaTime;
- targetLight.color = Color.Lerp(sunsetColor, dayColor, timer2 / dayToSunsetDuration);
- yield return null;
- }
- targetLight.color = dayColor;
- }
-
- private IEnumerator ToNight()
- {
- float timer2 = 0f;
- while (timer2 <= dayToSunsetDuration)
- {
- timer2 += Time.deltaTime;
- targetLight.color = Color.Lerp(dayColor, sunsetColor, timer2 / dayToSunsetDuration);
- yield return null;
- }
- timer2 = 0f;
- while (timer2 <= sunsetToNightDuration)
- {
- timer2 += Time.deltaTime;
- targetLight.color = Color.Lerp(dayColor, nightColor, timer2 / sunsetToNightDuration);
- yield return null;
- }
- targetLight.color = nightColor;
- }
-}