Added basic health bar
This commit is contained in:
@@ -54,6 +54,11 @@ public partial class AllFightersVisual : Node
|
||||
{
|
||||
HideTargetSelect();
|
||||
}
|
||||
|
||||
if (from == FightHappening.FightState.ActionAnim)
|
||||
{
|
||||
_fighterVisuals.Values.ForEach(fv=>fv.UpdateHealthBar());
|
||||
}
|
||||
}
|
||||
|
||||
public void EnterFighter()
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
||||
using Babushka.scripts.CSharp.Common.Fight.UI;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
[Tool]
|
||||
|
||||
public partial class FighterVisual : Node2D
|
||||
{
|
||||
#region Shortcuts
|
||||
@@ -15,23 +16,11 @@ public partial class FighterVisual : Node2D
|
||||
FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
|
||||
|
||||
#endregion
|
||||
|
||||
[ExportCategory("References")]
|
||||
[Export] private Node2D _visualParent;
|
||||
[Export] private Node2D _targetSelectionParent;
|
||||
|
||||
|
||||
[Signal]
|
||||
public delegate void DamageTakenEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void AttackingEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void DyingEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void HealedEventHandler();
|
||||
[ExportCategory("References")]
|
||||
[Export] private Node2D _visualParent = null!;
|
||||
[Export] private Node2D _targetSelectionParent = null!;
|
||||
[Export] public FighterHealthBarVisual healthBarVisual = null!;
|
||||
|
||||
|
||||
private FightWorld.Fighter _boundFighter;
|
||||
@@ -40,6 +29,7 @@ public partial class FighterVisual : Node2D
|
||||
{
|
||||
_boundFighter = fighter;
|
||||
UpdateMirrorState();
|
||||
UpdateHealthBar();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,6 +41,11 @@ public partial class FighterVisual : Node2D
|
||||
_visualParent.Scale = new Vector2(_boundFighter.isEnemy ? -1 : 1, 1);
|
||||
}
|
||||
|
||||
public void UpdateHealthBar()
|
||||
{
|
||||
healthBarVisual.UpdateHealth(_boundFighter.GetHealth(), _boundFighter.maxHealth);
|
||||
}
|
||||
|
||||
public void SetTargetSelectionActive(bool value)
|
||||
{
|
||||
_targetSelectionParent.Visible = value;
|
||||
@@ -66,7 +61,7 @@ public partial class FighterVisual : Node2D
|
||||
targetDetail.SetTarget(_boundFighter);
|
||||
FightHappening.Instance.DetailFilled();
|
||||
}
|
||||
|
||||
|
||||
// Animations
|
||||
//public void AttackAnimation(FightAttack attack)
|
||||
//{
|
||||
@@ -100,7 +95,7 @@ public partial class FighterVisual : Node2D
|
||||
.SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
|
||||
await ToSignal(tween, "finished");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//private void HitAnimation(FightAttack attack)
|
||||
//{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight.UI;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FighterHealthBarVisual : Node2D
|
||||
{
|
||||
[Export] private Label _tmpHealthLabel = null!;
|
||||
|
||||
public void UpdateHealth(int currentHealth, int maxHealth)
|
||||
{
|
||||
_tmpHealthLabel.Text = $"{currentHealth} / {maxHealth}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://b2dx06p6i7pu0
|
||||
Reference in New Issue
Block a user