Интерфейс в процессе
This commit is contained in:
1 parent
bea109175b
commit
45fe19be24
53 files changed
+2527
-64
No files matched your search
@@ -33,14 +33,14 @@ namespace Code.App.AppStates
|
||||
_playerHealth = Context.PlayerFactory.CreatePlayerHealth();
|
||||
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.GiveHealth, GiveHealth);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.GiveMoney, GiveHealth);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.GiveMoney, GiveMoney);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseHealth, LooseHealth);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseMoney, LooseMoney);
|
||||
}
|
||||
|
||||
private void SceneLoaded()
|
||||
{
|
||||
((GameplayPanel)Context.UIService.CurrentPanel).Initialize(_playerMoney, _playerHealth);
|
||||
((GameplayPanel)(Context.UIService.CurrentPanel)).Initialize(_playerMoney, _playerHealth);
|
||||
Context.UIService.LoadingScreen.Hide();
|
||||
|
||||
base.EnterState();
|
||||
@@ -48,12 +48,16 @@ namespace Code.App.AppStates
|
||||
|
||||
private void GiveHealth(InputAction.CallbackContext context)
|
||||
{
|
||||
UnityEngine.Debug.Log("Giving health");
|
||||
_playerHealth.GetDamage(-1);
|
||||
UnityEngine.Debug.Log(_playerHealth.HealthPoints);
|
||||
}
|
||||
|
||||
private void LooseHealth(InputAction.CallbackContext context)
|
||||
{
|
||||
UnityEngine.Debug.Log("Losing health");
|
||||
_playerHealth.GetDamage(1);
|
||||
UnityEngine.Debug.Log(_playerHealth.HealthPoints);
|
||||
}
|
||||
|
||||
private void GiveMoney(InputAction.CallbackContext context)
|
||||
@@ -63,7 +67,7 @@ namespace Code.App.AppStates
|
||||
|
||||
private void LooseMoney(InputAction.CallbackContext context)
|
||||
{
|
||||
_playerMoney.GiveMoney(100);
|
||||
_playerMoney.LooseMoney(100);
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Code.UI;
|
||||
using Code.UI.GameplayElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
@@ -9,5 +10,10 @@ namespace Code.Configs
|
||||
{
|
||||
[FormerlySerializedAs("uiElements")] public UIElement[] uiElementsPrefabs;
|
||||
[FormerlySerializedAs("canvas")] public Canvas canvasPrefab;
|
||||
|
||||
[Header("GameplayPanel")]
|
||||
public HealthBar healthBarPrefab;
|
||||
public MoneyBar moneyBarPrefab;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Code.Gameplay.Player
|
||||
|
||||
public event OnDeathDelegate OnDeath;
|
||||
|
||||
public delegate void OnDamageDelegate(int damage, int health);
|
||||
public delegate void OnDamageDelegate(int damage, PlayerHealth health);
|
||||
|
||||
public event OnDamageDelegate OnDamage;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Code.Gameplay.Player
|
||||
public void GetDamage(int count)
|
||||
{
|
||||
_healthPoints -= count;
|
||||
OnDamage?.Invoke(count, _healthPoints);
|
||||
OnDamage?.Invoke(count, this);
|
||||
|
||||
if (_healthPoints <= 0) OnDeath?.Invoke();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Code.Scenes.SceneEnvironments
|
||||
public void TransitVariables(MainMenuEnvironment env)
|
||||
{
|
||||
cameraTarget = env.cameraTarget;
|
||||
cameraPosition = env.cameraPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user