diff --git a/project.godot b/project.godot index eb23521..1ec38b8 100644 --- a/project.godot +++ b/project.godot @@ -16,7 +16,7 @@ warnings/check_angle_interpolation_type_conflicting=false [application] config/name="Liberation of the Neighbourville" -config/version="0.2.0" +config/version="0.2.1" run/main_scene="uid://bfstrli64u23y" config/features=PackedStringArray("4.4", "C#", "Forward Plus") config/icon="res://icon.png" diff --git a/scenes/entities/Zombies/hobo.tscn b/scenes/entities/Zombies/hobo.tscn index e967583..835b3b5 100644 --- a/scenes/entities/Zombies/hobo.tscn +++ b/scenes/entities/Zombies/hobo.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=62 format=3 uid="uid://bgqmwsb6ynm81"] +[gd_scene load_steps=64 format=3 uid="uid://bgqmwsb6ynm81"] [ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="1_fnu7s"] [ext_resource type="Shader" uid="uid://d0eo5uuj222c4" path="res://assets/shaders/CG_color_blender.gdshader" id="2_6qr4h"] @@ -18,6 +18,7 @@ [ext_resource type="AnimationLibrary" uid="uid://c0tlm0ta4dgbk" path="res://resources/animations/zombies/hobo.res" id="8_yb81c"] [ext_resource type="AudioStream" uid="uid://w0qfwds4o3ti" path="res://assets/audio/sfx/hit_generic.tres" id="9_tu6af"] [ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="11_7jlle"] +[ext_resource type="Script" uid="uid://d3l8e8ko5r5i3" path="res://scripts/ArmorHPObserver.cs" id="12_vn3j1"] [ext_resource type="AudioStream" uid="uid://ch55p7qbaawtp" path="res://assets/audio/sfx/argh.tres" id="12_w1b1s"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_w8pya"] @@ -90,6 +91,8 @@ region = Rect2(38, 22, 22, 13) atlas = ExtResource("5_b583s") region = Rect2(34, 38, 45, 27) +[sub_resource type="CircleShape2D" id="CircleShape2D_vn3j1"] + [sub_resource type="AtlasTexture" id="AtlasTexture_tebih"] atlas = ExtResource("5_b583s") region = Rect2(34, 0, 6, 19) @@ -738,7 +741,6 @@ transitions = ["Start", "Idle", SubResource("AnimationNodeStateMachineTransition graph_offset = Vector2(274, -18) [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_txjqc"] -graph_offset = Vector2(-427.399, 70.0005) nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_2q05d") nodes/TimeScale/position = Vector2(60, 120) nodes/Tree/node = SubResource("AnimationNodeStateMachine_xg3p6") @@ -767,16 +769,16 @@ scale = Vector2(0.999902, 0.999902) texture = SubResource("AtlasTexture_txjqc") [node name="RightUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="1"] -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999829, 0.999829) [node name="Right_Upper_Leg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg" index="0"] texture = SubResource("AtlasTexture_b583s") [node name="RightLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg" index="1"] -scale = Vector2(0.99983, 0.99983) +scale = Vector2(0.999832, 0.999832) [node name="RightFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg" index="0"] -scale = Vector2(0.999825, 0.999825) +scale = Vector2(0.999829, 0.999829) [node name="Right_Foot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg/RightFoot" index="0"] texture = SubResource("AtlasTexture_uoit3") @@ -785,19 +787,19 @@ texture = SubResource("AtlasTexture_uoit3") texture = SubResource("AtlasTexture_vn3j1") [node name="LeftUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="2"] -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999826, 0.999826) [node name="Left_Upper_Leg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg" index="0"] texture = SubResource("AtlasTexture_yb81c") [node name="LeftLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg" index="1"] -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999827, 0.999827) [node name="Left_Lower_Leg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg" index="0"] texture = SubResource("AtlasTexture_nlwsb") [node name="LeftFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg" index="1"] -scale = Vector2(0.999818, 0.999818) +scale = Vector2(0.999823, 0.999823) [node name="Left_Foot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg/LeftFoot" index="0"] texture = SubResource("AtlasTexture_8y6c0") @@ -806,7 +808,7 @@ texture = SubResource("AtlasTexture_8y6c0") scale = Vector2(0.999827, 0.999827) [node name="RightUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="0"] -scale = Vector2(0.999828, 0.999828) +scale = Vector2(0.999826, 0.999826) [node name="Right_Upper_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm" index="0"] texture = SubResource("AtlasTexture_nc6p3") @@ -828,7 +830,7 @@ texture = SubResource("AtlasTexture_0s5wm") [node name="Tie" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="2"] position = Vector2(-9, -21) -rotation = 0.042342 +rotation = 0.00885234 scale = Vector2(1e-05, 1e-05) [node name="Tie" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Tie" index="0"] @@ -871,27 +873,48 @@ texture = SubResource("AtlasTexture_pjhfy") [node name="Right_Eye" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="0"] position = Vector2(-16, -8) +scale = Vector2(1, 1) [node name="Left_Eye" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="1"] -position = Vector2(-4, -9) +position = Vector2(-4, -9.00001) +scale = Vector2(1, 1) [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="2"] position = Vector2(-3, 3) -rotation = -0.0688665 -scale = Vector2(0.999827, 0.999827) +rotation = -0.0143978 +scale = Vector2(0.999829, 0.999829) texture = SubResource("AtlasTexture_7cvmi") offset = Vector2(-14, -2) -[node name="Trashcan_lid" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="3"] +[node name="TrashcanLid" type="RigidBody2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="3" node_paths=PackedStringArray("data")] +position = Vector2(-3, 3) +scale = Vector2(0.999826, 0.999826) +collision_layer = 128 +collision_mask = 64 +freeze = true +script = ExtResource("3_tu6af") +data = NodePath("../../../../../../../../..") + +[node name="Trashcan_lid" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid" index="0"] z_index = -1 -position = Vector2(-0.00229669, -17.0131) -scale = Vector2(0.999828, 0.999828) +position = Vector2(2.99822, -20.0166) +scale = Vector2(1, 1) texture = SubResource("AtlasTexture_n380g") offset = Vector2(-0.5, -0.5) metadata/_edit_lock_ = true +[node name="CollisionShape2D" type="CollisionShape2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid" index="1"] +position = Vector2(2.99791, -20.018) +scale = Vector2(1, 1) +shape = SubResource("CircleShape2D_vn3j1") + +[node name="Observer" type="Node" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid" index="2" node_paths=PackedStringArray("_observedArmor")] +script = ExtResource("12_vn3j1") +_threshold = 0.333 +_observedArmor = NodePath("../../../../../../../../../../CanArmor") + [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="1"] -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999828, 0.999828) [node name="TrashcanLid" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="4"] position = Vector2(-0.0022974, -17.0131) @@ -903,16 +926,16 @@ bone_angle = 180.0 editor_settings/show_bone_gizmo = false [node name="RemoteTransform2D" type="RemoteTransform2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/TrashcanLid" index="0"] -remote_path = NodePath("../../HeadParticle/Head/Trashcan_lid") +remote_path = NodePath("../../HeadParticle/Head/TrashcanLid/Trashcan_lid") [node name="LeftUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="5"] -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999829, 0.999829) [node name="Left_Upper_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm" index="0"] texture = SubResource("AtlasTexture_tebih") [node name="Left_Lower_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile" index="0"] -rotation = 0.0381959 +rotation = 0.00798553 scale = Vector2(0.999999, 0.999999) texture = SubResource("AtlasTexture_auxav") @@ -964,7 +987,8 @@ audioStream = ExtResource("12_w1b1s") channel = "anger" metadata/_custom_type_script = "uid://c36bj8u7jghc7" -[connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/TrashcanLid/RemoteTransform2D" method="queue_free"] +[connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/TrashcanLid/RemoteTransform2D" method="queue_free"] +[connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid" method="FallOff"] [connection signal="ArmorLost" from="CanArmor" to="HitPlayer" method="Next"] [connection signal="ArmorLost" from="CanArmor" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Can" method="FallOff"] [connection signal="ArmorLost" from="CanArmor" to="Behaviour" method="Trashed"] diff --git a/scripts/Armor.cs b/scripts/Armor.cs index 7e8ba22..7c1d710 100644 --- a/scripts/Armor.cs +++ b/scripts/Armor.cs @@ -12,7 +12,7 @@ public partial class Armor : Node [Export] public float MaxHP { get; private set; } - private float _hp; + public float _hp; private bool _lost = false; public override void _Ready() diff --git a/scripts/ArmorHPObserver.cs b/scripts/ArmorHPObserver.cs new file mode 100644 index 0000000..59d1445 --- /dev/null +++ b/scripts/ArmorHPObserver.cs @@ -0,0 +1,32 @@ +using Godot; + +namespace Newlon.Components; + +public partial class ArmorHPObserver : Node +{ + [Export] private float _threshold = 0.5f; + [Export] private bool _setGreater = false; + [Export] private Armor _observedArmor; + [Signal] public delegate void ThresholdReachedEventHandler(); + + public override void _Ready() + { + _observedArmor.ArmorDamaged += OnHPChanged; + } + + private void OnHPChanged(float delta) + { + if (_setGreater == false && _observedArmor._hp / _observedArmor.MaxHP < _threshold) + { + EmitSignal(SignalName.ThresholdReached); + _observedArmor.ArmorDamaged -= OnHPChanged; + QueueFree(); + } + else if (_setGreater && _observedArmor._hp / _observedArmor.MaxHP > _threshold) + { + EmitSignal(SignalName.ThresholdReached); + _observedArmor.ArmorDamaged -= OnHPChanged; + QueueFree(); + } + } +} diff --git a/scripts/ArmorHPObserver.cs.uid b/scripts/ArmorHPObserver.cs.uid new file mode 100644 index 0000000..c1f6b50 --- /dev/null +++ b/scripts/ArmorHPObserver.cs.uid @@ -0,0 +1 @@ +uid://d3l8e8ko5r5i3