1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 23:11:54 +08:00
Files
Dog-Lynx-And-HCN/scripts/Contents/Characters/Chick.gd
T
fallingshrimp 5525bcd7bc feat(角色): 添加角色生成时的行走动画
在Chick角色和EntityBase基类中添加spawn方法,用于在角色生成时播放行走动画
2025-08-29 12:51:43 +08:00

40 lines
1.3 KiB
GDScript

extends EntityBase
class_name Chick
@onready var firepot = $"%firepot"
const laserCount = 4
func register():
fields[FieldStore.Entity.MAX_HEALTH] = 2000
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.35
attackCooldownMap[0] = 2000
attackCooldownMap[1] = 6000
attackCooldownMap[2] = 100
func spawn():
texture.play("walk")
func ai():
move(currentFocusedBoss.position - position)
if currentFocusedBoss.position.distance_to(position) < 300:
tryAttack(2)
elif currentFocusedBoss.position.distance_to(position) < 700:
tryAttack(1)
else:
tryAttack(0)
func attack(type):
if type == 0:
var weaponPos = findWeaponAnchor("normal")
for i in randi_range(10, 20):
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90)))
elif type == 1:
for i in range(laserCount):
BulletBase.generate(preload("res://components/Bullets/ChickLaser.tscn"), self, texture.global_position, deg_to_rad(90 * i))
elif type == 2:
var weaponPos = findWeaponAnchor("normal")
var target = weaponPos.angle_to_point(currentFocusedBoss.position)
firepot.global_rotation = target
firepot.shot()
BulletBase.generate(preload("res://components/Bullets/FireScan.tscn"), self, weaponPos, target)
return true