From 3bb4fcd12943c6518a612ece8f0da6c04e0087dc Mon Sep 17 00:00:00 2001 From: jonathan Date: Tue, 11 Nov 2025 15:55:15 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Added=20damage=20fly=20number?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prefabs/fight/damage_flying_nuber.tscn | 18 +++++++ .../fighterVisuals/blob_fighter_visual.tscn | 2 +- .../fighterVisuals/vesna_fighter_visual.tscn | 47 ++++++++++++------- .../Common/Fight/Actions/AllyAttackAction.cs | 6 +++ .../Common/Fight/Actions/BlobAttackAction.cs | 6 ++- .../FighterDamageIndicatorFlyingNumber.cs | 22 +++++++++ .../FighterDamageIndicatorFlyingNumber.cs.uid | 1 + .../Fight/FighterDamageIndicatorVisual.cs | 16 +++++++ .../Fight/FighterDamageIndicatorVisual.cs.uid | 1 + scripts/CSharp/Common/Fight/FighterVisual.cs | 12 ++++- 10 files changed, 109 insertions(+), 22 deletions(-) create mode 100644 prefabs/fight/damage_flying_nuber.tscn create mode 100644 scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs create mode 100644 scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs.uid create mode 100644 scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs create mode 100644 scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs.uid diff --git a/prefabs/fight/damage_flying_nuber.tscn b/prefabs/fight/damage_flying_nuber.tscn new file mode 100644 index 0000000..c2c2d1a --- /dev/null +++ b/prefabs/fight/damage_flying_nuber.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=2 format=3 uid="uid://l1hdihubffeg"] + +[ext_resource type="Script" uid="uid://b5i41b6502xam" path="res://scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs" id="1_m0ub6"] + +[node name="DamageFlyingNuber" type="Node2D" node_paths=PackedStringArray("_label")] +script = ExtResource("1_m0ub6") +_label = NodePath("Label") + +[node name="Label" type="Label" parent="."] +custom_minimum_size = Vector2(200, 100) +offset_left = -100.0 +offset_top = -50.0 +offset_right = 100.0 +offset_bottom = 50.0 +theme_override_font_sizes/font_size = 56 +text = "888" +horizontal_alignment = 1 +vertical_alignment = 1 diff --git a/prefabs/fight/fighterVisuals/blob_fighter_visual.tscn b/prefabs/fight/fighterVisuals/blob_fighter_visual.tscn index 6f61899..b9e6e4d 100644 --- a/prefabs/fight/fighterVisuals/blob_fighter_visual.tscn +++ b/prefabs/fight/fighterVisuals/blob_fighter_visual.tscn @@ -9,7 +9,7 @@ region = Rect2(1133.19, 93.65, 460.526, 347.391) [node name="BlobFighterVisual" instance=ExtResource("1_80xdf")] -[node name="Sprite2D" parent="Visuals" index="0"] +[node name="Sprite2D" parent="SquashParent/Visuals" index="0"] position = Vector2(23, -96) scale = Vector2(0.547474, 0.547474) texture = SubResource("AtlasTexture_ane0o") diff --git a/prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn b/prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn index 2927637..1c651ea 100644 --- a/prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn +++ b/prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=9 format=3 uid="uid://7jsxokx67gpq"] +[gd_scene load_steps=11 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="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="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"] +[ext_resource type="Script" uid="uid://c250yp2mdq83e" path="res://scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs" id="6_0qs42"] +[ext_resource type="PackedScene" uid="uid://l1hdihubffeg" path="res://prefabs/fight/damage_flying_nuber.tscn" id="7_y6dyb"] [sub_resource type="AtlasTexture" id="AtlasTexture_wil2y"] atlas = ExtResource("2_6l7g5") @@ -17,25 +19,41 @@ size = Vector2(250, 401) radius = 173.0 height = 588.0 -[node name="VesnaFighterVisual" type="Node2D" node_paths=PackedStringArray("_visualParent", "_targetSelectionParent", "healthBarVisual")] +[node name="VesnaFighterVisual" type="Node2D" node_paths=PackedStringArray("_visualParent", "_targetSelectionParent", "_squashParent", "healthBarVisual", "_fighterDamageIndicatorVisual")] script = ExtResource("1_hai27") -_visualParent = NodePath("Visuals") +_visualParent = NodePath("SquashParent/Visuals") _targetSelectionParent = NodePath("TargetSelection") -healthBarVisual = NodePath("HealthBar") +_squashParent = NodePath("SquashParent") +healthBarVisual = NodePath("SquashParent/HealthBar") +_fighterDamageIndicatorVisual = NodePath("DamageIndicator") -[node name="Visuals" type="Node2D" parent="."] +[node name="SquashParent" type="Node2D" parent="."] -[node name="Sprite2D" type="Sprite2D" parent="Visuals"] +[node name="Visuals" type="Node2D" parent="SquashParent"] + +[node name="Sprite2D" type="Sprite2D" parent="SquashParent/Visuals"] position = Vector2(-31, -199) scale = Vector2(0.451719, 0.451719) texture = SubResource("AtlasTexture_wil2y") -[node name="ChacacterSizeIndicator" type="CollisionShape2D" parent="Visuals"] +[node name="ChacacterSizeIndicator" type="CollisionShape2D" parent="SquashParent/Visuals"] editor_description = "This is a reference to the space, a normal sized humanoid character should occupy" visible = false position = Vector2(0, -200.5) shape = SubResource("RectangleShape2D_6l7g5") +[node name="HealthBar" type="Node2D" parent="SquashParent" node_paths=PackedStringArray("_tmpHealthLabel")] +script = ExtResource("5_xv37w") +_tmpHealthLabel = NodePath("tmpLabel") + +[node name="tmpLabel" type="Label" parent="SquashParent/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" + [node name="TargetSelection" type="Node2D" parent="."] process_mode = 4 visible = false @@ -55,17 +73,10 @@ position = Vector2(-3, -227) scale = Vector2(1.65625, 1.65625) 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" +[node name="DamageIndicator" type="Node2D" parent="."] +position = Vector2(3, -190) +script = ExtResource("6_0qs42") +_flyingNumberPrefab = ExtResource("7_y6dyb") [connection signal="TargetSelected" from="TargetSelection/Click" to="." method="ClickedTarget"] [connection signal="mouse_entered" from="TargetSelection/Click" to="TargetSelection/HoverIndicator" method="show"] diff --git a/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs b/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs index 788661b..e67a7f2 100644 --- a/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs +++ b/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs @@ -60,6 +60,12 @@ public class AllyAttackAction : FighterAction await currentFighterVisual.AnimatePosToTarget(targetFighterVisual); _ = targetFighterVisual.AnimateHit(); + + foreach (var hit in minigameDetail.damageHits!) + { + targetFighterVisual.SpawnDamageIndicatorNumber(hit); + } + await currentFighterVisual.AnimatePosToBase(); } } \ No newline at end of file diff --git a/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs b/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs index bb37064..fa3da73 100644 --- a/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs +++ b/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs @@ -6,6 +6,9 @@ namespace Babushka.scripts.CSharp.Common.Fight.Actions; public class BlobAttackAction : FighterAction { + // settings + private const int Damage = 3; + public override Variant> GetAnimationEnd() { return 1; @@ -18,7 +21,7 @@ public class BlobAttackAction : FighterAction public override void ExecuteAction() { - FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-3); + FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-Damage); } public override async Task AnimateAction(AllFightersVisual allFightersVisual) @@ -31,6 +34,7 @@ public class BlobAttackAction : FighterAction await currentFighterVisual.AnimatePosToTarget(targetFighterVisual); _ = targetFighterVisual.AnimateHit(); + targetFighterVisual.SpawnDamageIndicatorNumber(Damage); await currentFighterVisual.AnimatePosToBase(); } } \ No newline at end of file diff --git a/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs b/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs new file mode 100644 index 0000000..e833d67 --- /dev/null +++ b/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs @@ -0,0 +1,22 @@ +using System; +using Godot; + +namespace Babushka.scripts.CSharp.Common.Fight; + +public partial class FighterDamageIndicatorFlyingNumber : Node2D +{ + [Export] private Label _label; + + public void Initialize(int number) + { + _label.Text = number.ToString(); + + var tween = CreateTween(); + var xMovement = GD.RandRange(-150, 150); + var yMovement = GD.RandRange(-400, -250); + tween.Parallel().TweenProperty(this, "position:x", xMovement, .6); + tween.Parallel().TweenProperty(this, "position:y", yMovement, .6) + .SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Quad); + tween.Chain().TweenCallback(Callable.From(QueueFree)); + } +} \ No newline at end of file diff --git a/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs.uid b/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs.uid new file mode 100644 index 0000000..97e578b --- /dev/null +++ b/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs.uid @@ -0,0 +1 @@ +uid://b5i41b6502xam diff --git a/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs b/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs new file mode 100644 index 0000000..4e79ac4 --- /dev/null +++ b/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs @@ -0,0 +1,16 @@ +using Godot; + +namespace Babushka.scripts.CSharp.Common.Fight; + +public partial class FighterDamageIndicatorVisual : Node2D +{ + [Export] private PackedScene _flyingNumberPrefab; + + + public void SpawnFlyingNumber(int number) + { + var flyingNumberInstance = _flyingNumberPrefab.Instantiate(); + AddChild(flyingNumberInstance); + flyingNumberInstance.Initialize(number); + } +} \ No newline at end of file diff --git a/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs.uid b/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs.uid new file mode 100644 index 0000000..8a3d321 --- /dev/null +++ b/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs.uid @@ -0,0 +1 @@ +uid://c250yp2mdq83e diff --git a/scripts/CSharp/Common/Fight/FighterVisual.cs b/scripts/CSharp/Common/Fight/FighterVisual.cs index 04d1002..9e3b7ab 100644 --- a/scripts/CSharp/Common/Fight/FighterVisual.cs +++ b/scripts/CSharp/Common/Fight/FighterVisual.cs @@ -19,7 +19,11 @@ public partial class FighterVisual : Node2D [ExportCategory("References")] [Export] private Node2D _visualParent = null!; [Export] private Node2D _targetSelectionParent = null!; + [Export] private Node2D _squashParent = null!; [Export] public FighterHealthBarVisual healthBarVisual = null!; + [Export] private FighterDamageIndicatorVisual _fighterDamageIndicatorVisual; + + private FightWorld.Fighter _boundFighter; @@ -75,8 +79,8 @@ public partial class FighterVisual : Node2D public async Task AnimateHit() { var tween = GetTree().CreateTween(); - tween.TweenProperty(this, "scale", new Vector2(1.4f, 0.6f), 0.15); - tween.TweenProperty(this, "scale", new Vector2(1, 1), 0.4) + tween.TweenProperty(_squashParent, "scale", new Vector2(1.4f, 0.6f), 0.15); + tween.TweenProperty(_squashParent, "scale", new Vector2(1, 1), 0.4) .SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out); await ToSignal(tween, "finished"); } @@ -90,4 +94,8 @@ public partial class FighterVisual : Node2D // tween.TweenProperty(this, "scale", new Vector2(1, 1), 0.4) // .SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out); //} + public void SpawnDamageIndicatorNumber(int number) + { + _fighterDamageIndicatorVisual.SpawnFlyingNumber(number); + } } \ No newline at end of file -- 2.36.3