61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using Code.Gameplay.Player;
|
|
using DG.Tweening;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Code.UI.Panels
|
|
{
|
|
public class GameplayPanel : UIElement
|
|
{
|
|
[Header("Dispatcher")]
|
|
[SerializeField] private Image dispatcher;
|
|
[SerializeField] private RectTransform dispatcherHiddenPosition;
|
|
[SerializeField] private RectTransform dispatcherShownPosition;
|
|
[SerializeField] private float dispatcherTransitionTime = 0.5f;
|
|
[Header("Timer")]
|
|
[SerializeField] private TMP_Text timer;
|
|
public TMP_Text Timer => timer;
|
|
[Header("HealthBar")]
|
|
[SerializeField] private Image healthBar;
|
|
[Header("MoneyBar")]
|
|
[SerializeField] private TMP_Text moneyText;
|
|
|
|
private void MoneyUpdate(int count, int money)
|
|
{
|
|
// TODO Анимация получения\потери
|
|
moneyText.text = money.ToString();
|
|
}
|
|
private void HealthUpdate(int count, PlayerHealth health)
|
|
{
|
|
// TODO Анимация потери
|
|
float fillAmount = (float)health.HealthPoints / health.MaxHealthPoints;
|
|
healthBar.fillAmount = fillAmount;
|
|
}
|
|
public void Initialize(PlayerMoney money, PlayerHealth health)
|
|
{
|
|
money.OnMoneyGet += MoneyUpdate;
|
|
money.OnMoneyLoose += MoneyUpdate;
|
|
MoneyUpdate(0,money.Money);
|
|
|
|
health.OnDamage += HealthUpdate;
|
|
HealthUpdate(0,health);
|
|
}
|
|
public void SummonDispatcher()
|
|
{
|
|
// TODO
|
|
dispatcher.transform.DOMoveX(dispatcherShownPosition.position.x, dispatcherTransitionTime);
|
|
}
|
|
public void CloseDispatcher()
|
|
{
|
|
dispatcher.transform.DOMoveX(dispatcherHiddenPosition.position.x, dispatcherTransitionTime);
|
|
// TODO
|
|
}
|
|
public override void Hide()
|
|
{
|
|
}
|
|
public override void Show()
|
|
{
|
|
}
|
|
}
|
|
} |