diff --git a/components/Bullets/BigLaser.tscn b/components/Bullets/BigLaser.tscn index 5efbf09..f50e122 100644 --- a/components/Bullets/BigLaser.tscn +++ b/components/Bullets/BigLaser.tscn @@ -20,11 +20,12 @@ height = 2000.0 script = ExtResource("2_oqfvl") fields = { 0: 0, -1: 15, +1: 25, 2: 1 } lifeTime = 5000.0 -needEnergy = 100.0 +needEnergy = 150.0 +knockback = 10.0 [node name="texture" parent="." index="0"] rotation = 1.5708 diff --git a/components/Bullets/LaserPluse.tscn b/components/Bullets/LaserPluse.tscn index 58c2743..cd76e67 100644 --- a/components/Bullets/LaserPluse.tscn +++ b/components/Bullets/LaserPluse.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=7 format=3 uid="uid://bx4guw2vkxgw4"] +[gd_scene load_steps=9 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"] +[ext_resource type="Script" path="res://scripts/Contents/Bullets/Common/LockLauncher.gd" id="2_ropvu"] [sub_resource type="SpriteFrames" id="SpriteFrames_83opd"] animations = [{ @@ -25,7 +26,7 @@ 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), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 10, -0.25, 0, 0.25, 0), "times": PackedFloat32Array(0, 1) } tracks/1/type = "bezier" @@ -36,7 +37,7 @@ 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), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 10, -0.25, 0, 0.25, 0), "times": PackedFloat32Array(0, 1) } tracks/2/type = "bezier" @@ -47,7 +48,7 @@ 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), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 0.5, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0), "times": PackedFloat32Array(0, 0.5, 1) } @@ -93,7 +94,15 @@ _data = { "spawn": SubResource("Animation_hjoni") } +[sub_resource type="CircleShape2D" id="CircleShape2D_ts2ht"] +radius = 35.0571 + [node name="LaserPluse" instance=ExtResource("1_k5wxk")] +z_index = -1 +script = ExtResource("2_ropvu") +target = 1 +autoSpawnAnimation = true +freeAfterSpawn = true [node name="texture" parent="." index="0"] sprite_frames = SubResource("SpriteFrames_83opd") @@ -102,3 +111,6 @@ sprite_frames = SubResource("SpriteFrames_83opd") libraries = { "": SubResource("AnimationLibrary_tbgxn") } + +[node name="hitbox" parent="." index="1"] +shape = SubResource("CircleShape2D_ts2ht") diff --git a/scripts/Contents/Bullets/BigLaser.gd b/scripts/Contents/Bullets/BigLaser.gd index 117e762..165e39e 100644 --- a/scripts/Contents/Bullets/BigLaser.gd +++ b/scripts/Contents/Bullets/BigLaser.gd @@ -12,4 +12,10 @@ func applyDot(): await TickTool.millseconds(50) hitbox.disabled = false await TickTool.millseconds(50) + BulletBase.generate( + preload("res://components/Bullets/LaserPluse.tscn"), + launcher, + position, + rotation + ) return true diff --git a/scripts/Contents/Bullets/Common/LockLauncher.gd b/scripts/Contents/Bullets/Common/LockLauncher.gd new file mode 100644 index 0000000..2fbf780 --- /dev/null +++ b/scripts/Contents/Bullets/Common/LockLauncher.gd @@ -0,0 +1,16 @@ +extends BulletBase +class_name LockLauncher + +enum PositionType { + SELF, + TEXTURE, +} + +@export var target: PositionType = PositionType.SELF + +func ai(): + if target == PositionType.SELF: + position = launcher.position + else: + position = launcher.texture.global_position + rotation = launcher.rotation diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index 1b4f4fc..7a6a02c 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, 8, INF, 1), - create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 0, INF, 1) + create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1), + create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 8, INF, 5) ] static func create( diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index ea4d65a..2bbc9b3 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -13,6 +13,8 @@ class_name BulletBase @export var needEnergy: float = 0.0 # 发射时需要消耗的能量 @export var autoSpawnAnimation: bool = false @export var autoLoopAnimation: bool = false +@export var freeAfterSpawn: bool = false +@export var knockback: float = 0 # 击退力,物理引擎单位 @onready var animator: AnimationPlayer = $"%animator" @onready var hitbox: CollisionShape2D = $"%hitbox" @@ -30,6 +32,8 @@ func _ready(): if autoSpawnAnimation: animator.play("spawn") await animator.animation_finished + if freeAfterSpawn: + destroy() if autoLoopAnimation: animator.play("loop") dotLoop() diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 6532811..5de72cd 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -148,12 +148,13 @@ func takeDamage(bullet: BulletBase, crit: bool): var damage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE) if sprinting: playSound("miss") - storeEnergy(damage * 1.25) + storeEnergy(damage * 0.5) damage = 0 else: playSound("hurt") bullet.launcher.storeEnergy(damage * 0.05) - storeEnergy(damage * -0.1) + storeEnergy(damage * -0.25) + position += Vector2.from_angle(bullet.position.angle_to_point(position)) * bullet.knockback hit.emit(damage, bullet, crit) healthChanged.emit(health) health -= damage @@ -162,7 +163,7 @@ func takeDamage(bullet: BulletBase, crit: bool): bullet.launcher.setBoss(self) if health <= 0: if isBoss: - bullet.launcher.storeEnergy(energy) + bullet.launcher.storeEnergy(energy * 0.5) bullet.launcher.setBoss(null) tryDie(bullet) func storeEnergy(value: float):