Интерфейс в процессе

This commit is contained in:
ThomasCharester committed 2025-10-31 23:19:16 +03:00
1 parent bea109175b
commit 45fe19be24
53 files changed
+2527 -64

No files matched your search

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 271d8609b0d94575a2e61c48d3b46d63
timeCreated: 1761917025
@@ -0,0 +1,18 @@
using Code.Gameplay.Player;
using UnityEngine;
using UnityEngine.UI;
namespace Code.UI.GameplayElements
{
public class HealthBar : MonoBehaviour
{
[SerializeField] private Image healthBar;
public void HealthUpdate(int count, PlayerHealth health)
{
// TODO Анимация потери
float fillAmount = (float)health.HealthPoints / health.MaxHealthPoints;
healthBar.fillAmount = fillAmount;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ddb267271c834c6697caff23709d30a2
timeCreated: 1761917038
@@ -0,0 +1,16 @@
using TMPro;
using UnityEngine;
namespace Code.UI.GameplayElements
{
public class MoneyBar : MonoBehaviour
{
[SerializeField] private TMP_Text moneyText;
public void MoneyUpdate(int count, int money)
{
// TODO Анимация получения\потери
moneyText.text = money.ToString();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 02373b82fefd4812ac1d6d97d65fc9f0
timeCreated: 1761917491
+12 -21
View File
@@ -1,4 +1,5 @@
using Code.Gameplay.Player;
using Code.UI.GameplayElements;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -7,34 +8,24 @@ namespace Code.UI
{
public class GameplayPanel : UIElement
{
[SerializeField] private Image healthBar;
[SerializeField] private Image dispatcher;
[SerializeField] private TMP_Text moneyText;
[SerializeField] private TMP_Text timer;
private HealthBar _healthBar;
private MoneyBar _moneyBar;
private int _maxHealth;
public void Initialize(PlayerMoney money, PlayerHealth health)
public void Initialize(PlayerMoney money, PlayerHealth health, HealthBar healthBar = null, MoneyBar moneyBar = null)
{
money.OnMoneyGet += MoneyUpdate;
money.OnMoneyLoose += MoneyUpdate;
_healthBar = healthBar;
_moneyBar = moneyBar;
moneyText.text = money.Money.ToString();
money.OnMoneyGet += _moneyBar.MoneyUpdate;
money.OnMoneyLoose += _moneyBar.MoneyUpdate;
_moneyBar.MoneyUpdate(0,money.Money);
health.OnDamage += HealthUpdate;
healthBar.fillAmount = (float)health.HealthPoints / _maxHealth * 100f;
health.OnDamage += _healthBar.HealthUpdate;
_healthBar.HealthUpdate(0,health);
_maxHealth = health.MaxHealthPoints;
}
private void MoneyUpdate(int count, int money)
{
// TODO Анимация получения\потери
moneyText.text = money.ToString();
}
private void HealthUpdate(int count, int health)
{
// TODO Анимация потери
healthBar.fillAmount = (float)health / _maxHealth * 100f;
}
private void Update()
{
@@ -0,0 +1,11 @@
using Code.UI.GameplayElements;
using UnityEngine;
namespace Code.UI
{
public interface IUIFactory
{
MoneyBar CreateMoneybar(Canvas canvas);
HealthBar CreateHealthbar(Canvas canvas);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 61892c4ae3ab4b1498c3df219c5c75d6
timeCreated: 1761922548
@@ -0,0 +1,15 @@
using Code.UI.GameplayElements;
using Reflex.Attributes;
using UnityEngine;
namespace Code.UI
{
public class UIFactory : IUIFactory
{
[Inject] private HealthBar healthbarPrefab;
[Inject] private MoneyBar moneybarPrefab;
public MoneyBar CreateMoneybar(Canvas canvas) => Object.Instantiate(moneybarPrefab, canvas.transform);
public HealthBar CreateHealthbar(Canvas canvas) => Object.Instantiate(healthbarPrefab, canvas.transform);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2250767e26ad4e0aa313b80087696ea9
timeCreated: 1761922359