1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-27 14:02:29 +08:00

feat(战斗系统): 改进攻击逻辑和Kernyr角色技能

重构tryAttack方法,将needChargeUp参数改为更灵活的chargeConfig配置
优化Kernyr角色的攻击2技能,改为持续旋转发射子弹
This commit is contained in:
2026-03-28 10:30:23 +08:00
parent 2105de1131
commit 0a3dbd64ef
2 changed files with 30 additions and 15 deletions
+22 -14
View File
@@ -3,6 +3,7 @@ class_name Kernyr
var attack1Angle = 0 var attack1Angle = 0
var attack0State = 0 var attack0State = 0
var attack2Start = 0
func register(): func register():
fields[FieldStore.Entity.MAX_HEALTH] = 2000 fields[FieldStore.Entity.MAX_HEALTH] = 2000
@@ -13,7 +14,7 @@ func register():
attackMutexes = [2] attackMutexes = [2]
func ai(): func ai():
for i in 3: for i in 3:
tryAttack(i) tryAttack(i, [2])
func attack(type: int): func attack(type: int):
if type == 0: if type == 0:
for i in randi_range(7, 16): for i in randi_range(7, 16):
@@ -38,19 +39,26 @@ func attack(type: int):
elif type == 2: elif type == 2:
var anchor = currentFocusedBoss.position var anchor = currentFocusedBoss.position
var radius = 600 var radius = 600
await sprintTo(anchor + Vector2(0, -radius), 0.1)
await TickTool.millseconds(500)
await chargeUp()
var count = 10.0 var count = 10.0
for i in count: var i = 0
await sprintTo(anchor + Vector2.from_angle(deg_to_rad(i / count * 360.0 - 90)) * radius, 0.5) var currentAngle = 0
for bullet in BulletBase.generate( var time = 500.0
ComponentManager.getBullet("Egg"), await sprintTo(anchor + Vector2(0, -radius), 0.1)
self , attack2Start = timeLived()
position, while timeLived() - attack2Start <= time:
0 var targetAngle = deg_to_rad(i / count * 360.0 - 90)
): currentAngle = deg_to_rad((timeLived() - attack2Start) / time * 360.0 - 90)
if bullet is EggBullet: position = anchor + Vector2.from_angle(currentAngle) * radius
bullet.look_at(anchor) 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 TickTool.millseconds(2000)
await chargeUp() await chargeUp()
+8 -1
View File
@@ -325,7 +325,7 @@ func useEnergy(value: float):
energy -= finalEnergy(value) energy -= finalEnergy(value)
energyChanged.emit(energy, false) energyChanged.emit(energy, false)
return state return state
func tryAttack(type: int, needChargeUp: bool = false): func tryAttack(type: int, chargeConfig: Variant = false):
var weapon: Weapon var weapon: Weapon
if isPlayer() and !isSummon(): if isPlayer() and !isSummon():
if len(weapons) > type: if len(weapons) > type:
@@ -343,6 +343,13 @@ func tryAttack(type: int, needChargeUp: bool = false):
cooldownTimer.cooldown = attackCooldownMap.get(type, defaultCooldownUnit) cooldownTimer.cooldown = attackCooldownMap.get(type, defaultCooldownUnit)
state = cooldownTimer.start() state = cooldownTimer.start()
if state: if state:
var needChargeUp: bool
if chargeConfig is bool:
needChargeUp = chargeConfig
elif chargeConfig is Array:
needChargeUp = type in chargeConfig
else:
needChargeUp = false
if needChargeUp: if needChargeUp:
await chargeUp() await chargeUp()
for attackingState in attackingStates: for attackingState in attackingStates: