1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

feat(角色): 添加熊boss的新攻击方式和音效

添加熊boss的四种攻击方式:
1. 箭雨攻击(ArrowSeven)
2. 太阳舞攻击(SunDance)
3. 永恒彩虹攻击(ForeverRainbow)
4. 冲刺攻击(BearSprint)

新增对应攻击音效资源
调整子弹追踪和伤害计算逻辑
添加冲刺粒子特效
This commit is contained in:
2025-09-13 19:55:51 +08:00
parent c5d21b68ba
commit 97ec81f05e
19 changed files with 426 additions and 54 deletions
+13
View File
@@ -0,0 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://dse2033lnmr7h"]
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_qcnih"]
[ext_resource type="Script" path="res://scripts/Contents/Bullets/ChickSprint.gd" id="2_87hcl"]
[sub_resource type="CircleShape2D" id="CircleShape2D_rirs4"]
radius = 63.1269
[node name="BearSprint" instance=ExtResource("1_qcnih")]
script = ExtResource("2_87hcl")
[node name="hitbox" parent="." index="1"]
shape = SubResource("CircleShape2D_rirs4")
@@ -0,0 +1,155 @@
[gd_scene load_steps=13 format=3 uid="uid://2odeyqgojcge"]
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_sltl7"]
[ext_resource type="Texture2D" uid="uid://bkiaaucejquik" path="res://resources/bullets/light-express/Everlasting_Rainbow.png" id="2_3w4yo"]
[ext_resource type="Script" path="res://scripts/Contents/Bullets/BossAttack/Bear/ForeverRainbow.gd" id="2_wwmq8"]
[sub_resource type="Gradient" id="Gradient_wd04q"]
offsets = PackedFloat32Array(0, 0.16, 0.32, 0.48, 0.64, 0.8, 1)
colors = PackedColorArray(1, 0, 0, 1, 1, 0.447059, 0, 1, 1, 0.890625, 0, 1, 0, 0.820313, 0.128174, 1, 0, 1, 0.859375, 1, 0, 0.53125, 1, 1, 0.429688, 0, 1, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_gcnu1"]
gradient = SubResource("Gradient_wd04q")
[sub_resource type="SpriteFrames" id="SpriteFrames_vtg2m"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_3w4yo")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="Animation" id="Animation_vt8tg"]
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(2, -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(2, -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="Animation" id="Animation_oinqg"]
resource_name = "destroy"
length = 0.5
step = 0.1
[sub_resource type="Animation" id="Animation_ynxlt"]
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_kmogx"]
resource_name = "spawn"
length = 11.0
step = 0.5
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, 0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 2, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 3, 11)
}
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, 0),
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0, 2, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 3, 11)
}
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, 3, 11)
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_edsep"]
_data = {
"RESET": SubResource("Animation_vt8tg"),
"destroy": SubResource("Animation_oinqg"),
"loop": SubResource("Animation_ynxlt"),
"spawn": SubResource("Animation_kmogx")
}
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_4fgwj"]
radius = 15.0
height = 86.0
[node name="ForeverRainbow" instance=ExtResource("1_sltl7")]
script = ExtResource("2_wwmq8")
allColor = SubResource("GradientTexture1D_gcnu1")
lifeTime = 11000.0
indisDamage = true
autoSpawnAnimation = true
autoDestroyOnHitMap = false
freeAfterSpawn = true
[node name="texture" parent="." index="0"]
position = Vector2(-67, 0)
scale = Vector2(2, 2)
sprite_frames = SubResource("SpriteFrames_vtg2m")
[node name="animator" parent="texture" index="0"]
libraries = {
"": SubResource("AnimationLibrary_edsep")
}
[node name="hitbox" parent="." index="1"]
position = Vector2(-13, 0)
rotation = 1.5708
shape = SubResource("CapsuleShape2D_4fgwj")
@@ -11,6 +11,42 @@ colors = PackedColorArray(1, 0, 0, 1, 1, 0.447059, 0, 1, 1, 0.890625, 0, 1, 0, 0
[sub_resource type="GradientTexture1D" id="GradientTexture1D_ikq3n"]
gradient = SubResource("Gradient_ep4dl")
[sub_resource type="Animation" id="Animation_n0ppl"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("%texture/..:scale:x")
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("%texture/..:scale:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -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("%texture/..:modulate:a")
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)
}
[sub_resource type="Animation" id="Animation_oinqg"]
resource_name = "destroy"
length = 0.5
@@ -71,42 +107,6 @@ tracks/2/keys = {
"times": PackedFloat32Array(0, 0.504665, 2.00467, 3)
}
[sub_resource type="Animation" id="Animation_n0ppl"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("%texture/..:scale:x")
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("%texture/..:scale:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -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("%texture/..:modulate:a")
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)
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_fv2s4"]
_data = {
"RESET": SubResource("Animation_n0ppl"),
+77 -1
View File
@@ -1,12 +1,16 @@
[gd_scene load_steps=13 format=3 uid="uid://m60bwhdpbem8"]
[gd_scene load_steps=28 format=3 uid="uid://m60bwhdpbem8"]
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_3ves7"]
[ext_resource type="Script" path="res://scripts/Contents/Characters/Bear.gd" id="2_kh2af"]
[ext_resource type="Texture2D" uid="uid://dmy5lfw3jy2u4" path="res://resources/characters/bear/bear-walk-a.svg" id="2_umdul"]
[ext_resource type="AudioStream" uid="uid://dqhrycmnkwojq" path="res://resources/sounds/bossAttack/Bear/Arrow7.ogg" id="3_n5dji"]
[ext_resource type="Texture2D" uid="uid://dxlsg4p1xkqh0" path="res://resources/characters/bear/bear-walk-b.svg" id="3_o77du"]
[ext_resource type="Texture2D" uid="uid://cd5vnifacsc8t" path="res://resources/characters/bear/bear-walk-c.svg" id="4_encki"]
[ext_resource type="AudioStream" uid="uid://bxks728nvv83c" path="res://resources/sounds/bossAttack/Bear/SunDance.ogg" id="4_meklc"]
[ext_resource type="Texture2D" uid="uid://dsgtjdeggris7" path="res://resources/characters/bear/bear-walk-d.svg" id="5_mvydi"]
[ext_resource type="AudioStream" uid="uid://dhcm3pjj82xhg" path="res://resources/sounds/bossAttack/Bear/ForeverRainbow.ogg" id="5_vej16"]
[ext_resource type="Texture2D" uid="uid://d2mwi15jqmnek" path="res://resources/characters/bear/bear-walk-e.svg" id="6_rwuah"]
[ext_resource type="AudioStream" uid="uid://cqh2yvwcy83gg" path="res://resources/sounds/bossAttack/Bear/Sprint.ogg" id="6_x3jmu"]
[ext_resource type="Texture2D" uid="uid://cli2fyulk3dsg" path="res://resources/characters/bear/bear-walk-f.svg" id="7_f0c6w"]
[ext_resource type="Texture2D" uid="uid://dadi3ud01bqxk" path="res://resources/characters/bear/bear-walk-g.svg" id="8_4c7bp"]
[ext_resource type="Texture2D" uid="uid://017nthmejh3g" path="res://resources/characters/bear/bear-walk-h.svg" id="9_bcby1"]
@@ -54,10 +58,71 @@ animations = [{
[sub_resource type="CircleShape2D" id="CircleShape2D_hekxf"]
radius = 114.215
[sub_resource type="Curve" id="Curve_u430e"]
_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_4vlq0"]
curve = SubResource("Curve_u430e")
[sub_resource type="Curve" id="Curve_hrxfa"]
_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_f4sgy"]
curve = SubResource("Curve_hrxfa")
[sub_resource type="Gradient" id="Gradient_ep4dl"]
offsets = PackedFloat32Array(0, 0.16, 0.32, 0.48, 0.64, 0.8, 1)
colors = PackedColorArray(1, 0, 0, 1, 1, 0.447059, 0, 1, 1, 0.890625, 0, 1, 0, 0.820313, 0.128174, 1, 0, 1, 0.859375, 1, 0, 0.53125, 1, 1, 0.429688, 0, 1, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_53df5"]
gradient = SubResource("Gradient_ep4dl")
[sub_resource type="Gradient" id="Gradient_c54lm"]
colors = PackedColorArray(0.1, 0.1, 0.1, 1, 1, 1, 1, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_o57pq"]
gradient = SubResource("Gradient_c54lm")
[sub_resource type="Curve" id="Curve_wldwu"]
_data = [Vector2(0, 0.75), 0.0, 0.0, 0, 0, Vector2(1, 0.3), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_hk4ss"]
curve = SubResource("Curve_wldwu")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_5v3nj"]
particle_flag_disable_z = true
angle_min = 1.07288e-05
angle_max = 360.0
angle_curve = SubResource("CurveTexture_f4sgy")
spread = 180.0
initial_velocity_min = 200.0
initial_velocity_max = 300.0
gravity = Vector3(0, 0, 0)
scale_curve = SubResource("CurveTexture_hk4ss")
color = Color(10, 10, 10, 1)
color_ramp = SubResource("GradientTexture1D_o57pq")
color_initial_ramp = SubResource("GradientTexture1D_53df5")
alpha_curve = SubResource("CurveTexture_4vlq0")
[node name="Bear" instance=ExtResource("1_3ves7")]
script = ExtResource("2_kh2af")
displayName = "狗熊"
[node name="attack0" parent="sounds" index="5"]
stream = ExtResource("3_n5dji")
[node name="attack1" type="AudioStreamPlayer2D" parent="sounds" index="6"]
stream = ExtResource("4_meklc")
[node name="attack2" type="AudioStreamPlayer2D" parent="sounds" index="7"]
stream = ExtResource("5_vej16")
[node name="attack3" type="AudioStreamPlayer2D" parent="sounds" index="8"]
stream = ExtResource("6_x3jmu")
[node name="texture" parent="." index="2"]
position = Vector2(0, -80)
sprite_frames = SubResource("SpriteFrames_6tgxs")
@@ -70,5 +135,16 @@ shape = SubResource("CircleShape2D_hekxf")
[node name="normal" type="Node2D" parent="texture/weapons" index="0"]
[node name="sprintParticle" type="GPUParticles2D" parent="texture" index="6"]
unique_name_in_owner = true
z_index = -1
emitting = false
amount = 20
process_material = SubResource("ParticleProcessMaterial_5v3nj")
texture = ExtResource("2_umdul")
[node name="statebar" parent="." index="3"]
position = Vector2(0, -175)
[node name="movebox" parent="." index="4"]
disabled = true
Binary file not shown.
@@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dqhrycmnkwojq"
path="res://.godot/imported/Arrow7.ogg-4daaa1f326c9d2f72b9133a00493c666.oggvorbisstr"
[deps]
source_file="res://resources/sounds/bossAttack/Bear/Arrow7.ogg"
dest_files=["res://.godot/imported/Arrow7.ogg-4daaa1f326c9d2f72b9133a00493c666.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file not shown.
@@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://dhcm3pjj82xhg"
path="res://.godot/imported/ForeverRainbow.ogg-b6772403e0b98813291a22e4f5452147.oggvorbisstr"
[deps]
source_file="res://resources/sounds/bossAttack/Bear/ForeverRainbow.ogg"
dest_files=["res://.godot/imported/ForeverRainbow.ogg-b6772403e0b98813291a22e4f5452147.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file not shown.
@@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://cqh2yvwcy83gg"
path="res://.godot/imported/Sprint.ogg-e547dff9a20b4385df68f6b79af56207.oggvorbisstr"
[deps]
source_file="res://resources/sounds/bossAttack/Bear/Sprint.ogg"
dest_files=["res://.godot/imported/Sprint.ogg-e547dff9a20b4385df68f6b79af56207.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
Binary file not shown.
@@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://bxks728nvv83c"
path="res://.godot/imported/SunDance.ogg-7dbdf3d807c0ba3ebfa16739ee2ca08a.oggvorbisstr"
[deps]
source_file="res://resources/sounds/bossAttack/Bear/SunDance.ogg"
dest_files=["res://.godot/imported/SunDance.ogg-7dbdf3d807c0ba3ebfa16739ee2ca08a.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
@@ -27,10 +27,10 @@ func ai():
if timeLived() <= forwardTime:
speed = 10 * ((forwardTime - timeLived()) / forwardTime)
elif forwarded:
if timeLived() < forwardTime + 1000:
if timeLived() < forwardTime + 2000:
speed = clamp((timeLived() - forwardTime) / 75, 0, 30)
if is_instance_valid(tracer):
PresetBulletAI.trace(self, tracer.position, 0.1)
PresetBulletAI.trace(self, tracer.position, 0.03)
else:
forwarded = true
@@ -0,0 +1,20 @@
extends BulletBase
@export var allColor: GradientTexture1D = null
var myColor: Color
func register():
damage = 5
penerate = 1
func spawn():
myColor = allColor.gradient.sample(randf())
setColor(myColor)
func ai():
speed = (11000 - timeLived()) / 11000 * initialSpeed
rotation_degrees += speed / 10
PresetBulletAI.forward(self, rotation)
func setColor(color: Color):
texture.modulate = color
+2 -2
View File
@@ -5,10 +5,10 @@ func register():
speed = 0
penerate = 1
func ai():
damage = launcher.velocity.length()
damage = launcher.velocity.length() / 300
PresetBulletAI.lockLauncher(self, launcher, true)
if !launcher.sprinting:
tryDestroy()
func destroy(beacuseMap: bool):
if beacuseMap:
launcher.takeDamage(self, 0.5)
launcher.takeDamage(self, MathTool.rate(0.5))
+30 -8
View File
@@ -1,23 +1,45 @@
extends EntityBase
class_name Bear # 攻击方式模仿泰拉瑞亚光之女皇
@onready var sprintParticle: GPUParticles2D = $"%sprintParticle"
func register():
fields[FieldStore.Entity.MAX_HEALTH] = 2000
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.25
attackCooldownMap[0] = 100
attackCooldownMap[1] = 100
attackCooldownMap[0] = 3000
attackCooldownMap[1] = 10000
attackCooldownMap[2] = 8000
attackCooldownMap[3] = 13000
sprintMultiplier = 120
func spawn():
texture.play("walk")
func ai():
PresetEntityAI.follow(self, currentFocusedBoss, 0)
tryAttack(0)
tryAttack(1)
for i in range(4):
tryAttack(i)
func attack(type):
var weaponPos = findWeaponAnchor("normal")
if type == 0:
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360))):
bullet.tracer = currentFocusedBoss
for i in range(20):
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360))):
bullet.tracer = currentFocusedBoss
elif type == 1:
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/SunDance.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360))):
bullet.damage = 1
await sprintTo(currentFocusedBoss.position - Vector2(200, 200), 0.25)
for i in range(6):
BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/SunDance.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360)))
elif type == 2:
for i in range(13):
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ForeverRainbow.tscn"), self, weaponPos, 0):
bullet.rotation = 360 / 13.0 * i
elif type == 3:
await sprintTo(currentFocusedBoss.position - Vector2(500, 0), 0.25)
sprintParticle.emitting = true
canRunAi = false
await TickTool.millseconds(1500)
BulletBase.generate(preload("res://components/Bullets/BearSprint.tscn"), self, weaponPos, 0)
await trySprint()
sprintParticle.emitting = false
canRunAi = true
return true
func sprint():
move((currentFocusedBoss.position - position).normalized() * sprintMultiplier * Vector2(1, 0), true)
+2
View File
@@ -26,8 +26,10 @@ var spawnInWhere: Vector2 = Vector2.ZERO
var destroying: bool = false
var isChildSplit: bool = false
var isChildRefract: bool = false
var initialSpeed: float = 0
func _ready():
initialSpeed = speed
register()
area_entered.connect(hit)
spawnInWhen = WorldManager.getTime()
+12 -4
View File
@@ -92,6 +92,7 @@ var lastDirection: int = 1
var currentFocusedBoss: EntityBase = null
var charginup: bool = false
var weapons: Array[Weapon] = []
var canRunAi: bool = true
func _ready():
register()
@@ -155,7 +156,7 @@ func _physics_process(_delta: float) -> void:
sprinting = false
else:
velocity = Vector2.ZERO
if (isPlayer() or is_instance_valid(currentFocusedBoss)) and not charginup:
if (isPlayer() or is_instance_valid(currentFocusedBoss)) and not charginup and canRunAi:
ai()
move_and_slide()
storeEnergy(randf_range(0.01, 0.1) * fields.get(FieldStore.Entity.ENERGY_REGENERATION), true)
@@ -242,11 +243,11 @@ func tryAttack(type: int, needChargeUp: bool = false):
await EffectController.create(preload("res://components/Effects/AttackStar.tscn"), damageAnchor.global_position).shot()
charginup = false
if isPlayer():
if weapon.tryAttack(self):
if await weapon.tryAttack(self):
weapon.playSound("attack")
else:
if attack(type):
playSound("attack" + str(type))
attack(type)
playSound("attack" + str(type))
return state
func trySprint():
trailing = true
@@ -255,6 +256,13 @@ func trySprint():
sprinting = true
await TickTool.until(func(): return !sprinting)
trailing = false
func sprintTo(target: Vector2, speed: float):
await TickTool.until(
func():
position += (target - position) * speed
return position.distance_to(target) < 10
)
position = target
func tryDie(by: BulletBase):
if is_queued_for_deletion(): return
for drop in range(min(len(drops), len(dropCounts))):
+1 -1
View File
@@ -100,7 +100,7 @@ func playSound(sound: String):
func tryAttack(entity: EntityBase):
if cooldownTimer.start():
if entity.useEnergy(needEnergy):
return attack(entity)
return await attack(entity)
# 抽象
func update(_to: int, origin: Dictionary, _entity: EntityBase):