Added basic health bar
This commit is contained in:
@@ -14,5 +14,5 @@ position = Vector2(23, -96)
|
|||||||
scale = Vector2(0.547474, 0.547474)
|
scale = Vector2(0.547474, 0.547474)
|
||||||
texture = SubResource("AtlasTexture_ane0o")
|
texture = SubResource("AtlasTexture_ane0o")
|
||||||
|
|
||||||
[node name="ChacacterSizeIndicator" parent="Visuals" index="1"]
|
[node name="Sprite2D" parent="TargetSelection/HoverIndicator" index="0"]
|
||||||
visible = true
|
position = Vector2(1, -126)
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
[gd_scene load_steps=8 format=3 uid="uid://7jsxokx67gpq"]
|
[gd_scene load_steps=9 format=3 uid="uid://7jsxokx67gpq"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/Fight/FighterVisual.cs" id="1_hai27"]
|
[ext_resource type="Script" uid="uid://by88f32fou7lh" path="res://scripts/CSharp/Common/Fight/FighterVisual.cs" id="1_hai27"]
|
||||||
[ext_resource type="Texture2D" uid="uid://f7htcxiwvuup" path="res://art/animation/vesna/Side/S01-Idle/0001.png" id="2_6l7g5"]
|
[ext_resource type="Texture2D" uid="uid://f7htcxiwvuup" path="res://art/animation/vesna/Side/S01-Idle/0001.png" id="2_6l7g5"]
|
||||||
[ext_resource type="Script" uid="uid://boprnfciqgixf" path="res://scripts/CSharp/Common/Fight/UI/TargetSelectionClick.cs" id="3_wil2y"]
|
[ext_resource type="Script" uid="uid://boprnfciqgixf" path="res://scripts/CSharp/Common/Fight/UI/TargetSelectionClick.cs" id="3_wil2y"]
|
||||||
[ext_resource type="Texture2D" uid="uid://qlfwuakhe57t" path="res://art/ui/UI/attack_select_wheel.png" id="4_8ldlc"]
|
[ext_resource type="Texture2D" uid="uid://qlfwuakhe57t" path="res://art/ui/UI/attack_select_wheel.png" id="4_8ldlc"]
|
||||||
|
[ext_resource type="Script" uid="uid://b2dx06p6i7pu0" path="res://scripts/CSharp/Common/Fight/UI/FighterHealthBarVisual.cs" id="5_xv37w"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wil2y"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wil2y"]
|
||||||
atlas = ExtResource("2_6l7g5")
|
atlas = ExtResource("2_6l7g5")
|
||||||
@@ -16,10 +17,11 @@ size = Vector2(250, 401)
|
|||||||
radius = 173.0
|
radius = 173.0
|
||||||
height = 588.0
|
height = 588.0
|
||||||
|
|
||||||
[node name="VesnaFighterVisual" type="Node2D" node_paths=PackedStringArray("_visualParent", "_targetSelectionParent")]
|
[node name="VesnaFighterVisual" type="Node2D" node_paths=PackedStringArray("_visualParent", "_targetSelectionParent", "healthBarVisual")]
|
||||||
script = ExtResource("1_hai27")
|
script = ExtResource("1_hai27")
|
||||||
_visualParent = NodePath("Visuals")
|
_visualParent = NodePath("Visuals")
|
||||||
_targetSelectionParent = NodePath("TargetSelection")
|
_targetSelectionParent = NodePath("TargetSelection")
|
||||||
|
healthBarVisual = NodePath("HealthBar")
|
||||||
|
|
||||||
[node name="Visuals" type="Node2D" parent="."]
|
[node name="Visuals" type="Node2D" parent="."]
|
||||||
|
|
||||||
@@ -53,6 +55,18 @@ position = Vector2(-3, -227)
|
|||||||
scale = Vector2(1.65625, 1.65625)
|
scale = Vector2(1.65625, 1.65625)
|
||||||
texture = ExtResource("4_8ldlc")
|
texture = ExtResource("4_8ldlc")
|
||||||
|
|
||||||
|
[node name="HealthBar" type="Node2D" parent="." node_paths=PackedStringArray("_tmpHealthLabel")]
|
||||||
|
script = ExtResource("5_xv37w")
|
||||||
|
_tmpHealthLabel = NodePath("tmpLabel")
|
||||||
|
|
||||||
|
[node name="tmpLabel" type="Label" parent="HealthBar"]
|
||||||
|
offset_left = -110.0
|
||||||
|
offset_top = -528.0
|
||||||
|
offset_right = 111.0
|
||||||
|
offset_bottom = -431.0
|
||||||
|
theme_override_font_sizes/font_size = 71
|
||||||
|
text = "xx / xx"
|
||||||
|
|
||||||
[connection signal="TargetSelected" from="TargetSelection/Click" to="." method="ClickedTarget"]
|
[connection signal="TargetSelected" from="TargetSelection/Click" to="." method="ClickedTarget"]
|
||||||
[connection signal="mouse_entered" from="TargetSelection/Click" to="TargetSelection/HoverIndicator" method="show"]
|
[connection signal="mouse_entered" from="TargetSelection/Click" to="TargetSelection/HoverIndicator" method="show"]
|
||||||
[connection signal="mouse_exited" from="TargetSelection/Click" to="TargetSelection/HoverIndicator" method="hide"]
|
[connection signal="mouse_exited" from="TargetSelection/Click" to="TargetSelection/HoverIndicator" method="hide"]
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ public partial class AllFightersVisual : Node
|
|||||||
{
|
{
|
||||||
HideTargetSelect();
|
HideTargetSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (from == FightHappening.FightState.ActionAnim)
|
||||||
|
{
|
||||||
|
_fighterVisuals.Values.ForEach(fv=>fv.UpdateHealthBar());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnterFighter()
|
public void EnterFighter()
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
using Babushka.scripts.CSharp.Common.Fight.ActionDetails;
|
||||||
|
using Babushka.scripts.CSharp.Common.Fight.UI;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||||
|
|
||||||
[Tool]
|
|
||||||
public partial class FighterVisual : Node2D
|
public partial class FighterVisual : Node2D
|
||||||
{
|
{
|
||||||
#region Shortcuts
|
#region Shortcuts
|
||||||
@@ -17,21 +18,9 @@ public partial class FighterVisual : Node2D
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
[ExportCategory("References")]
|
[ExportCategory("References")]
|
||||||
[Export] private Node2D _visualParent;
|
[Export] private Node2D _visualParent = null!;
|
||||||
[Export] private Node2D _targetSelectionParent;
|
[Export] private Node2D _targetSelectionParent = null!;
|
||||||
|
[Export] public FighterHealthBarVisual healthBarVisual = null!;
|
||||||
|
|
||||||
[Signal]
|
|
||||||
public delegate void DamageTakenEventHandler();
|
|
||||||
|
|
||||||
[Signal]
|
|
||||||
public delegate void AttackingEventHandler();
|
|
||||||
|
|
||||||
[Signal]
|
|
||||||
public delegate void DyingEventHandler();
|
|
||||||
|
|
||||||
[Signal]
|
|
||||||
public delegate void HealedEventHandler();
|
|
||||||
|
|
||||||
|
|
||||||
private FightWorld.Fighter _boundFighter;
|
private FightWorld.Fighter _boundFighter;
|
||||||
@@ -40,6 +29,7 @@ public partial class FighterVisual : Node2D
|
|||||||
{
|
{
|
||||||
_boundFighter = fighter;
|
_boundFighter = fighter;
|
||||||
UpdateMirrorState();
|
UpdateMirrorState();
|
||||||
|
UpdateHealthBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,6 +41,11 @@ public partial class FighterVisual : Node2D
|
|||||||
_visualParent.Scale = new Vector2(_boundFighter.isEnemy ? -1 : 1, 1);
|
_visualParent.Scale = new Vector2(_boundFighter.isEnemy ? -1 : 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateHealthBar()
|
||||||
|
{
|
||||||
|
healthBarVisual.UpdateHealth(_boundFighter.GetHealth(), _boundFighter.maxHealth);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetTargetSelectionActive(bool value)
|
public void SetTargetSelectionActive(bool value)
|
||||||
{
|
{
|
||||||
_targetSelectionParent.Visible = value;
|
_targetSelectionParent.Visible = value;
|
||||||
|
|||||||
@@ -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