Files
UltimateFishing2020/Assets/Scripts/Assembly-CSharp/GameWeatherManager.cs
2026-03-04 10:03:45 +08:00

79 lines
2.1 KiB
C#

using UnityEngine;
using UnityEngine.AzureSky;
using UnityEngine.SceneManagement;
using _Data.Variabales.DayWeather;
public class GameWeatherManager : MonoBehaviour
{
[Header("This component must be plugged in to Azure Prefab")]
private AzureTimeController timeController;
private AzureWeatherController weatherController;
private AzureEnvironmentController environmentController;
[SerializeField]
private ScriptableEnumWeatherType weather;
[SerializeField]
private ScriptableTimeDayVariable timeOfDay;
[SerializeField]
private float morningTime = 6f;
[SerializeField]
private float noonTime = 12f;
[SerializeField]
private float eveningTime = 16f;
[SerializeField]
private float nightTime = 22f;
private void Awake()
{
timeController = GetComponent<AzureTimeController>();
weatherController = GetComponent<AzureWeatherController>();
environmentController = GetComponent<AzureEnvironmentController>();
weather.OnValueChanged += WeatherOnOnValueChanged;
timeOfDay.OnValueChanged += TimeOfDayOnOnValueChanged;
}
private void Start()
{
if (SceneManager.GetActiveScene().name == "Tutorial Map" || SceneManager.GetActiveScene().name == "Residence")
{
timeOfDay.Value = morningTime;
timeController.SetTimeline(timeOfDay);
weatherController.SetNewWeatherProfile(0);
return;
}
TimeOfDay timeOfDayFromHour = timeOfDay.GetTimeOfDayFromHour();
timeOfDay.Morning = morningTime;
timeOfDay.Noon = noonTime;
timeOfDay.Evening = eveningTime;
timeOfDay.Night = nightTime;
timeOfDay.SetDayTime(timeOfDayFromHour);
timeController.SetTimeline(timeOfDay);
weatherController.SetNewWeatherProfile(weather.GetWeatherId());
}
private void TimeOfDayOnOnValueChanged(float obj)
{
timeController.SetTimeline(obj);
environmentController.UpdateReflectionProbe();
}
private void WeatherOnOnValueChanged(Weather obj)
{
weatherController.SetNewWeatherProfile((int)obj);
environmentController.UpdateReflectionProbe();
}
private void OnDestroy()
{
weather.OnValueChanged -= WeatherOnOnValueChanged;
timeOfDay.OnValueChanged -= TimeOfDayOnOnValueChanged;
}
}