using UnityEngine; namespace _Project.Scripts.PlayerUtils { public class PlayerUI : MonoBehaviour { [Header("Настройки Интерфейса")] [SerializeField] private bool showHUD = true; private PlayerMovement movement; private PlayerPossession possession; private void Start() { movement = Player.Instance.Movement; possession = Player.Instance.Possession; } private void OnGUI() { if (!showHUD || movement == null) return; float speed = movement.CurrentSpeed; float csUnits = speed * 38.5f; GUIStyle style = new GUIStyle { fontSize = 22, fontStyle = FontStyle.Bold }; string state = ""; if (movement.IsSliding) { style.normal.textColor = Color.yellow; state = " [SLIDE]"; } else if (!movement.IsGrounded) { style.normal.textColor = Color.green; state = " [AIR]"; } else style.normal.textColor = Color.white; GUI.Label(new Rect(30, 30, 600, 40), $"Speed: {speed:F1} m/s ({csUnits:F0} u/s){state}", style); if (possession != null && possession.CurrentProfile != null) { style.normal.textColor = possession.IsInSpiritForm ? Color.cyan : Color.green; string bodyInfo = $"Форма: {possession.CurrentProfile.displayName} | HP: {possession.CurrentHealth:F0}/{possession.MaxHealth:F0}"; if (!possession.IsInSpiritForm) bodyInfo += " ([Q] Покинуть тело)"; GUI.Label(new Rect(30, 65, 800, 40), bodyInfo, style); if (possession.AimedEnemy != null) { if (possession.IsTargetInPossessZone) { style.normal.textColor = Color.cyan; GUI.Label(new Rect(Screen.width / 2f - 160f, Screen.height / 2f + 40f, 450f, 40f), $"[E] ВСЕЛИТЬСЯ: {possession.AimedEnemy.enemyClass}", style); } else { style.normal.textColor = new Color(1f, 0.5f, 0.5f); GUI.Label(new Rect(Screen.width / 2f - 180f, Screen.height / 2f + 40f, 500f, 40f), $"ДАЛЕКО — ВОЙДИ В СФЕРУ ({possession.AimedEnemy.enemyClass})", style); } } } } } }