using System.Collections; using System.Collections.Generic; using UnityEngine; public class CountryData : MonoBehaviour { public string countryName = "Unknown"; public string countryNameUkr; public float utcOffset = 0f; public string utcLabel = "UTC+0"; public bool hasAnomaly = false; public string anomalyFact = ""; public Vector3 centerOnGlobe; [Header("DST")] public float baseUtcOffset = 0f; public string baseUtcLabel = "UTC+0"; public float dstUtcOffset = 0f; public string dstUtcLabel = "UTC+0"; public int dstStartMonth = 0; public int dstEndMonth = 0; private Material _mat; private static readonly int PropBase = Shader.PropertyToID("_BaseColor"); private static readonly int PropHover = Shader.PropertyToID("_HoverStrength"); private static readonly int PropSelect = Shader.PropertyToID("_SelectStrength"); public void Init(Material mat) { _mat = mat; } public void SetDefaultColor(Color color) { if (_mat != null) _mat.SetColor(PropBase, color); } public void OnHoverEnter() { if (_mat != null) _mat.SetFloat(PropHover, 0.35f); } public void OnHoverExit() { if (_mat != null) _mat.SetFloat(PropHover, 0f); } public void Select() { if (_mat != null) { _mat.SetFloat(PropHover, 0f); _mat.SetFloat(PropSelect, 1f); } } public void Deselect() { if (_mat != null) { _mat.SetFloat(PropHover, 0f); _mat.SetFloat(PropSelect, 0f); } } public void RefreshDST() { if (dstStartMonth == 0) return; int month = System.DateTime.Now.Month; bool isDST; if (dstStartMonth > dstEndMonth) isDST = (month >= dstStartMonth || month <= dstEndMonth); else isDST = (month >= dstStartMonth && month <= dstEndMonth); utcOffset = isDST ? dstUtcOffset : baseUtcOffset; utcLabel = isDST ? dstUtcLabel : baseUtcLabel; } public string GetCurrentTime() { System.TimeSpan offset = System.TimeSpan.FromMinutes(utcOffset * 60.0); System.DateTime local = System.DateTime.UtcNow + offset; return local.ToString("dd MMMM, HH:mm", new System.Globalization.CultureInfo("uk-UA")); } }