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