From 5c16dcc29409d9ccd4b7d6c601a4f5ed4d6cb0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Fri, 29 Aug 2025 11:17:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AD=90=E5=BC=B9):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=B0=8F=E9=B8=A1=E6=BF=80=E5=85=89=E6=94=BB=E5=87=BB=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=90=E5=BC=B9=E8=A1=8C=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 替换原有Laser为ChickLaser,实现更华丽的激光效果 - 调整FireScan子弹速度和伤害值 - 优化Diamond子弹追踪逻辑和持续时间 - 新增PresetsAI.lockLauncher方法用于固定子弹位置 - 调整Chick角色的攻击冷却时间和攻击距离判定 --- components/Bullets/ChickLaser.tscn | 225 +++++++++++++++++++ components/Bullets/Common/LaserSummoner.tscn | 35 +-- components/Bullets/Laser.tscn | 35 --- components/Characters/Chick.tscn | 4 +- scripts/Contents/Bullets/ChickLaser.gd | 8 + scripts/Contents/Bullets/Diamond.gd | 5 +- scripts/Contents/Bullets/FireScan.gd | 4 +- scripts/Contents/Bullets/Laser.gd | 6 - scripts/Contents/Bullets/Presets/Presets.gd | 8 + scripts/Contents/Characters/Chick.gd | 6 +- 10 files changed, 268 insertions(+), 68 deletions(-) create mode 100644 components/Bullets/ChickLaser.tscn delete mode 100644 components/Bullets/Laser.tscn create mode 100644 scripts/Contents/Bullets/ChickLaser.gd delete mode 100644 scripts/Contents/Bullets/Laser.gd diff --git a/components/Bullets/ChickLaser.tscn b/components/Bullets/ChickLaser.tscn new file mode 100644 index 0000000..708d69d --- /dev/null +++ b/components/Bullets/ChickLaser.tscn @@ -0,0 +1,225 @@ +[gd_scene load_steps=15 format=3 uid="uid://bvri0nv1jrigf"] + +[ext_resource type="PackedScene" uid="uid://8gjjfju6p3fh" path="res://components/Bullets/Common/LaserSummoner.tscn" id="1_eb54j"] +[ext_resource type="Script" path="res://scripts/Contents/Bullets/ChickLaser.gd" id="2_7g0f0"] +[ext_resource type="Shader" path="res://shaders/BigLaser.gdshader" id="3_4y0mm"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_x6ivr"] +shader = ExtResource("3_4y0mm") +shader_parameter/laser_color = Color(0, 0.507813, 1, 1) +shader_parameter/width = 1.0 +shader_parameter/softness = 0.5 +shader_parameter/wave_speed = 1.0 +shader_parameter/wave_frequency = 1.0 +shader_parameter/wave_amplitude = 0.5 +shader_parameter/wave_width = 0.5 +shader_parameter/edge_nonalpha = 0.6 + +[sub_resource type="Curve" id="Curve_4f20s"] +_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_ftxbx"] +curve = SubResource("Curve_4f20s") + +[sub_resource type="Curve" id="Curve_ffsha"] +_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_5b6jo"] +curve = SubResource("Curve_ffsha") + +[sub_resource type="Gradient" id="Gradient_rbqh5"] +offsets = PackedFloat32Array(0, 0.553435) +colors = PackedColorArray(1, 1, 1, 1, 0, 0.695313, 1, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_y1x3v"] +gradient = SubResource("Gradient_rbqh5") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_vb8yw"] +particle_flag_disable_z = true +emission_shape = 3 +emission_box_extents = Vector3(0, 250, 1) +angle_min = 1.07288e-05 +angle_max = 360.0 +angle_curve = SubResource("CurveTexture_5b6jo") +spread = 15.0 +initial_velocity_min = -500.0 +initial_velocity_max = 500.0 +gravity = Vector3(0, 0, 0) +scale_min = 3.0 +scale_max = 15.0 +color_ramp = SubResource("GradientTexture1D_y1x3v") +alpha_curve = SubResource("CurveTexture_ftxbx") + +[sub_resource type="Animation" id="Animation_1rif1"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("rect:position:y") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("rect:scale:x") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1e-05, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/2/type = "bezier" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("circle:rotation") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/3/type = "bezier" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("circle:scale:x") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1e-05, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/4/type = "bezier" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("circle:scale:y") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1e-05, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} +tracks/5/type = "bezier" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("circle:modulate:a") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="Animation" id="Animation_ep0ow"] +resource_name = "spawn" +length = 5.0 +step = 0.05 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("rect:position:y") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0, 0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 25, -0.25, 0, 0.25, 0, 25, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5, 4.5, 5) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("rect:scale:x") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0, 0, 0, 0), +"points": PackedFloat32Array(1e-05, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1e-05, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5, 4.5, 5) +} +tracks/2/type = "bezier" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("circle:rotation") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"handle_modes": PackedInt32Array(0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 25.1327, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 5) +} +tracks/3/type = "bezier" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("circle:scale:x") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"handle_modes": PackedInt32Array(0, 0, 0, 0), +"points": PackedFloat32Array(1e-05, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1e-05, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5, 4.5, 5) +} +tracks/4/type = "bezier" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("circle:scale:y") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"handle_modes": PackedInt32Array(0, 0, 0, 0), +"points": PackedFloat32Array(1e-05, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1e-05, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5, 4.5, 5) +} +tracks/5/type = "bezier" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("circle:modulate:a") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"handle_modes": PackedInt32Array(0, 0, 0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5, 4.5, 5) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_7qqtc"] +_data = { +"RESET": SubResource("Animation_1rif1"), +"spawn": SubResource("Animation_ep0ow") +} + +[node name="ChickLaser" instance=ExtResource("1_eb54j")] +script = ExtResource("2_7g0f0") + +[node name="rect" parent="texture" index="0"] +material = SubResource("ShaderMaterial_x6ivr") +offset_left = 204.0 +offset_top = 0.0 +offset_right = 254.0 +offset_bottom = 500.0 + +[node name="particles" parent="texture/rect" index="0"] +position = Vector2(25, 250) +amount = 100 +process_material = SubResource("ParticleProcessMaterial_vb8yw") +lifetime = 0.1 +visibility_rect = Rect2(-50, -250, 100, 500) + +[node name="launcher" parent="texture/rect" index="1"] +position = Vector2(25, -21) +scale = Vector2(0.525, 0.525) + +[node name="animator" parent="texture" index="1"] +libraries = { +"": SubResource("AnimationLibrary_7qqtc") +} diff --git a/components/Bullets/Common/LaserSummoner.tscn b/components/Bullets/Common/LaserSummoner.tscn index 1fd5ef7..02b8d11 100644 --- a/components/Bullets/Common/LaserSummoner.tscn +++ b/components/Bullets/Common/LaserSummoner.tscn @@ -18,42 +18,42 @@ shader_parameter/wave_amplitude = 0.5 shader_parameter/wave_width = 0.5 shader_parameter/edge_nonalpha = 0.6 -[sub_resource type="Curve" id="Curve_m7ued"] +[sub_resource type="Curve" id="Curve_itlbo"] _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_iykvy"] -curve = SubResource("Curve_m7ued") +[sub_resource type="CurveTexture" id="CurveTexture_xathl"] +curve = SubResource("Curve_itlbo") -[sub_resource type="Curve" id="Curve_7w1gn"] +[sub_resource type="Curve" id="Curve_75ctq"] _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_nimkb"] -curve = SubResource("Curve_7w1gn") +[sub_resource type="CurveTexture" id="CurveTexture_my7uy"] +curve = SubResource("Curve_75ctq") -[sub_resource type="Gradient" id="Gradient_krx08"] -offsets = PackedFloat32Array(0, 0.553435) +[sub_resource type="Gradient" id="Gradient_62xhh"] +offsets = PackedFloat32Array(0, 0.60687) colors = PackedColorArray(1, 1, 1, 1, 1, 0, 0, 1) -[sub_resource type="GradientTexture1D" id="GradientTexture1D_l66oc"] -gradient = SubResource("Gradient_krx08") +[sub_resource type="GradientTexture1D" id="GradientTexture1D_yix5j"] +gradient = SubResource("Gradient_62xhh") -[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_n3bsp"] +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_m7jvq"] particle_flag_disable_z = true emission_shape = 3 emission_box_extents = Vector3(0, 1000, 1) angle_min = 1.07288e-05 angle_max = 360.0 -angle_curve = SubResource("CurveTexture_nimkb") +angle_curve = SubResource("CurveTexture_my7uy") spread = 15.0 initial_velocity_min = -500.0 initial_velocity_max = 500.0 gravity = Vector3(0, 0, 0) scale_min = 3.0 scale_max = 15.0 -color_ramp = SubResource("GradientTexture1D_l66oc") -alpha_curve = SubResource("CurveTexture_iykvy") +color_ramp = SubResource("GradientTexture1D_yix5j") +alpha_curve = SubResource("CurveTexture_xathl") [sub_resource type="Animation" id="Animation_1rif1"] length = 0.001 @@ -136,7 +136,7 @@ tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { "handle_modes": PackedInt32Array(0, 0, 0, 0), -"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 50, -0.25, 0, 0.25, 0, 50, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 25, -0.25, 0, 0.25, 0, 25, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0), "times": PackedFloat32Array(0, 0.5, 4.5, 5) } tracks/1/type = "bezier" @@ -216,15 +216,16 @@ sprite_frames = SubResource("SpriteFrames_yip5k") [node name="rect" type="ColorRect" parent="texture" index="0"] material = SubResource("ShaderMaterial_b2oy8") offset_left = 233.0 +offset_top = 50.0 offset_right = 333.0 -offset_bottom = 2000.0 +offset_bottom = 2050.0 rotation = -1.5708 scale = Vector2(1e-05, 1) [node name="particles" type="GPUParticles2D" parent="texture/rect" index="0"] position = Vector2(50, 1000) amount = 400 -process_material = SubResource("ParticleProcessMaterial_n3bsp") +process_material = SubResource("ParticleProcessMaterial_m7jvq") lifetime = 0.25 visibility_rect = Rect2(-100, -1000, 200, 2000) diff --git a/components/Bullets/Laser.tscn b/components/Bullets/Laser.tscn deleted file mode 100644 index 9859bc7..0000000 --- a/components/Bullets/Laser.tscn +++ /dev/null @@ -1,35 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://bvri0nv1jrigf"] - -[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_3u4op"] -[ext_resource type="Shader" path="res://shaders/Laser.gdshader" id="2_h6cxi"] -[ext_resource type="Script" path="res://scripts/Contents/Bullets/Laser.gd" id="2_yy5sr"] - -[sub_resource type="SpriteFrames" id="SpriteFrames_yip5k"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_5n8cv"] -shader = ExtResource("2_h6cxi") -shader_parameter/color = Color(0.654902, 1, 1, 1) -shader_parameter/laser_width = 0.01 -shader_parameter/soft_edge = 0.5 - -[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_y85id"] -height = 300.0 - -[node name="Laser" instance=ExtResource("1_3u4op")] -script = ExtResource("2_yy5sr") -lifeTime = 2000.0 - -[node name="texture" parent="." index="0"] -rotation = 1.5708 -sprite_frames = SubResource("SpriteFrames_yip5k") - -[node name="rect" type="ColorRect" parent="texture" index="0"] -material = SubResource("ShaderMaterial_5n8cv") -offset_left = -10.0 -offset_top = -300.0 -offset_right = 10.0 - -[node name="hitbox" parent="." index="1"] -position = Vector2(150, 0) -rotation = 1.5708 -shape = SubResource("CapsuleShape2D_y85id") diff --git a/components/Characters/Chick.tscn b/components/Characters/Chick.tscn index fcca496..7aedf8c 100644 --- a/components/Characters/Chick.tscn +++ b/components/Characters/Chick.tscn @@ -32,18 +32,16 @@ animations = [{ [node name="Chick" instance=ExtResource("1_goqmy")] script = ExtResource("2_r6bub") -cooldownUnit = 3000.0 isBoss = true displayName = "小鸡" drops = Array[int]([0, 1]) dropCounts = Array[Vector2]([Vector2(10, 30), Vector2(15, 50)]) appleCount = Vector2i(2, 4) -energy = 1000.0 [node name="hurt" parent="sounds" index="3"] stream = ExtResource("3_ik1xf") -[node name="attack1" type="AudioStreamPlayer2D" parent="sounds" index="4"] +[node name="attack1" type="AudioStreamPlayer2D" parent="sounds" index="6"] stream = ExtResource("4_oyq2p") [node name="texture" parent="." index="1"] diff --git a/scripts/Contents/Bullets/ChickLaser.gd b/scripts/Contents/Bullets/ChickLaser.gd new file mode 100644 index 0000000..48c4c6a --- /dev/null +++ b/scripts/Contents/Bullets/ChickLaser.gd @@ -0,0 +1,8 @@ +extends BulletBase +class_name Laser + +func register(): + penerate = 1 +func ai(): + rotation_degrees += 1 + PresetsAI.lockLauncher(self, launcher, true) diff --git a/scripts/Contents/Bullets/Diamond.gd b/scripts/Contents/Bullets/Diamond.gd index 80fa041..db311bc 100644 --- a/scripts/Contents/Bullets/Diamond.gd +++ b/scripts/Contents/Bullets/Diamond.gd @@ -1,11 +1,12 @@ extends BulletBase class_name Diamond -const traceTime = 2000 +const traceTime = 1500 func register(): damage = 2 func ai(): - rotation = lerp_angle(rotation, position.angle_to_point(launcher.currentFocusedBoss.position), 0.1 * clamp((traceTime - timeLived()) / traceTime, 0, INF)) canDamageSelf = !(timeLived() >= traceTime) PresetsAI.forward(self, rotation) + if timeLived() < traceTime: + PresetsAI.trace(self, launcher.currentFocusedBoss.position, 0.05) diff --git a/scripts/Contents/Bullets/FireScan.gd b/scripts/Contents/Bullets/FireScan.gd index 71f3151..ca9dd50 100644 --- a/scripts/Contents/Bullets/FireScan.gd +++ b/scripts/Contents/Bullets/FireScan.gd @@ -2,8 +2,8 @@ extends BulletBase class_name FireScan func register(): - speed = 5 - damage = 20 + speed = 2 + damage = 1 func ai(): PresetsAI.forward(self, rotation) diff --git a/scripts/Contents/Bullets/Laser.gd b/scripts/Contents/Bullets/Laser.gd deleted file mode 100644 index e7c1d8e..0000000 --- a/scripts/Contents/Bullets/Laser.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends BulletBase -class_name Laser - -func ai(): - rotation_degrees += 5 - position = launcher.texture.global_position diff --git a/scripts/Contents/Bullets/Presets/Presets.gd b/scripts/Contents/Bullets/Presets/Presets.gd index fca082f..ed5e3ba 100644 --- a/scripts/Contents/Bullets/Presets/Presets.gd +++ b/scripts/Contents/Bullets/Presets/Presets.gd @@ -1,4 +1,12 @@ class_name PresetsAI +static func lockLauncher(bullet: BulletBase, launcher: EntityBase, onTexture: bool = false): + bullet.position = launcher.texture.global_position if onTexture else launcher.position static func forward(bullet: BulletBase, rotation: float): bullet.forward(Vector2.from_angle(rotation)) +static func trace(bullet: BulletBase, target: Vector2, speed: float): + bullet.rotation = lerp_angle( + bullet.rotation, + bullet.position.angle_to_point(target), + speed + ) diff --git a/scripts/Contents/Characters/Chick.gd b/scripts/Contents/Characters/Chick.gd index f347ee4..ffc0ef1 100644 --- a/scripts/Contents/Characters/Chick.gd +++ b/scripts/Contents/Characters/Chick.gd @@ -9,14 +9,14 @@ func register(): fields[FieldStore.Entity.MAX_HEALTH] = 2000 fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.35 attackCooldownMap[0] = 2000 - attackCooldownMap[1] = 3000 + attackCooldownMap[1] = 6000 attackCooldownMap[2] = 100 func ai(): move(currentFocusedBoss.position - position) if currentFocusedBoss.position.distance_to(position) < 200: tryAttack(2) - elif currentFocusedBoss.position.distance_to(position) < 400: + elif currentFocusedBoss.position.distance_to(position) < 500: tryAttack(1) else: tryAttack(0) @@ -27,7 +27,7 @@ func attack(type): BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90))) elif type == 1: for i in range(laserCount): - BulletBase.generate(preload("res://components/Bullets/Laser.tscn"), self, texture.global_position, deg_to_rad(90 * i)) + BulletBase.generate(preload("res://components/Bullets/ChickLaser.tscn"), self, texture.global_position, deg_to_rad(90 * i)) elif type == 2: var weaponPos = findWeaponAnchor("normal") var target = weaponPos.angle_to_point(currentFocusedBoss.position)