From 0a9e5f328ac9a6c236d2db5ed44b1ac48f0f513f 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: Thu, 30 Apr 2026 20:56:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(Statemachine):=20=E5=B0=86FollowPositi?= =?UTF-8?q?on=E9=87=8D=E6=9E=84=E4=B8=BASyncTransform=E5=B9=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=BC=A9=E6=94=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(EnergyBlock): 添加新的攻击类型1并设置冷却时间 fix(Parrier): 修复子弹碰撞时的hitbox禁用问题 feat(Bullets): 添加新的SwingSword子弹资源 style(Wave): 调整调试配置使用测试小怪而非Boss --- components/Bullets/SwingSword.tscn | 276 ++++++++++++++++++ components/Bullets/Volcano.tscn | 2 +- resources/bullets/swords/broom.svg | 65 +++++ resources/bullets/swords/broom.svg.import | 43 +++ scripts/Contents/Bullets/Parrier.gd | 3 +- scripts/Contents/Characters/EnergyBlock.gd | 4 + scripts/Contents/Wave.gd | 2 +- .../{FollowPosition.gd => SyncTransform.gd} | 6 + ...owPosition.gd.uid => SyncTransform.gd.uid} | 0 9 files changed, 397 insertions(+), 4 deletions(-) create mode 100644 components/Bullets/SwingSword.tscn create mode 100644 resources/bullets/swords/broom.svg create mode 100644 resources/bullets/swords/broom.svg.import rename scripts/Statemachine/{FollowPosition.gd => SyncTransform.gd} (73%) rename scripts/Statemachine/{FollowPosition.gd.uid => SyncTransform.gd.uid} (100%) diff --git a/components/Bullets/SwingSword.tscn b/components/Bullets/SwingSword.tscn new file mode 100644 index 0000000..982ad32 --- /dev/null +++ b/components/Bullets/SwingSword.tscn @@ -0,0 +1,276 @@ +[gd_scene format=3 uid="uid://b7yp28gfrqj5w"] + +[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_f7kh1"] +[ext_resource type="AudioStream" uid="uid://cer3lxbxqw5pq" path="res://resources/sounds/effect/sword1.mp3" id="2_ccsa1"] +[ext_resource type="Texture2D" uid="uid://caf67vt47y180" path="res://resources/bullets/swords/broom.svg" id="2_nqryj"] +[ext_resource type="AudioStream" uid="uid://bm2o8hu7nyqh1" path="res://resources/sounds/effect/sword3.mp3" id="3_23nu4"] +[ext_resource type="Script" uid="uid://ckc6guqib3rno" path="res://scripts/Statemachine/SyncTransform.gd" id="3_ihf3m"] + +[sub_resource type="Animation" id="Animation_ccsa1"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +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 = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:modulate") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("%hitbox:disabled") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("sword/trail:emitting") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("sword/trail:visible") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} + +[sub_resource type="Animation" id="Animation_nqryj"] +resource_name = "destroy" +length = 0.5 +step = 0.1 + +[sub_resource type="Animation" id="Animation_ihf3m"] +resource_name = "loop" +loop_mode = 1 +step = 0.1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 1), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0.0, 6.28319] +} + +[sub_resource type="Animation" id="Animation_gwhbm"] +resource_name = "spawn" +length = 2.7 +step = 0.05 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:rotation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0, 0, 0, 2, 2), +"points": PackedFloat32Array(-1.57, 0, 0, 0.4, -2, 1.57, -0.4, 2, 0, 0, -1.57, -0.4, -2, 0, 0, 0, -0.3, 0, 0, 0, 0, 0, 0, 0.3, 0, 1.57, 0, 0, 0, 0), +"times": PackedFloat32Array(0.2, 0.95, 1.7, 2, 2.4, 2.7) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:scale:x") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0, 0, 2, 2, 2, 2, 2), +"points": PackedFloat32Array(0, -0.25, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0.05, 0, 1.5, -0.05, 0, 0.05, 0, 0.5, -0.15, 0, 0.9999999, 0, 0.5, 0, 0, 0, 1, 2, 0, 0, 0, 0), +"times": PackedFloat32Array(0, 0.35, 1.7, 1.8, 2, 2.2, 2.4) +} +tracks/2/type = "bezier" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:scale:y") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"handle_modes": PackedInt32Array(2, 0, 2, 2, 2, 0, 2), +"points": PackedFloat32Array(0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0.05, 0, 1.5, -0.05, 0, 0.05, 0, 0.5, -0.15, 0, 0, 0, 0.5, 0, 0, 0, 1, 2, 0, 0, 0, 0), +"times": PackedFloat32Array(0, 0.35, 1.7, 1.8, 2, 2.2, 2.4) +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath(".:modulate") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.2, 2.4, 2.7), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("%hitbox:disabled") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0, 0.5, 0.65, 1, 1.25, 1.7, 1.9, 2.2, 2.4), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1), +"update": 1, +"values": [true, false, true, false, true, false, true, false, true] +} +tracks/5/type = "audio" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("audio") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"clips": [{ +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("2_ccsa1") +}, { +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("3_23nu4") +}, { +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("2_ccsa1") +}, { +"end_offset": 0.0, +"start_offset": 0.0, +"stream": ExtResource("3_23nu4") +}], +"times": PackedFloat32Array(0.4, 0.9, 1.6, 2.15) +} +tracks/5/use_blend = true +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("sword/trail:emitting") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0, 2.2, 2.7), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 1, +"values": [false, true, false] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("sword/trail:visible") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(0, 2.2), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [false, true] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_ccsa1"] +_data = { +&"RESET": SubResource("Animation_ccsa1"), +&"destroy": SubResource("Animation_nqryj"), +&"loop": SubResource("Animation_ihf3m"), +&"spawn": SubResource("Animation_gwhbm") +} + +[sub_resource type="Curve" id="Curve_buajx"] +_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_2tlcd"] +curve = SubResource("Curve_buajx") + +[sub_resource type="Curve" id="Curve_hsyiq"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.5), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="CurveTexture" id="CurveTexture_m4ahn"] +curve = SubResource("Curve_hsyiq") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_h2e5u"] +particle_flag_disable_z = true +spread = 0.0 +initial_velocity_min = 300.0 +initial_velocity_max = 300.0 +gravity = Vector3(0, 0, 0) +scale_curve = SubResource("CurveTexture_m4ahn") +alpha_curve = SubResource("CurveTexture_2tlcd") + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ccsa1"] +size = Vector2(259.81308, 36.189156) + +[node name="SwingSword" unique_id=5571707 instance=ExtResource("1_f7kh1")] +displayName = "扫帚" +motionType = 0 +penerate = 1.0 +autoSpawnAnimation = true +freeAfterSpawn = true + +[node name="texture" parent="." index="0" unique_id=162977358] +scale = Vector2(2, 2) + +[node name="animator" parent="texture" index="0" unique_id=1114087117] +libraries/ = SubResource("AnimationLibrary_ccsa1") + +[node name="sword" type="Sprite2D" parent="texture" index="2" unique_id=48557012] +position = Vector2(220, 0) +rotation = 3.1415927 +texture = ExtResource("2_nqryj") + +[node name="trail" type="GPUParticles2D" parent="texture/sword" index="0" unique_id=513809675] +z_index = -1 +amount = 10 +texture = ExtResource("2_nqryj") +preprocess = 1.0 +visibility_rect = Rect2(-200, -50, 400, 100) +local_coords = true +process_material = SubResource("ParticleProcessMaterial_h2e5u") + +[node name="hitbox" parent="." index="1" unique_id=175349408 node_paths=PackedStringArray("target")] +position = Vector2(439.70004, 16.243788) +rotation = -3.1046665 +scale = Vector2(2, 2) +shape = SubResource("RectangleShape2D_ccsa1") +script = ExtResource("3_ihf3m") +target = NodePath("../texture/sword") +enablePosition = true +enableRotation = true +enableScale = true diff --git a/components/Bullets/Volcano.tscn b/components/Bullets/Volcano.tscn index 74b702f..46b5abe 100644 --- a/components/Bullets/Volcano.tscn +++ b/components/Bullets/Volcano.tscn @@ -6,7 +6,7 @@ [ext_resource type="AudioStream" uid="uid://cer3lxbxqw5pq" path="res://resources/sounds/effect/sword1.mp3" id="3_6sp0s"] [ext_resource type="AudioStream" uid="uid://cfwu55dfgs4bl" path="res://resources/sounds/effect/sword2.mp3" id="4_1sgli"] [ext_resource type="AudioStream" uid="uid://bm2o8hu7nyqh1" path="res://resources/sounds/effect/sword3.mp3" id="5_b5nxd"] -[ext_resource type="Script" uid="uid://ckc6guqib3rno" path="res://scripts/Statemachine/FollowPosition.gd" id="7_1sgli"] +[ext_resource type="Script" uid="uid://ckc6guqib3rno" path="res://scripts/Statemachine/SyncTransform.gd" id="7_1sgli"] [sub_resource type="Animation" id="Animation_w1utg"] length = 0.001 diff --git a/resources/bullets/swords/broom.svg b/resources/bullets/swords/broom.svg new file mode 100644 index 0000000..c754cc8 --- /dev/null +++ b/resources/bullets/swords/broom.svg @@ -0,0 +1,65 @@ + + + + + broom + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/bullets/swords/broom.svg.import b/resources/bullets/swords/broom.svg.import new file mode 100644 index 0000000..3e54701 --- /dev/null +++ b/resources/bullets/swords/broom.svg.import @@ -0,0 +1,43 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://caf67vt47y180" +path="res://.godot/imported/broom.svg-5aec8b97cbbc94476bbe6de4db248d41.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/bullets/swords/broom.svg" +dest_files=["res://.godot/imported/broom.svg-5aec8b97cbbc94476bbe6de4db248d41.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/scripts/Contents/Bullets/Parrier.gd b/scripts/Contents/Bullets/Parrier.gd index 52a614a..ff34088 100644 --- a/scripts/Contents/Bullets/Parrier.gd +++ b/scripts/Contents/Bullets/Parrier.gd @@ -73,7 +73,7 @@ func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞 generateParryBall(targetBaseDamage) elif bullet.motionType == BulletBase.MotionType.SWING: parryEffect(bullet) - bullet.hitbox.disabled = true + bullet.hitbox.set_deferred("disabled", true) generateParryBall(targetBaseDamage) elif bullet.motionType == BulletBase.MotionType.SPRINT: parryEffect(bullet) @@ -82,7 +82,6 @@ func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞 generateParryBall(targetBaseDamage) elif bullet.motionType == BulletBase.MotionType.BREATH: penerateEffect(bullet.launcher) - bullet.hitbox.disable = true bullet.launcher.impluse(Vector2.from_angle(bullet.rotation) * -500) elif bullet.motionType == BulletBase.MotionType.SUMMON || bullet.motionType == BulletBase.MotionType.MAGIC: penerateEffect(bullet.launcher) diff --git a/scripts/Contents/Characters/EnergyBlock.gd b/scripts/Contents/Characters/EnergyBlock.gd index e77a658..f9b06d5 100644 --- a/scripts/Contents/Characters/EnergyBlock.gd +++ b/scripts/Contents/Characters/EnergyBlock.gd @@ -8,11 +8,15 @@ func register(): bullet.launcher.storeEnergy(damage) ) attackCooldownMap[0] = 0 + attackCooldownMap[1] = 3000 func ai(): tryAttack(0) + tryAttack(1) func attack(type: int): if type == 0: var track = getTrackingAnchor() var bullet = BulletTool.findClosetBulletCanDamage(track, get_tree(), self , 200) if is_instance_valid(bullet): BulletBase.generate(ComponentManager.getBullet("Parrier"), self , track, track.angle_to_point(bullet.position)) + elif type == 1: + BulletBase.generate(ComponentManager.getBullet("SwingSword"), self , getTrackingAnchor(), getTrackingAnchor().angle_to_point(currentFocusedPosition)) diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index edf53d0..7b547e4 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -57,7 +57,7 @@ static var WAVE_TESTMOB = [ ] static var WAVE_EMPTY = [] static var waveReleaseConfig = [WAVE_TESTBOSS, 1] -static var waveDebugConfig = [WAVE_TESTBOSS, 1] +static var waveDebugConfig = [WAVE_TESTMOB, 1] static var current: int = startWith(waveReleaseConfig[1]) if WorldManager.isRelease() else startWith(waveDebugConfig[1]) static var data = waveReleaseConfig[0] if WorldManager.isRelease() else waveDebugConfig[0] diff --git a/scripts/Statemachine/FollowPosition.gd b/scripts/Statemachine/SyncTransform.gd similarity index 73% rename from scripts/Statemachine/FollowPosition.gd rename to scripts/Statemachine/SyncTransform.gd index a369d8b..fb9450a 100644 --- a/scripts/Statemachine/FollowPosition.gd +++ b/scripts/Statemachine/SyncTransform.gd @@ -2,10 +2,14 @@ extends Node2D @export var target: Node2D + @export var offsetPosition: Vector2 = Vector2.ZERO @export var offsetRotation: float = 0.0 +@export var multipilerScale: Vector2 = Vector2.ONE + @export var enablePosition: bool = false @export var enableRotation: bool = false +@export var enableScale: bool = false func _process(_delta): if is_instance_valid(target): @@ -13,3 +17,5 @@ func _process(_delta): global_position = target.global_position + offsetPosition if enableRotation: global_rotation = target.global_rotation + deg_to_rad(offsetRotation) + if enableScale: + global_scale = target.global_scale * multipilerScale diff --git a/scripts/Statemachine/FollowPosition.gd.uid b/scripts/Statemachine/SyncTransform.gd.uid similarity index 100% rename from scripts/Statemachine/FollowPosition.gd.uid rename to scripts/Statemachine/SyncTransform.gd.uid