You do some, you lose some

This commit is contained in:
ThomasCharester committed 2026-11-19 12:39:23 +03:00
1 parent 1d107924bf
commit 2ce0391c16
42 files changed
+331912 -5358

No files matched your search

@@ -1,6 +1,7 @@
using System.Threading;
using Code.Infrastructure.Camera;
using Code.Infrastructure.UI;
using Code.OfficeGame.BattleMode.Timeline;
using Cysharp.Threading.Tasks;
using R3;
using Reflex.Attributes;
@@ -14,6 +15,7 @@ namespace Code.OfficeGame.BattleMode.Health.UI
{
[SerializeField] private TMP_Text healthText;
[SerializeField] private Image healthBar;
[SerializeField] private Image silentHealthBar;
[SerializeField] private Color criticalColor;
[SerializeField] private Color fullColor;
@@ -55,23 +57,36 @@ namespace Code.OfficeGame.BattleMode.Health.UI
entityHealth.HealthData
.Subscribe(SetHealthStatus)
.AddTo(ref _healthSubscriptions);
_previousHealthData = entityHealth.HealthData.CurrentValue;
}
private HealthData _previousHealthData;
private void SetHealthStatus(HealthData healthData)
{
if (healthData.CurrentHealth <= 0)
{
healthText.color = deadColor;
healthText.SetText("Dead");
healthBar.fillAmount = 1;
if(BattleTimeline.IsSilentSimulation)
silentHealthBar.fillAmount = 1;
else healthBar.fillAmount = 1;
return;
}
float healthPercentage = (float)healthData.CurrentHealth / healthData.MaxHealth;
healthBar.fillAmount = healthPercentage;
if(BattleTimeline.IsSilentSimulation)
if(_previousHealthData.CurrentHealth != healthData.CurrentHealth) silentHealthBar.fillAmount = healthPercentage;
else silentHealthBar.fillAmount = 0;
else
{
healthBar.fillAmount = healthPercentage;
_previousHealthData = healthData;
}
// SB
healthText.SetText($"{healthData.CurrentHealth}/{healthData.MaxHealth}");