mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 15:01:53 +08:00
feat(战斗系统): 改进攻击逻辑和Kernyr角色技能
重构tryAttack方法,将needChargeUp参数改为更灵活的chargeConfig配置 优化Kernyr角色的攻击2技能,改为持续旋转发射子弹
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user