1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00
Files
Dog-Lynx-And-HCN/scripts/Contents/Characters/Kernyr.gd
T
fallingshrimp ce7765c027 refactor(战斗系统): 优化攻击逻辑和碰撞处理
- 将蓄力攻击逻辑提取为独立方法 chargeUp 以提高代码复用性
- 调整攻击动画的等待时间,增加蓄力效果
- 添加碰撞反弹处理并重置冲刺状态
- 优化冲刺逻辑,在不可冲刺时提前终止
2026-03-28 09:04:38 +08:00

57 lines
1.6 KiB
GDScript

extends EntityBase
class_name Kernyr
var attack1Angle = 0
var attack0State = 0
func register():
fields[FieldStore.Entity.MAX_HEALTH] = 2000
fields[FieldStore.Entity.OFFSET_SHOOT] = 20
attackCooldownMap[0] = 2000
attackCooldownMap[1] = 100
attackCooldownMap[2] = 10000
attackMutexes = [2]
func ai():
for i in 3:
tryAttack(i)
func attack(type: int):
if type == 0:
for i in randi_range(7, 16):
BulletBase.generate(ComponentManager.getBullet("Diamond"), self , position + MathTool.sampleInCircle(20), rotation + deg_to_rad(randf_range(-90, 90)))
var states = [
Vector2(-1, 1),
Vector2(1, 1),
Vector2(1, -1),
Vector2(-1, -1)
]
await sprintTo(currentFocusedBoss.position + 400 * states[attack0State % len(states)], 0.1)
attack0State += 1
BulletBase.generate(ComponentManager.getBullet("HeavyCrystal"), self , findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
elif type == 1:
BulletBase.generate(
ComponentManager.getBullet("Yangyi"),
self ,
position,
attack1Angle
)
attack1Angle += deg_to_rad(360.0 / 20)
elif type == 2:
var anchor = currentFocusedBoss.position
var radius = 600
await sprintTo(anchor + Vector2(0, -radius), 0.1)
await TickTool.millseconds(500)
await chargeUp()
var count = 10.0
for i in count:
await sprintTo(anchor + Vector2.from_angle(deg_to_rad(i / count * 360.0 - 90)) * radius, 0.5)
for bullet in BulletBase.generate(
ComponentManager.getBullet("Yangyi"),
self ,
position,
0
):
if bullet is YangyiBullet:
bullet.look_at(anchor)
await TickTool.millseconds(2000)
await chargeUp()