mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
refactor(战斗系统): 优化攻击逻辑和碰撞处理
- 将蓄力攻击逻辑提取为独立方法 chargeUp 以提高代码复用性 - 调整攻击动画的等待时间,增加蓄力效果 - 添加碰撞反弹处理并重置冲刺状态 - 优化冲刺逻辑,在不可冲刺时提前终止
This commit is contained in:
@@ -39,7 +39,8 @@ func attack(type: int):
|
||||
var anchor = currentFocusedBoss.position
|
||||
var radius = 600
|
||||
await sprintTo(anchor + Vector2(0, -radius), 0.1)
|
||||
await TickTool.millseconds(2000)
|
||||
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)
|
||||
@@ -51,4 +52,5 @@ func attack(type: int):
|
||||
):
|
||||
if bullet is YangyiBullet:
|
||||
bullet.look_at(anchor)
|
||||
await TickTool.millseconds(3000)
|
||||
await TickTool.millseconds(2000)
|
||||
await chargeUp()
|
||||
|
||||
@@ -203,6 +203,11 @@ func _physics_process(_delta: float) -> void:
|
||||
velocity += inertia
|
||||
inertia *= 0.9
|
||||
move_and_slide()
|
||||
var collision = get_last_slide_collision()
|
||||
if is_instance_valid(collision):
|
||||
inertia = inertia.bounce(collision.get_normal())
|
||||
targetableSprinting = false
|
||||
sprinting = false
|
||||
storeEnergy(randf_range(0.01, 0.05 + fields.get(FieldStore.Entity.ENERGY_REGENERATION) - 1), true)
|
||||
trailParticle.emitting = trailing
|
||||
for cycler in cycleTimers.values():
|
||||
@@ -339,9 +344,7 @@ func tryAttack(type: int, needChargeUp: bool = false):
|
||||
state = cooldownTimer.start()
|
||||
if state:
|
||||
if needChargeUp:
|
||||
charginup = true
|
||||
await EffectController.create(ComponentManager.getEffect("AttackStar"), damageAnchor.global_position).shot()
|
||||
charginup = false
|
||||
await chargeUp()
|
||||
for attackingState in attackingStates:
|
||||
if attackingState in attackMutexes:
|
||||
return false
|
||||
@@ -356,6 +359,10 @@ func tryAttack(type: int, needChargeUp: bool = false):
|
||||
playSound("attack" + str(type))
|
||||
attackingStates.erase(type)
|
||||
return state
|
||||
func chargeUp():
|
||||
charginup = true
|
||||
await EffectController.create(ComponentManager.getEffect("AttackStar"), damageAnchor.global_position).shot()
|
||||
charginup = false
|
||||
func trySprint():
|
||||
trailing = true
|
||||
playSound("sprint")
|
||||
@@ -370,7 +377,7 @@ func sprintTo(target: Vector2, speed: float):
|
||||
await TickTool.until(
|
||||
func():
|
||||
position += (target - position) * speed
|
||||
return position.distance_to(target) < 10
|
||||
return position.distance_to(target) < 10 || !targetableSprinting
|
||||
)
|
||||
position = target
|
||||
trailing = false
|
||||
|
||||
Reference in New Issue
Block a user