From 0a3dbd64efd83765310065b39b43113d8d65f772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Sat, 28 Mar 2026 10:30:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=88=98=E6=96=97=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=94=BB=E5=87=BB=E9=80=BB=E8=BE=91=E5=92=8C?= =?UTF-8?q?Kernyr=E8=A7=92=E8=89=B2=E6=8A=80=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构tryAttack方法,将needChargeUp参数改为更灵活的chargeConfig配置 优化Kernyr角色的攻击2技能,改为持续旋转发射子弹 --- scripts/Contents/Characters/Kernyr.gd | 36 ++++++++++++++++----------- scripts/Statemachine/EntityBase.gd | 9 ++++++- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/scripts/Contents/Characters/Kernyr.gd b/scripts/Contents/Characters/Kernyr.gd index 8c1f7a0..84ffc0a 100644 --- a/scripts/Contents/Characters/Kernyr.gd +++ b/scripts/Contents/Characters/Kernyr.gd @@ -3,6 +3,7 @@ class_name Kernyr var attack1Angle = 0 var attack0State = 0 +var attack2Start = 0 func register(): fields[FieldStore.Entity.MAX_HEALTH] = 2000 @@ -13,7 +14,7 @@ func register(): attackMutexes = [2] func ai(): for i in 3: - tryAttack(i) + tryAttack(i, [2]) func attack(type: int): if type == 0: for i in randi_range(7, 16): @@ -38,19 +39,26 @@ func attack(type: int): 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("Egg"), - self , - position, - 0 - ): - if bullet is EggBullet: - bullet.look_at(anchor) + var i = 0 + var currentAngle = 0 + var time = 500.0 + await sprintTo(anchor + Vector2(0, -radius), 0.1) + attack2Start = timeLived() + while timeLived() - attack2Start <= time: + var targetAngle = deg_to_rad(i / count * 360.0 - 90) + currentAngle = deg_to_rad((timeLived() - attack2Start) / time * 360.0 - 90) + position = anchor + Vector2.from_angle(currentAngle) * radius + if currentAngle >= targetAngle: + i += 1 + for bullet in BulletBase.generate( + ComponentManager.getBullet("Egg"), + self , + position, + 0 + ): + if bullet is EggBullet: + bullet.look_at(anchor) + await TickTool.frame() await TickTool.millseconds(2000) await chargeUp() diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 0e04c5a..f274fab 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -325,7 +325,7 @@ func useEnergy(value: float): energy -= finalEnergy(value) energyChanged.emit(energy, false) return state -func tryAttack(type: int, needChargeUp: bool = false): +func tryAttack(type: int, chargeConfig: Variant = false): var weapon: Weapon if isPlayer() and !isSummon(): if len(weapons) > type: @@ -343,6 +343,13 @@ func tryAttack(type: int, needChargeUp: bool = false): cooldownTimer.cooldown = attackCooldownMap.get(type, defaultCooldownUnit) state = cooldownTimer.start() if state: + var needChargeUp: bool + if chargeConfig is bool: + needChargeUp = chargeConfig + elif chargeConfig is Array: + needChargeUp = type in chargeConfig + else: + needChargeUp = false if needChargeUp: await chargeUp() for attackingState in attackingStates: