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 22:03:28 +08:00
|
|
|
attackCooldownMap[4] = 4500
|
2025-09-13 22:46:25 +08:00
|
|
|
attackCooldownMap[5] = 5500
|
2025-09-13 20:43:05 +08:00
|
|
|
sprintMultiplier = 60
|
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 22:03:28 +08:00
|
|
|
for i in len(attackCooldownMap.keys()):
|
2025-09-13 19:55:51 +08:00
|
|
|
tryAttack(i)
|
2025-09-13 22:46:25 +08:00
|
|
|
# tryAttack(5)
|
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-13 22:03:28 +08:00
|
|
|
elif type == 4:
|
|
|
|
|
playSound("attack4")
|
|
|
|
|
var count = randi_range(8, 12)
|
|
|
|
|
for i in range(count):
|
|
|
|
|
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, findWeaponAnchor("normal"), deg_to_rad(360.0 / count * i)):
|
|
|
|
|
bullet.tracer = currentFocusedBoss
|
|
|
|
|
await TickTool.millseconds(830.0 / count)
|
|
|
|
|
return false
|
2025-09-13 22:46:25 +08:00
|
|
|
elif type == 5:
|
|
|
|
|
var target = currentFocusedBoss.position
|
|
|
|
|
var count = randi_range(10, 15)
|
|
|
|
|
for i in range(count):
|
|
|
|
|
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/LightGun.tscn"), self, target, 0):
|
|
|
|
|
bullet.position += Vector2.from_angle(deg_to_rad(360.0 / count * i)) * 1000
|
|
|
|
|
bullet.rotation = bullet.position.angle_to_point(target)
|
|
|
|
|
await TickTool.millseconds(1670.0 / count)
|
|
|
|
|
return false
|
2025-09-07 11:17:44 +08:00
|
|
|
return true
|
2025-09-13 19:55:51 +08:00
|
|
|
func sprint():
|
2025-09-13 20:43:05 +08:00
|
|
|
move(Vector2(sign((currentFocusedBoss.position - position).x * sprintMultiplier), 0), true)
|