Files
Souljack/Assets/_Project/Scripts/PlayerUtils/PlayerUI.cs
T

60 lines
2.4 KiB
C#
Raw Normal View History

2026-09-22 21:08:47 +03:00
using UnityEngine;
namespace _Project.Scripts.PlayerUtils
{
public class PlayerUI : MonoBehaviour
{
[Header("Настройки Интерфейса")]
[SerializeField] private bool showHUD = true;
2026-09-22 21:08:47 +03:00
private PlayerMovement movement;
private PlayerPossession possession;
2026-09-22 21:08:47 +03:00
private void Start()
{
movement = Player.Instance.Movement;
possession = Player.Instance.Possession;
2026-09-22 21:08:47 +03:00
}
private void OnGUI()
{
if (!showHUD || movement == null) return;
2026-09-22 21:08:47 +03:00
float speed = movement.CurrentSpeed;
float csUnits = speed * 38.5f;
GUIStyle style = new GUIStyle { fontSize = 22, fontStyle = FontStyle.Bold };
2026-09-22 21:08:47 +03:00
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;
2026-09-22 21:08:47 +03:00
GUI.Label(new Rect(30, 30, 600, 40), $"Speed: {speed:F1} m/s ({csUnits:F0} u/s){state}", style);
2026-09-22 21:08:47 +03:00
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);
}
}
}
2026-09-22 21:08:47 +03:00
}
}
}