Added basic health bar
This commit is contained in:
@@ -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)
|
||||
//{
|
||||
|
||||
Reference in New Issue
Block a user