mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-28 06:22:40 +08:00
refactor(Statemachine): 将冲刺逻辑提取到独立方法中
将velocity处理和冲刺条件判断提取到新的sprintAi方法中,提高代码可读性和复用性
This commit is contained in:
@@ -159,8 +159,7 @@ func _process(_delta):
|
|||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.2))
|
animatree.set("parameters/blend_position", lerpf(animatree.get("parameters/blend_position"), lastDirection, 0.2))
|
||||||
if sprinting:
|
if sprinting:
|
||||||
velocity *= 0.9
|
if sprintAi():
|
||||||
if velocity.length() <= 100:
|
|
||||||
sprinting = false
|
sprinting = false
|
||||||
else:
|
else:
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
@@ -354,6 +353,9 @@ func isPlayer():
|
|||||||
# 抽象方法,实际上是一些钩子,不需要全部实现
|
# 抽象方法,实际上是一些钩子,不需要全部实现
|
||||||
func ai():
|
func ai():
|
||||||
pass
|
pass
|
||||||
|
func sprintAi():
|
||||||
|
velocity *= 0.9
|
||||||
|
return velocity.length() <= 100
|
||||||
func attack(_type: int):
|
func attack(_type: int):
|
||||||
pass
|
pass
|
||||||
func die():
|
func die():
|
||||||
|
|||||||
Reference in New Issue
Block a user