From 19a484643d299ca0ee9d09880807a9245e1f3f2b 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, 28 Aug 2025 12:00:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=89=B9=E6=95=88):=20=E4=B8=BABigLaser?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=A8=E7=94=BB=E6=95=88=E6=9E=9C=E5=B9=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在BigLaser生成时播放"bigLaser"动画 - 增加激光的尺寸和碰撞范围 - 添加BigLaser粒子效果场景 - 调整Wave生成参数 - 在CameraManager中添加动画播放功能 --- components/Bullets/BigLaser.tscn | 12 +- components/Bullets/LaserPluse.tscn | 104 ++++++++++++++++++ components/Scenes/World.tscn | 66 ++++++++++- .../bullets/laser-pluse/frames/ball-a.svg | 1 + .../laser-pluse/frames/ball-a.svg.import | 37 +++++++ scripts/Contents/Bullets/BigLaser.gd | 1 + scripts/Contents/Wave.gd | 4 +- scripts/Tools/CameraManager.gd | 4 + 8 files changed, 220 insertions(+), 9 deletions(-) create mode 100644 components/Bullets/LaserPluse.tscn create mode 100644 resources/bullets/laser-pluse/frames/ball-a.svg create mode 100644 resources/bullets/laser-pluse/frames/ball-a.svg.import diff --git a/components/Bullets/BigLaser.tscn b/components/Bullets/BigLaser.tscn index 6d84e71..5efbf09 100644 --- a/components/Bullets/BigLaser.tscn +++ b/components/Bullets/BigLaser.tscn @@ -13,8 +13,8 @@ shader_parameter/laser_width = 0.01 shader_parameter/soft_edge = 0.5 [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_y85id"] -radius = 40.0 -height = 1000.0 +radius = 60.0 +height = 2000.0 [node name="BigLaser" instance=ExtResource("1_cqnkd")] script = ExtResource("2_oqfvl") @@ -32,11 +32,11 @@ sprite_frames = SubResource("SpriteFrames_yip5k") [node name="rect" type="ColorRect" parent="texture" index="0"] material = SubResource("ShaderMaterial_5n8cv") -offset_left = -40.0 -offset_top = -1000.0 -offset_right = 40.0 +offset_left = -60.0 +offset_top = -2000.0 +offset_right = 60.0 [node name="hitbox" parent="." index="1"] -position = Vector2(500, 0) +position = Vector2(1000, 0) rotation = 1.5708 shape = SubResource("CapsuleShape2D_y85id") diff --git a/components/Bullets/LaserPluse.tscn b/components/Bullets/LaserPluse.tscn new file mode 100644 index 0000000..58c2743 --- /dev/null +++ b/components/Bullets/LaserPluse.tscn @@ -0,0 +1,104 @@ +[gd_scene load_steps=7 format=3 uid="uid://bx4guw2vkxgw4"] + +[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_k5wxk"] +[ext_resource type="Texture2D" uid="uid://ry8d7pst4ihf" path="res://resources/bullets/laser-pluse/frames/ball-a.svg" id="2_ob1rp"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_83opd"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2_ob1rp") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="Animation" id="Animation_hjoni"] +resource_name = "spawn" +step = 0.1 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:scale:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 3, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 1) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:scale:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 3, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 1) +} +tracks/2/type = "bezier" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath(".:modulate:a") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(0, -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, 1) +} + +[sub_resource type="Animation" id="Animation_s367m"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:scale:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1, -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(".:scale:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1, -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(".:modulate:a") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_tbgxn"] +_data = { +"RESET": SubResource("Animation_s367m"), +"spawn": SubResource("Animation_hjoni") +} + +[node name="LaserPluse" instance=ExtResource("1_k5wxk")] + +[node name="texture" parent="." index="0"] +sprite_frames = SubResource("SpriteFrames_83opd") + +[node name="animator" parent="texture" index="0"] +libraries = { +"": SubResource("AnimationLibrary_tbgxn") +} diff --git a/components/Scenes/World.tscn b/components/Scenes/World.tscn index 3ee3491..76af829 100644 --- a/components/Scenes/World.tscn +++ b/components/Scenes/World.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=3 uid="uid://dmxi1ikn6avig"] +[gd_scene load_steps=9 format=3 uid="uid://dmxi1ikn6avig"] [ext_resource type="Script" path="res://scripts/Tools/WorldManager.gd" id="1_lxsxj"] [ext_resource type="PackedScene" uid="uid://dfwg750a47ggx" path="res://components/Scenes/UI.tscn" id="2_04cdd"] @@ -6,6 +6,64 @@ [ext_resource type="Script" path="res://scripts/Tools/CameraManager.gd" id="5_mk7bv"] [ext_resource type="Texture2D" uid="uid://ckk8kahhof06u" path="res://resources/maps/Castle 2.png" id="6_p0nkj"] +[sub_resource type="Animation" id="Animation_kii8h"] +resource_name = "bigLaser" +length = 5.0 +step = 0.1 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:zoom:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 2, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5, 3) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:zoom:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0, 0, 0), +"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 2, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5, 3) +} + +[sub_resource type="Animation" id="Animation_ykpvi"] +length = 0.001 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:zoom:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1, -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(".:zoom:y") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0), +"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0) +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_44ixa"] +_data = { +"RESET": SubResource("Animation_ykpvi"), +"bigLaser": SubResource("Animation_kii8h") +} + [node name="world" type="Node2D"] y_sort_enabled = true script = ExtResource("1_lxsxj") @@ -25,3 +83,9 @@ offset = Vector2(0, -80) process_callback = 0 position_smoothing_enabled = true script = ExtResource("5_mk7bv") + +[node name="animator" type="AnimationPlayer" parent="camera"] +unique_name_in_owner = true +libraries = { +"": SubResource("AnimationLibrary_44ixa") +} diff --git a/resources/bullets/laser-pluse/frames/ball-a.svg b/resources/bullets/laser-pluse/frames/ball-a.svg new file mode 100644 index 0000000..61ff3bb --- /dev/null +++ b/resources/bullets/laser-pluse/frames/ball-a.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/bullets/laser-pluse/frames/ball-a.svg.import b/resources/bullets/laser-pluse/frames/ball-a.svg.import new file mode 100644 index 0000000..afa1d2b --- /dev/null +++ b/resources/bullets/laser-pluse/frames/ball-a.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ry8d7pst4ihf" +path="res://.godot/imported/ball-a.svg-0ada16ca1da72a2513ca7041117d42e8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resources/bullets/laser-pluse/frames/ball-a.svg" +dest_files=["res://.godot/imported/ball-a.svg-0ada16ca1da72a2513ca7041117d42e8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +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/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/BigLaser.gd b/scripts/Contents/Bullets/BigLaser.gd index 57d501c..117e762 100644 --- a/scripts/Contents/Bullets/BigLaser.gd +++ b/scripts/Contents/Bullets/BigLaser.gd @@ -3,6 +3,7 @@ class_name BigLaser func spawn(): CameraManager.shake(5000) + CameraManager.playAnimation("bigLaser") func ai(): rotation = lerp_angle(rotation, ((get_global_mouse_position() - position).angle()), 0.1) position = launcher.texture.global_position diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index 8bfa80b..1b4f4fc 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -11,8 +11,8 @@ var per: int = 0 static var current: int = 0 static var data: Array[Wave] = [ # entity, minCount, maxCount, isBoss, from, to, per - create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1), - create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 1, INF, 4) + create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 8, INF, 1), + create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 0, INF, 1) ] static func create( diff --git a/scripts/Tools/CameraManager.gd b/scripts/Tools/CameraManager.gd index 96b355e..a7164a6 100644 --- a/scripts/Tools/CameraManager.gd +++ b/scripts/Tools/CameraManager.gd @@ -4,6 +4,8 @@ class_name CameraManager @export var shakeOffset: float = 100 +@onready var animator: AnimationPlayer = $"%animator" + var shaking: bool = false static var instance: CameraManager = null @@ -22,3 +24,5 @@ static func shake(millseconds: int = 1000): await TickTool.millseconds(millseconds) instance.shaking = false print("shake end") +static func playAnimation(animation: String): + instance.animator.play(animation)