mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-29 06:52:29 +08:00
refactor(EntityBase): 调整方法顺序以提高代码可读性
将getSprintInitialDisplace和getSprintProgress方法移动到move方法附近,使相关功能代码更集中
This commit is contained in:
@@ -160,10 +160,6 @@ func _physics_process(_delta: float) -> void:
|
|||||||
trailParticle.emitting = trailing
|
trailParticle.emitting = trailing
|
||||||
|
|
||||||
# 通用方法
|
# 通用方法
|
||||||
func getSprintInitialDisplace():
|
|
||||||
return displace(velocity) * sprintMultiplier
|
|
||||||
func getSprintProgress():
|
|
||||||
return velocity.length() / getSprintInitialDisplace().length()
|
|
||||||
func applyLevel():
|
func applyLevel():
|
||||||
fields[FieldStore.Entity.MAX_HEALTH] *= (1 + GameRule.entityHealthIncreasePerWave * (GameRule.difficulty + 1)) ** level
|
fields[FieldStore.Entity.MAX_HEALTH] *= (1 + GameRule.entityHealthIncreasePerWave * (GameRule.difficulty + 1)) ** level
|
||||||
fields[FieldStore.Entity.DAMAGE_MULTIPILER] *= (1 + GameRule.entityDamageIncreasePerWave * (GameRule.difficulty + 1)) ** level
|
fields[FieldStore.Entity.DAMAGE_MULTIPILER] *= (1 + GameRule.entityDamageIncreasePerWave * (GameRule.difficulty + 1)) ** level
|
||||||
@@ -174,6 +170,10 @@ func move(direction: Vector2, isSprinting: bool = false):
|
|||||||
var currentDirection = sign(direction.x)
|
var currentDirection = sign(direction.x)
|
||||||
if currentDirection != 0:
|
if currentDirection != 0:
|
||||||
lastDirection = currentDirection
|
lastDirection = currentDirection
|
||||||
|
func getSprintInitialDisplace():
|
||||||
|
return displace(velocity) * sprintMultiplier
|
||||||
|
func getSprintProgress():
|
||||||
|
return velocity.length() / getSprintInitialDisplace().length()
|
||||||
func takeDamage(bullet: BulletBase, crit: bool):
|
func takeDamage(bullet: BulletBase, crit: bool):
|
||||||
hurtAnimator.play("hurt")
|
hurtAnimator.play("hurt")
|
||||||
var baseDamage: float = bullet.damage * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
|
var baseDamage: float = bullet.damage * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
|
||||||
|
|||||||
Reference in New Issue
Block a user