чё то чё то есть
This commit is contained in:
1 parent
f632508497
commit
f12b4aef0d
14 files changed
+571
-97
No files matched your search
@@ -0,0 +1,53 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Scripts.PlayerUtils
|
||||
{
|
||||
public class PlayerUI : MonoBehaviour
|
||||
{
|
||||
[Header("Настройки Интерфейса")]
|
||||
[SerializeField] private bool showSpeedometer = true;
|
||||
|
||||
private PlayerMovement movement;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Берем ссылку на компонент передвижения через фасад Player
|
||||
movement = Player.Instance.Movement;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!showSpeedometer || movement == null) return;
|
||||
|
||||
// Читаем публичное свойство скорости (мы добавим его ниже)
|
||||
float speed = movement.CurrentSpeed;
|
||||
float csUnits = speed * 38.5f;
|
||||
|
||||
GUIStyle style = new GUIStyle
|
||||
{
|
||||
fontSize = 24,
|
||||
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, 500, 50), $"Speed: {speed:F1} m/s ({csUnits:F0} u/s){state}", style);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user