diff --git a/prefabs/fight/damage_flying_nuber.tscn b/prefabs/fight/damage_flying_nuber.tscn index c2c2d1a..c209975 100644 --- a/prefabs/fight/damage_flying_nuber.tscn +++ b/prefabs/fight/damage_flying_nuber.tscn @@ -1,10 +1,30 @@ -[gd_scene load_steps=2 format=3 uid="uid://l1hdihubffeg"] +[gd_scene load_steps=3 format=3 uid="uid://l1hdihubffeg"] [ext_resource type="Script" uid="uid://b5i41b6502xam" path="res://scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs" id="1_m0ub6"] +[ext_resource type="Texture2D" uid="uid://do0y56t1moi2" path="res://art/mockups/erdbeeren.png" id="2_ctnqp"] -[node name="DamageFlyingNuber" type="Node2D" node_paths=PackedStringArray("_label")] +[node name="DamageFlyingNuber" type="Node2D" node_paths=PackedStringArray("_label", "_sprite")] script = ExtResource("1_m0ub6") _label = NodePath("Label") +_sprite = NodePath("TextureRect") + +[node name="TextureRect" type="TextureRect" parent="."] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -61.0 +offset_top = -61.0 +offset_right = 61.0 +offset_bottom = 61.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +texture = ExtResource("2_ctnqp") +expand_mode = 1 +stretch_mode = 5 [node name="Label" type="Label" parent="."] custom_minimum_size = Vector2(200, 100) diff --git a/scenes/Babushka_scene_farm_outside_2d.tscn b/scenes/Babushka_scene_farm_outside_2d.tscn index c70b43c..2fc4392 100644 --- a/scenes/Babushka_scene_farm_outside_2d.tscn +++ b/scenes/Babushka_scene_farm_outside_2d.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=118 format=3 uid="uid://gigb28qk8t12"] +[gd_scene load_steps=119 format=3 uid="uid://gigb28qk8t12"] [ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Vesna.tscn" id="1_7wfwe"] [ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"] @@ -38,6 +38,7 @@ [ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="35_64mdn"] [ext_resource type="Texture2D" uid="uid://65e44yde224q" path="res://art/farm/Babushka_house_01.png" id="36_e5b7x"] [ext_resource type="Resource" uid="uid://duq7tshxv6uhp" path="res://resources/items/beet_seed.tres" id="36_fv1t2"] +[ext_resource type="Resource" uid="uid://0mnsr4anoaiq" path="res://resources/items/beet.tres" id="36_q1g8e"] [ext_resource type="AudioStream" uid="uid://cfqg50am0swb7" path="res://audio/Music/Farming_90BPM_69Bars_Loop.wav" id="37_8ey8m"] [ext_resource type="AudioStream" uid="uid://dku1rq5cocisg" path="res://audio/Music/Farming_90BPM_69Bars.wav" id="37_di1ed"] [ext_resource type="Shader" uid="uid://braevmqauoek7" path="res://shader/swaying_plant.gdshader" id="37_taxvr"] @@ -1117,6 +1118,24 @@ shape = SubResource("CircleShape2D_tm0yg") [node name="Icon" parent="YSorted/SeedPickup" index="4"] scale = Vector2(1, 1) +[node name="BeetPickup" parent="YSorted" instance=ExtResource("25_hukxv")] +position = Vector2(5787, 2269) +_finiteSupply = 3 +metadata/SaveID = "e1bbe13f-0622-42b8-97f3-87a8af369dc0" + +[node name="SpawnWithItem" parent="YSorted/BeetPickup" index="0"] +_blueprint = ExtResource("36_q1g8e") + +[node name="PickupInteractionArea" parent="YSorted/BeetPickup" index="3" node_paths=PackedStringArray("_spritesToOutline")] +_spritesToOutline = [NodePath("../../SeedPickup/Icon")] +metadata/SaveID = "ad152c51-3631-42c1-9aa4-4df896b35d8c" + +[node name="CollisionShape3D" parent="YSorted/BeetPickup/PickupInteractionArea/Area2D" index="0"] +shape = SubResource("CircleShape2D_tm0yg") + +[node name="Icon" parent="YSorted/BeetPickup" index="4"] +scale = Vector2(1, 1) + [node name="SeedPickup2" parent="YSorted" instance=ExtResource("25_hukxv")] position = Vector2(10705, 2257) _finiteSupply = 3 @@ -2582,6 +2601,7 @@ script = ExtResource("80_w1kgo") [connection signal="SuccessfulPickUp" from="YSorted/CanGenericPickup" to="YSorted/Vesna" method="HandlePickUp"] [connection signal="SuccessfulPickUp" from="YSorted/RakeGenericPickup" to="YSorted/Vesna" method="HandlePickUp"] [connection signal="SuccessfulPickUp" from="YSorted/SeedPickup" to="YSorted/Vesna" method="HandlePickUp"] +[connection signal="SuccessfulPickUp" from="YSorted/BeetPickup" to="YSorted/Vesna" method="HandlePickUp"] [connection signal="SuccessfulPickUp" from="YSorted/SeedPickup2" to="YSorted/Vesna" method="HandlePickUp"] [connection signal="InteractedTool" from="YSorted/Farm visuals/Static/EnterHouseInteraction" to="." method="LoadSceneAtIndex"] [connection signal="InteractedTool" from="YSorted/Blocker/InteractionArea" to="." method="LoadSceneAtIndex"] @@ -2606,6 +2626,8 @@ script = ExtResource("80_w1kgo") [editable path="YSorted/RakeGenericPickup/PickupInteractionArea"] [editable path="YSorted/SeedPickup"] [editable path="YSorted/SeedPickup/PickupInteractionArea"] +[editable path="YSorted/BeetPickup"] +[editable path="YSorted/BeetPickup/PickupInteractionArea"] [editable path="YSorted/SeedPickup2"] [editable path="YSorted/SeedPickup2/PickupInteractionArea"] [editable path="YSorted/Blocker/InteractionArea"] diff --git a/scenes/Babushka_scene_fight_happening.tscn b/scenes/Babushka_scene_fight_happening.tscn index aa86ac7..b19bf4a 100644 --- a/scenes/Babushka_scene_fight_happening.tscn +++ b/scenes/Babushka_scene_fight_happening.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://cjshlwk8ajpnp"] +[gd_scene load_steps=18 format=3 uid="uid://cjshlwk8ajpnp"] [ext_resource type="Script" uid="uid://cnhpnn8o0gybd" path="res://scripts/CSharp/Common/Fight/FightHappeningSceneSetup.cs" id="1_fiutj"] [ext_resource type="Script" uid="uid://c76mhhqyk4lgh" path="res://scripts/CSharp/Common/Fight/FightHappening.cs" id="1_gsk03"] @@ -6,6 +6,7 @@ [ext_resource type="Script" uid="uid://dwsqst8fhhqlc" path="res://scripts/CSharp/Common/Fight/AllFightersVisual.cs" id="2_lu4y4"] [ext_resource type="PackedScene" uid="uid://bcld43daavmrn" path="res://prefabs/fight/fight_scene_switcher.tscn" id="2_phrlx"] [ext_resource type="PackedScene" uid="uid://7jsxokx67gpq" path="res://prefabs/fight/fighterVisuals/vesna_fighter_visual.tscn" id="4_qo0gi"] +[ext_resource type="Script" uid="uid://cdrjvgm82pxoj" path="res://scripts/CSharp/Common/Fight/FightHappeningAnimationContext.cs" id="4_v5rv6"] [ext_resource type="PackedScene" uid="uid://0vm3jb1hnkkb" path="res://prefabs/fight/fighterVisuals/blob_fighter_visual.tscn" id="4_vp8s0"] [ext_resource type="Script" uid="uid://buiwuf7pjfq8" path="res://scripts/CSharp/Common/Fight/FightHappeningStateReaction.cs" id="4_ydj1i"] [ext_resource type="PackedScene" uid="uid://bydwj3pbvqrhb" path="res://prefabs/minigame/minigame.tscn" id="8_2b3cf"] @@ -13,20 +14,28 @@ [ext_resource type="Script" uid="uid://bwm0nhvt1083k" path="res://scripts/CSharp/Common/Fight/FightMinigameHandler.cs" id="8_falfe"] [ext_resource type="Script" uid="uid://d2ugtb3dalrg3" path="res://scripts/CSharp/Common/Fight/FightHappeningStateDebugger.cs" id="8_tv7cl"] [ext_resource type="Script" uid="uid://2f7rqk50gtdg" path="res://scripts/CSharp/Common/Fight/SwitchSceneOnFightEnd.cs" id="10_qqd8u"] +[ext_resource type="Script" uid="uid://6nniwfxye8ss" path="res://scripts/CSharp/Common/Fight/UsedItemIndicatorVisual.cs" id="14_b4ll5"] +[ext_resource type="PackedScene" uid="uid://l1hdihubffeg" path="res://prefabs/fight/damage_flying_nuber.tscn" id="15_oy2wu"] +[ext_resource type="Texture2D" uid="uid://djewfwrdt4iv3" path="res://art/ui/UI/icons/icon-fruit-beetroot.png" id="16_k4fcr"] [node name="BabushkaSceneFightHappening" type="Node2D"] [node name="FightHappening" type="Node" parent="."] script = ExtResource("1_gsk03") -[node name="ActionAnimationController" type="Node" parent="." node_paths=PackedStringArray("_allFightersVisual")] +[node name="ActionAnimationController" type="Node" parent="." node_paths=PackedStringArray("_allFightersVisual", "_animationContext")] script = ExtResource("2_7kjgs") _allFightersVisual = NodePath("../FightVisuals") +_animationContext = NodePath("AnimationContext") [node name="StateReactionActionAnimation" type="Node" parent="ActionAnimationController"] script = ExtResource("4_ydj1i") _fightState = 10 +[node name="AnimationContext" type="Node" parent="ActionAnimationController" node_paths=PackedStringArray("useHealItemIndicator")] +script = ExtResource("4_v5rv6") +useHealItemIndicator = NodePath("../../UseItemIndicator") + [node name="Camera2D" type="Camera2D" parent="."] [node name="FightSetup" type="Node2D" parent="."] @@ -206,6 +215,12 @@ offset_right = 794.0 offset_bottom = -472.0 text = "Hello world" +[node name="UseItemIndicator" type="Node2D" parent="."] +position = Vector2(214, 319) +script = ExtResource("14_b4ll5") +_flyingIndicatorPrefab = ExtResource("15_oy2wu") +_itemTexture = ExtResource("16_k4fcr") + [connection signal="SignalTransitionState" from="FightHappening" to="ActionAnimationController/StateReactionActionAnimation" method="FightHappeningStateTransitioned"] [connection signal="SignalTransitionState" from="FightHappening" to="FightVisuals" method="FightHappeningStateChange"] [connection signal="SignalTransitionState" from="FightHappening" to="ActionSelect/StateReactionInputActionSelect" method="FightHappeningStateTransitioned"] diff --git a/scripts/CSharp/Common/Fight/ActionAnimationController.cs b/scripts/CSharp/Common/Fight/ActionAnimationController.cs index 04621fa..2d84378 100644 --- a/scripts/CSharp/Common/Fight/ActionAnimationController.cs +++ b/scripts/CSharp/Common/Fight/ActionAnimationController.cs @@ -11,11 +11,11 @@ public partial class ActionAnimationController : Node #endregion [Export] private AllFightersVisual _allFightersVisual = null!; - + [Export] private FightHappeningAnimationContext _animationContext = null!; public void StateEnter() { - _ = HappeningData.actionStaging!.AnimateAction(_allFightersVisual); + _ = HappeningData.actionStaging!.AnimateAction(_allFightersVisual,_animationContext); } public void StateExit() diff --git a/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs b/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs index 34e0264..857e7b6 100644 --- a/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs +++ b/scripts/CSharp/Common/Fight/Actions/AllyAttackAction.cs @@ -50,7 +50,8 @@ public class AllyAttackAction : FighterAction targetSelect.GetTarget().ChangeHealth(-totalDamage); } - public override async Task AnimateAction(AllFightersVisual allFightersVisual) + public override async Task AnimateAction(AllFightersVisual allFightersVisual, + FightHappeningAnimationContext animationContext) { var currentFighter = HappeningData.fighterTurn.Current; var targetFighter = targetSelect.GetTarget(); diff --git a/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs b/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs index dbae1b1..009b16c 100644 --- a/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs +++ b/scripts/CSharp/Common/Fight/Actions/BlobAttackAction.cs @@ -21,7 +21,8 @@ public class BlobAttackAction(int damage = 3) : FighterAction FightWorld.Instance.allyFighters.vesnaFighter.ChangeHealth(-damage); } - public override async Task AnimateAction(AllFightersVisual allFightersVisual) + public override async Task AnimateAction(AllFightersVisual allFightersVisual, + FightHappeningAnimationContext animationContext) { var currentFighter = HappeningData.fighterTurn.Current; var targetFighter = FightWorld.Instance.allyFighters.vesnaFighter; diff --git a/scripts/CSharp/Common/Fight/Actions/EatBeetrootAction.cs b/scripts/CSharp/Common/Fight/Actions/EatBeetrootAction.cs index ddb87a0..791488b 100644 --- a/scripts/CSharp/Common/Fight/Actions/EatBeetrootAction.cs +++ b/scripts/CSharp/Common/Fight/Actions/EatBeetrootAction.cs @@ -21,11 +21,13 @@ public class EatBeetrootAction : FighterAction { blueprint = FightWorld.Instance.itemBeetrootToEatForHealth }); } - public override async Task AnimateAction(AllFightersVisual allFightersVisual) + public override async Task AnimateAction(AllFightersVisual allFightersVisual, + FightHappeningAnimationContext animationContext) { var fighter = HappeningData.fighterTurn.Current; var fighterVisual = allFightersVisual.GetVisualForFighter(fighter); fighterVisual.SpawnDamageIndicatorNumber($"+{HealAmount}"); + animationContext.useHealItemIndicator.SpawnIndicator(); await fighterVisual.AnimateHeal(); } diff --git a/scripts/CSharp/Common/Fight/FightHappeningAnimationContext.cs b/scripts/CSharp/Common/Fight/FightHappeningAnimationContext.cs new file mode 100644 index 0000000..8d1d141 --- /dev/null +++ b/scripts/CSharp/Common/Fight/FightHappeningAnimationContext.cs @@ -0,0 +1,8 @@ +using Godot; + +namespace Babushka.scripts.CSharp.Common.Fight; + +public partial class FightHappeningAnimationContext : Node +{ + [Export] public UsedItemIndicatorVisual useHealItemIndicator = null!; +} \ No newline at end of file diff --git a/scripts/CSharp/Common/Fight/FightHappeningAnimationContext.cs.uid b/scripts/CSharp/Common/Fight/FightHappeningAnimationContext.cs.uid new file mode 100644 index 0000000..3c6c81c --- /dev/null +++ b/scripts/CSharp/Common/Fight/FightHappeningAnimationContext.cs.uid @@ -0,0 +1 @@ +uid://cdrjvgm82pxoj diff --git a/scripts/CSharp/Common/Fight/FighterAction.cs b/scripts/CSharp/Common/Fight/FighterAction.cs index e3ea88b..cbaf939 100644 --- a/scripts/CSharp/Common/Fight/FighterAction.cs +++ b/scripts/CSharp/Common/Fight/FighterAction.cs @@ -59,7 +59,9 @@ public abstract class FighterAction /// Animates the action. /// /// - public virtual async Task AnimateAction(AllFightersVisual allFightersVisual) + /// + public virtual async Task AnimateAction(AllFightersVisual allFightersVisual, + FightHappeningAnimationContext animationContext) { } diff --git a/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs b/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs index 7509dae..88aeddb 100644 --- a/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs +++ b/scripts/CSharp/Common/Fight/FighterDamageIndicatorVisual.cs @@ -4,12 +4,12 @@ namespace Babushka.scripts.CSharp.Common.Fight; public partial class FighterDamageIndicatorVisual : Node2D { - [Export] private PackedScene _flyingNumberPrefab; + [Export] private PackedScene _flyingNumberPrefab = null!; public void SpawnFlyingNumber(string text) { - var flyingNumberInstance = _flyingNumberPrefab.Instantiate(); + var flyingNumberInstance = _flyingNumberPrefab.Instantiate(); AddChild(flyingNumberInstance); flyingNumberInstance.Initialize(text); } diff --git a/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs b/scripts/CSharp/Common/Fight/FlyingIndicator.cs similarity index 57% rename from scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs rename to scripts/CSharp/Common/Fight/FlyingIndicator.cs index cb9cd25..0ea0b24 100644 --- a/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs +++ b/scripts/CSharp/Common/Fight/FlyingIndicator.cs @@ -3,13 +3,19 @@ using Godot; namespace Babushka.scripts.CSharp.Common.Fight; -public partial class FighterDamageIndicatorFlyingNumber : Node2D +public partial class FlyingIndicator : Node2D { - [Export] private Label _label; - - public void Initialize(string text) + [Export] private Label _label = null!; + [Export] private TextureRect _sprite = null!; + + + public void Initialize(string? text = null, Texture2D? icon = null) { - _label.Text = text; + _label.Visible = text != null; + _sprite.Visible = icon != null; + + if (text != null) _label.Text = text; + if (icon != null) _sprite.Texture = icon; var tween = CreateTween(); var xMovement = GD.RandRange(-150, 150); diff --git a/scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs.uid b/scripts/CSharp/Common/Fight/FlyingIndicator.cs.uid similarity index 100% rename from scripts/CSharp/Common/Fight/FighterDamageIndicatorFlyingNumber.cs.uid rename to scripts/CSharp/Common/Fight/FlyingIndicator.cs.uid diff --git a/scripts/CSharp/Common/Fight/UsedItemIndicatorVisual.cs b/scripts/CSharp/Common/Fight/UsedItemIndicatorVisual.cs new file mode 100644 index 0000000..286fd94 --- /dev/null +++ b/scripts/CSharp/Common/Fight/UsedItemIndicatorVisual.cs @@ -0,0 +1,17 @@ +using Godot; + +namespace Babushka.scripts.CSharp.Common.Fight; + +public partial class UsedItemIndicatorVisual : Node2D +{ + [Export] private PackedScene _flyingIndicatorPrefab = null!; + [Export] private Texture2D _itemTexture = null!; + + + public void SpawnIndicator() + { + var flyingNumberInstance = _flyingIndicatorPrefab.Instantiate(); + AddChild(flyingNumberInstance); + flyingNumberInstance.Initialize(icon: _itemTexture); + } +} \ No newline at end of file diff --git a/scripts/CSharp/Common/Fight/UsedItemIndicatorVisual.cs.uid b/scripts/CSharp/Common/Fight/UsedItemIndicatorVisual.cs.uid new file mode 100644 index 0000000..168d3df --- /dev/null +++ b/scripts/CSharp/Common/Fight/UsedItemIndicatorVisual.cs.uid @@ -0,0 +1 @@ +uid://6nniwfxye8ss