Add hit component and effects; update player and enemy scenes to integrate hit feedback

This commit is contained in:
2025-05-16 14:22:20 +02:00
parent 907bb5226f
commit 811372d5d3
36 changed files with 1362 additions and 613 deletions

View File

@@ -1,7 +1,8 @@
[gd_scene load_steps=31 format=3 uid="uid://bqi5s710xb1ju"]
[gd_scene load_steps=40 format=3 uid="uid://bqi5s710xb1ju"]
[ext_resource type="Script" uid="uid://ccuddyoakg04u" path="res://scripts/player.gd" id="1_8j4h4"]
[ext_resource type="Texture2D" uid="uid://b7gp0gqvkv8j4" path="res://sprites/MrBrick_base.png" id="2_bc55y"]
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="2_lgb3u"]
[ext_resource type="Texture2D" uid="uid://jl1gwqchhpdc" path="res://sprites/left_eye.png" id="3_2srrh"]
[ext_resource type="Texture2D" uid="uid://iiawtnwmeny3" path="res://sprites/right_eye.png" id="4_ccn81"]
[ext_resource type="Script" uid="uid://oxeqvxkgj87j" path="res://scripts/components/flip_player.gd" id="5_geu10"]
@@ -27,6 +28,13 @@
[ext_resource type="Resource" uid="uid://d3bjre2etov1n" path="res://resources/skills/magnetic.tres" id="22_vnsgd"]
[ext_resource type="Script" uid="uid://bjsyeo1n7bsri" path="res://scripts/components/skill_unlocker_component.gd" id="23_qsv2c"]
[ext_resource type="PackedScene" uid="uid://bg76mtpcmfm2j" path="res://objects/ui/charging_bar_layer.tscn" id="28_3f5nm"]
[ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="28_jh5m0"]
[ext_resource type="Script" uid="uid://ceq8n7yw7qxpi" path="res://scripts/components/hit_component.gd" id="29_jh5m0"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_xoue7"]
shader = ExtResource("2_lgb3u")
shader_parameter/enabled = false
shader_parameter/tint = Color(1, 1, 1, 1)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_hdsg1"]
size = Vector2(16, 31)
@@ -37,15 +45,47 @@ size = Vector2(16, 32)
[sub_resource type="CircleShape2D" id="CircleShape2D_ps31c"]
radius = 48.0
[node name="Brick Player" type="CharacterBody2D" node_paths=PackedStringArray("jump_sfx") groups=["player"]]
[sub_resource type="Gradient" id="Gradient_qb72p"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_f1fvy"]
gradient = SubResource("Gradient_qb72p")
[sub_resource type="Curve" id="Curve_82d6e"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_7b7mt"]
curve = SubResource("Curve_82d6e")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_lgb3u"]
resource_local_to_scene = true
lifetime_randomness = 1.0
particle_flag_disable_z = true
emission_shape = 1
emission_sphere_radius = 8.0
direction = Vector3(0.1, -0.5, 0)
initial_velocity_min = 200.0
initial_velocity_max = 400.0
gravity = Vector3(0, 80, 0)
damping_min = 400.0
damping_max = 800.0
scale_max = 3.0
scale_curve = SubResource("CurveTexture_7b7mt")
color = Color(0.764706, 0.443137, 0, 1)
color_ramp = SubResource("GradientTexture1D_f1fvy")
[node name="Brick Player" type="CharacterBody2D" node_paths=PackedStringArray("jump_sfx", "rotation_target") groups=["player"]]
collision_layer = 4
collision_mask = 43
script = ExtResource("1_8j4h4")
jump_sfx = NodePath("sfx_jump")
rotation_target = NodePath("Root/Base")
[node name="Root" type="Node2D" parent="."]
[node name="Base" type="Sprite2D" parent="Root"]
material = SubResource("ShaderMaterial_xoue7")
texture = ExtResource("2_bc55y")
[node name="Left Eye" type="Sprite2D" parent="Root"]
@@ -59,6 +99,7 @@ texture = ExtResource("4_ccn81")
hframes = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(0, 0.5)
shape = SubResource("RectangleShape2D_hdsg1")
@@ -73,6 +114,7 @@ collision_layer = 0
collision_mask = 8
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDamageArea"]
visible = false
position = Vector2(0, 1)
shape = SubResource("RectangleShape2D_vad0t")
@@ -136,11 +178,19 @@ available_skills = Array[ExtResource("21_d0oiv")]([ExtResource("22_vnsgd"), ExtR
script = ExtResource("23_qsv2c")
skill_manager = NodePath("../SkillManager")
[node name="HitComponent" type="Node" parent="." node_paths=PackedStringArray("sprite", "health_component", "hit_fx")]
script = ExtResource("29_jh5m0")
sprite = NodePath("../Root/Base")
health_component = NodePath("../HealthComponent")
hit_fx = NodePath("../HitParticles")
metadata/_custom_type_script = "uid://ceq8n7yw7qxpi"
[node name="MagneticArea" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 2
[node name="CollisionShape2D" type="CollisionShape2D" parent="MagneticArea"]
visible = false
shape = SubResource("CircleShape2D_ps31c")
[node name="CanBeLaunchedComponent" type="Node" parent="."]
@@ -164,5 +214,8 @@ offset_top = -30.0
offset_right = 23.0
offset_bottom = -20.0
[node name="HitParticles" parent="." instance=ExtResource("28_jh5m0")]
process_material = SubResource("ParticleProcessMaterial_lgb3u")
[connection signal="on_death" from="HealthComponent" to="PlayerDeathComponent" method="_on_health_component_on_death"]
[connection signal="on_health_change" from="HealthComponent" to="KnockbackComponent" method="_on_health_component_on_health_change"]

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=3 uid="uid://bwdlmualj6xbw"]
[gd_scene load_steps=26 format=3 uid="uid://bwdlmualj6xbw"]
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="1_ep4yr"]
[ext_resource type="Texture2D" uid="uid://cu72810eyk4dx" path="res://sprites/enemy-robot.png" id="2_hjtwe"]
@@ -7,7 +7,6 @@
[ext_resource type="Script" uid="uid://dmqpif5qhvri3" path="res://scripts/components/side_to_side_movement.gd" id="4_gbsq8"]
[ext_resource type="Script" uid="uid://b37gqnycj6rtk" path="res://scripts/components/periodic_shooting.gd" id="5_m03v0"]
[ext_resource type="Script" uid="uid://dqm371fysuk7i" path="res://scripts/components/enemy_death.gd" id="6_6p3gr"]
[ext_resource type="PackedScene" uid="uid://jiv4e82ycwmq" path="res://objects/entities/homing_bullet.tscn" id="7_lvsna"]
[ext_resource type="Script" uid="uid://dqmbvuutd5c3c" path="res://scripts/components/flashing_component.gd" id="7_xsaiy"]
[ext_resource type="Script" uid="uid://ceq8n7yw7qxpi" path="res://scripts/components/hit_component.gd" id="9_0qjr4"]
[ext_resource type="Script" uid="uid://c07d50s20rl8s" path="res://scripts/components/status_effect_component.gd" id="10_5i27q"]
@@ -17,6 +16,7 @@
[ext_resource type="AudioStream" uid="uid://dyev46uqusimi" path="res://sfx/shoot.wav" id="14_tdjks"]
[ext_resource type="PackedScene" uid="uid://dx80ivlvuuew4" path="res://objects/fxs/fire_fx.tscn" id="15_mc6rj"]
[ext_resource type="PackedScene" uid="uid://ck6nml06tm6ue" path="res://objects/fxs/ice_fx.tscn" id="16_68hnm"]
[ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="18_pxaaa"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pwwji"]
size = Vector2(25, 31)
@@ -29,10 +29,41 @@ shader_parameter/tint = Color(1, 1, 1, 1)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ejbqt"]
size = Vector2(34, 31)
[sub_resource type="Gradient" id="Gradient_qb72p"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_f1fvy"]
gradient = SubResource("Gradient_qb72p")
[sub_resource type="Curve" id="Curve_82d6e"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_7b7mt"]
curve = SubResource("Curve_82d6e")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_pxaaa"]
resource_local_to_scene = true
lifetime_randomness = 1.0
particle_flag_disable_z = true
emission_shape = 1
emission_sphere_radius = 8.0
direction = Vector3(0.1, -0.5, 0)
initial_velocity_min = 200.0
initial_velocity_max = 400.0
gravity = Vector3(0, 80, 0)
damping_min = 400.0
damping_max = 800.0
scale_max = 3.0
scale_curve = SubResource("CurveTexture_7b7mt")
color = Color(0.635294, 1, 0.952941, 1)
color_ramp = SubResource("GradientTexture1D_f1fvy")
[node name="Enemy" type="CharacterBody2D"]
collision_layer = 8
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(-1.5, 0.5)
shape = SubResource("RectangleShape2D_pwwji")
@@ -67,7 +98,6 @@ right_wall_ray = NodePath("../Right Wall Ray")
[node name="PeriodicShootingComponent" type="Node" parent="." node_paths=PackedStringArray("side_to_side_movement", "root", "bullet_spawn_right", "bullet_spawn_left")]
script = ExtResource("5_m03v0")
bullet_scene = ExtResource("7_lvsna")
side_to_side_movement = NodePath("../SideToSideMovement")
root = NodePath("..")
bullet_spawn_right = NodePath("../Sprite2D/right bullet spawn")
@@ -85,6 +115,7 @@ collision_layer = 8
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
visible = false
position = Vector2(-2, 0.5)
shape = SubResource("RectangleShape2D_ejbqt")
debug_color = Color(0.913521, 0.265052, 0.323172, 0.42)
@@ -111,10 +142,11 @@ script = ExtResource("7_xsaiy")
sprite = NodePath("../Sprite2D")
health_component = NodePath("../HealthComponent")
[node name="HitComponent" type="Node" parent="." node_paths=PackedStringArray("sprite", "health_component")]
[node name="HitComponent" type="Node" parent="." node_paths=PackedStringArray("sprite", "health_component", "hit_fx")]
script = ExtResource("9_0qjr4")
sprite = NodePath("../Sprite2D")
health_component = NodePath("../HealthComponent")
hit_fx = NodePath("../HitParticles")
[node name="StatusEffectComponent" type="Node" parent="."]
script = ExtResource("10_5i27q")
@@ -145,3 +177,7 @@ amount = 2048
[node name="Ice FX" parent="." instance=ExtResource("16_68hnm")]
visible = false
[node name="HitParticles" parent="." instance=ExtResource("18_pxaaa")]
position = Vector2(0, 1)
process_material = SubResource("ParticleProcessMaterial_pxaaa")

View File

@@ -30,6 +30,7 @@ collision_mask = 21
shape = SubResource("CircleShape2D_txsw8")
[node name="Sprite2D" type="Sprite2D" parent="."]
self_modulate = Color(2, 1, 1, 1)
scale = Vector2(0.5, 0.5)
texture = ExtResource("1_bmfqy")
hframes = 12
@@ -78,6 +79,9 @@ root = NodePath("..")
max_speed = 122.0
acceleration = 4.0
detection_area = NodePath("../DetectionArea")
wobble_strength = 10.0
drag = 1.0
steering_lerp = 0.01
[node name="DetectionArea" type="Area2D" parent="."]
collision_layer = 0
@@ -88,9 +92,11 @@ shape = SubResource("CircleShape2D_bmfqy")
debug_color = Color(0.802086, 0.36581, 0.539812, 0.42)
[node name="Trail" type="Line2D" parent="."]
self_modulate = Color(2, 2, 2, 1)
top_level = true
z_index = 199
width = 4.0
width_curve = SubResource("Curve_id4r8")
default_color = Color(2, 1.2, 1.2, 1)
gradient = SubResource("Gradient_id4r8")
script = ExtResource("8_id4r8")