144 lines
3.2 KiB
C#
144 lines
3.2 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UniStorm_Clock_C : MonoBehaviour
|
|
{
|
|
private UniStormWeatherSystem_C uniStormSystem;
|
|
|
|
private AzureSky_Controller azureSkyController;
|
|
|
|
private GameObject uniStormObject;
|
|
|
|
private GlobalSettings globalSettings;
|
|
|
|
private GameController gameController;
|
|
|
|
public bool use12hourclock;
|
|
|
|
public Text ClockText;
|
|
|
|
public Text DateText;
|
|
|
|
public Text TempText;
|
|
|
|
public Text WindText;
|
|
|
|
public Image WeatherImage;
|
|
|
|
public Image SeasonImage;
|
|
|
|
public Image MoonImage;
|
|
|
|
private float WeatherUpdateTimer;
|
|
|
|
public float WeatherUpdateSeconds = 30f;
|
|
|
|
public Sprite ClearWeatherIcon;
|
|
|
|
public Sprite MostlyClearWeatherIcon;
|
|
|
|
public Sprite PartlyCloudyWeatherIcon;
|
|
|
|
public Sprite MostlyCloudyWeatherIcon;
|
|
|
|
public Sprite LightRainWeatherIcon;
|
|
|
|
public Sprite HeavyRainWeatherIcon;
|
|
|
|
public Sprite ThunderStormsWeatherIcon;
|
|
|
|
public Sprite LightSnowWeatherIcon;
|
|
|
|
public Sprite HeavySnowWeatherIcon;
|
|
|
|
public Sprite FoggyWeatherIcon;
|
|
|
|
public Sprite WindyWeatherIcon;
|
|
|
|
public Sprite SpringIcon;
|
|
|
|
public Sprite SummerIcon;
|
|
|
|
public Sprite FallIcon;
|
|
|
|
public Sprite WinterIcon;
|
|
|
|
public Sprite MoonPhase1Icon;
|
|
|
|
public Sprite MoonPhase2Icon;
|
|
|
|
public Sprite MoonPhase3Icon;
|
|
|
|
public Sprite MoonPhase4Icon;
|
|
|
|
public Sprite MoonPhase5Icon;
|
|
|
|
public Sprite MoonPhase6Icon;
|
|
|
|
public Sprite MoonPhase7Icon;
|
|
|
|
public Sprite MoonPhase8Icon;
|
|
|
|
private void Start()
|
|
{
|
|
gameController = GameController.Instance;
|
|
uniStormObject = GameObject.Find("UniStormSystemEditor");
|
|
if ((bool)uniStormObject)
|
|
{
|
|
uniStormSystem = uniStormObject.GetComponent<UniStormWeatherSystem_C>();
|
|
}
|
|
azureSkyController = UnityEngine.Object.FindObjectOfType<AzureSky_Controller>();
|
|
globalSettings = GlobalSettings.Instance;
|
|
WeatherUpdateTimer = WeatherUpdateSeconds - 0.25f;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((!gameController || gameController.isInitialized) && (!(uniStormSystem == null) || !(azureSkyController == null)))
|
|
{
|
|
if (!use12hourclock)
|
|
{
|
|
ClockText.text = gameController.weatherLevelManager.GetHour() + ":" + gameController.weatherLevelManager.GetMinutes().ToString("00");
|
|
}
|
|
TempText.text = UtilitiesUnits.GetTemperatureString(gameController.weatherLevelManager.GetTemperature());
|
|
WindText.text = UtilitiesUnits.GetUnitsWind((float)Math.Round(gameController.weatherLevelManager.GetWindHUDSpeed(), 1)).ToString("F1") + " " + UtilitiesUnits.GetUnitNameWind();
|
|
WeatherUpdateTimer += Time.deltaTime;
|
|
if (WeatherUpdateTimer >= WeatherUpdateSeconds)
|
|
{
|
|
UpdateIconsNew();
|
|
UpdateIcons();
|
|
WeatherUpdateTimer = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void UpdateIconsNew()
|
|
{
|
|
if (gameController.weatherLevelManager.GetPercipitation() == 1f)
|
|
{
|
|
WeatherImage.sprite = HeavyRainWeatherIcon;
|
|
}
|
|
else if (gameController.weatherLevelManager.cloudiness == 0f)
|
|
{
|
|
WeatherImage.sprite = ClearWeatherIcon;
|
|
}
|
|
else if (gameController.weatherLevelManager.cloudiness < 0.2f)
|
|
{
|
|
WeatherImage.sprite = MostlyClearWeatherIcon;
|
|
}
|
|
else if (gameController.weatherLevelManager.cloudiness < 0.8f)
|
|
{
|
|
WeatherImage.sprite = PartlyCloudyWeatherIcon;
|
|
}
|
|
else
|
|
{
|
|
WeatherImage.sprite = MostlyCloudyWeatherIcon;
|
|
}
|
|
}
|
|
|
|
public void UpdateIcons()
|
|
{
|
|
}
|
|
}
|