From f9601c4d139d7929396d5a9c2dbd4e86a0827bfd 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: Tue, 18 Nov 2025 22:19:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AD=90=E5=BC=B9):=20=E4=B8=BA=E5=BC=93?= =?UTF-8?q?=E7=AE=AD=E5=AD=90=E5=BC=B9=E6=B7=BB=E5=8A=A0=E8=93=84=E5=8A=9B?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E5=92=8C=E7=B2=92=E5=AD=90=E7=89=B9=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加蓄力等待时间和粒子特效系统,使弓箭在发射前有蓄力效果,并在发射时显示火焰粒子特效。修改了Bow.gd和Arrow.gd以支持蓄力时间参数,并更新Arrow.tscn添加新的粒子系统节点。 --- components/Bullets/Arrow.tscn | 36 ++++++++++++++++++++++++++++++- scripts/Contents/Bullets/Arrow.gd | 16 +++++++++++++- scripts/Contents/Bullets/Bow.gd | 4 +++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/components/Bullets/Arrow.tscn b/components/Bullets/Arrow.tscn index 6ae2446..3a28baa 100644 --- a/components/Bullets/Arrow.tscn +++ b/components/Bullets/Arrow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://wy8wqwhwr4fb"] +[gd_scene load_steps=13 format=3 uid="uid://wy8wqwhwr4fb"] [ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_0wuio"] [ext_resource type="Texture2D" uid="uid://dadbn306owsy3" path="res://resources/bullets/arrow/arrow.png" id="2_b2ohg"] @@ -20,6 +20,32 @@ initial_velocity_max = 3000.0 gravity = Vector3(0, 0, 0) alpha_curve = SubResource("CurveTexture_cawe8") +[sub_resource type="Curve" id="Curve_qddg0"] +_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_uu3a4"] +curve = SubResource("Curve_qddg0") + +[sub_resource type="Gradient" id="Gradient_cawe8"] +colors = PackedColorArray(1, 0, 0, 1, 1, 0.8159592, 0, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_afwvr"] +gradient = SubResource("Gradient_cawe8") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_qddg0"] +particle_flag_disable_z = true +emission_shape = 1 +emission_sphere_radius = 150.0 +direction = Vector3(-1, 0, 0) +spread = 20.0 +initial_velocity_max = 2500.0 +gravity = Vector3(0, 0, 0) +scale_min = 20.0 +scale_max = 60.0 +color_initial_ramp = SubResource("GradientTexture1D_afwvr") +alpha_curve = SubResource("CurveTexture_uu3a4") + [sub_resource type="CircleShape2D" id="CircleShape2D_b2ohg"] [node name="Arrow" instance=ExtResource("1_0wuio")] @@ -35,6 +61,7 @@ scale = Vector2(0.06775362, 0.06775362) texture = ExtResource("2_b2ohg") [node name="trail" type="GPUParticles2D" parent="texture/static" index="0"] +unique_name_in_owner = true z_index = -1 amount = 12 texture = ExtResource("2_b2ohg") @@ -42,6 +69,13 @@ preprocess = 1.0 local_coords = true process_material = SubResource("ParticleProcessMaterial_afwvr") +[node name="fire" type="GPUParticles2D" parent="texture/static" index="1"] +position = Vector2(1328.3423, 44.278076) +amount = 300 +preprocess = 1.0 +local_coords = true +process_material = SubResource("ParticleProcessMaterial_qddg0") + [node name="hitbox" parent="." index="1"] position = Vector2(85, 0) shape = SubResource("CircleShape2D_b2ohg") diff --git a/scripts/Contents/Bullets/Arrow.gd b/scripts/Contents/Bullets/Arrow.gd index 4ea19bc..82c9045 100644 --- a/scripts/Contents/Bullets/Arrow.gd +++ b/scripts/Contents/Bullets/Arrow.gd @@ -1,9 +1,23 @@ extends BulletBase class_name Arrow -var atk: float = 0 +@onready var trail: GPUParticles2D = $%trail +var atk: float = 0 +var waitTime: float = 0 + +func register(): + trail.emitting = false + hitbox.disabled = true func ai(): + if timeLived() < waitTime: + PresetBulletAI.lockLauncher(self, launcher, true) + rotation = position.angle_to_point(get_global_mouse_position()) + position += Vector2.from_angle(rotation) * 200 + return + else: + trail.emitting = true + hitbox.disabled = false speed = (1 - lifeDistancePercent()) * initialSpeed damage = speed * atk PresetBulletAI.forward(self, rotation) diff --git a/scripts/Contents/Bullets/Bow.gd b/scripts/Contents/Bullets/Bow.gd index bf010e7..112c913 100644 --- a/scripts/Contents/Bullets/Bow.gd +++ b/scripts/Contents/Bullets/Bow.gd @@ -3,9 +3,9 @@ class_name Bow var count: int = 0 var atk: float = 0 +var waitTime: float = 1000 func spawn(): - await TickTool.millseconds(1000) var startAngle = rotation - deg_to_rad(count * 10.0 / 2) for c in count: for i in BulletBase.generate( @@ -16,6 +16,8 @@ func spawn(): ): var bullet: Arrow = i bullet.atk = atk + bullet.waitTime = waitTime + await TickTool.millseconds(waitTime) tryDestroy() func ai(): PresetBulletAI.lockLauncher(self, launcher, true)