2025-08-27 13:05:20 +08:00
|
|
|
extends EntityBase
|
2025-09-07 09:25:51 +08:00
|
|
|
class_name Bear # 攻击方式模仿泰拉瑞亚光之女皇
|
|
|
|
|
|
2025-09-13 19:55:51 +08:00
|
|
|
@onready var sprintParticle: GPUParticles2D = $"%sprintParticle"
|
|
|
|
|
|
2025-09-07 09:48:03 +08:00
|
|
|
func register():
|
|
|
|
|
fields[FieldStore.Entity.MAX_HEALTH] = 2000
|
2025-09-13 20:39:05 +08:00
|
|
|
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.5
|
2025-09-13 19:55:51 +08:00
|
|
|
attackCooldownMap[0] = 3000
|
|
|
|
|
attackCooldownMap[1] = 10000
|
|
|
|
|
attackCooldownMap[2] = 8000
|
|
|
|
|
attackCooldownMap[3] = 13000
|
2025-09-13 20:39:05 +08:00
|
|
|
sprintMultiplier = 100
|
2025-09-07 09:48:03 +08:00
|
|
|
func spawn():
|
|
|
|
|
texture.play("walk")
|
2025-09-07 09:25:51 +08:00
|
|
|
func ai():
|
2025-09-13 20:39:05 +08:00
|
|
|
PresetEntityAI.follow(self, currentFocusedBoss, 200)
|
2025-09-13 19:55:51 +08:00
|
|
|
for i in range(4):
|
|
|
|
|
tryAttack(i)
|
2025-09-07 09:25:51 +08:00
|
|
|
func attack(type):
|
2025-09-07 09:48:03 +08:00
|
|
|
var weaponPos = findWeaponAnchor("normal")
|
2025-09-07 09:25:51 +08:00
|
|
|
if type == 0:
|
2025-09-13 20:39:05 +08:00
|
|
|
playSound("attack0")
|
|
|
|
|
for i in randi_range(20, 30):
|
|
|
|
|
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, findWeaponAnchor("normal"), deg_to_rad(randf_range(0, 360))):
|
2025-09-13 19:55:51 +08:00
|
|
|
bullet.tracer = currentFocusedBoss
|
2025-09-13 20:39:05 +08:00
|
|
|
bullet.position += MathTool.randv2_range(50)
|
|
|
|
|
await TickTool.millseconds(50)
|
|
|
|
|
return false
|
2025-09-07 11:17:44 +08:00
|
|
|
elif type == 1:
|
2025-09-13 20:39:05 +08:00
|
|
|
await sprintTo(currentFocusedBoss.position - Vector2(MathTool.randc_from([-300, 300]), 300), 0.25)
|
|
|
|
|
var count = randi_range(6, 8)
|
|
|
|
|
for i in range(count):
|
|
|
|
|
BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/SunDance.tscn"), self, weaponPos, deg_to_rad(360.0 / count * i))
|
2025-09-13 19:55:51 +08:00
|
|
|
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:
|
2025-09-13 20:39:05 +08:00
|
|
|
await sprintTo(currentFocusedBoss.position - Vector2(MathTool.randc_from([500, -500]), 0), 0.25)
|
|
|
|
|
playSound("attack3")
|
2025-09-13 19:55:51 +08:00
|
|
|
sprintParticle.emitting = true
|
|
|
|
|
canRunAi = false
|
2025-09-13 20:39:05 +08:00
|
|
|
await TickTool.millseconds(900)
|
2025-09-13 19:55:51 +08:00
|
|
|
BulletBase.generate(preload("res://components/Bullets/BearSprint.tscn"), self, weaponPos, 0)
|
|
|
|
|
await trySprint()
|
|
|
|
|
sprintParticle.emitting = false
|
|
|
|
|
canRunAi = true
|
2025-09-13 20:39:05 +08:00
|
|
|
await sprintTo(currentFocusedBoss.position + MathTool.randv2_range(400), 0.25)
|
|
|
|
|
return false
|
2025-09-07 11:17:44 +08:00
|
|
|
return true
|
2025-09-13 19:55:51 +08:00
|
|
|
func sprint():
|
|
|
|
|
move((currentFocusedBoss.position - position).normalized() * sprintMultiplier * Vector2(1, 0), true)
|