1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

refactor(Bullets): 优化子弹格挡逻辑并提取公共方法

重构Parrier.gd中的格挡逻辑,将重复代码提取为parryEffect和penerateEffect方法
调整FoxZhua子弹的追踪位置和场景配置
修改waveDebugConfig使用测试BOSS而非测试小怪
This commit is contained in:
2026-04-30 18:32:34 +08:00
parent 550718c742
commit 5cef96cd34
4 changed files with 50 additions and 36 deletions
+1 -1
View File
@@ -5,4 +5,4 @@ class_name FoxZhua
func ai():
if canTrace:
PresetBulletAI.lerpPosition(self, launcher.currentFocusedBoss.getTrackingAnchor() - Vector2(0, 200), speed)
PresetBulletAI.lerpPosition(self , launcher.currentFocusedBoss.getTrackingAnchor(), speed)
+39 -23
View File
@@ -9,6 +9,32 @@ var maxBallCount: int = 5
var atk: float = 1
var reflectRate: float = 1
func parryEffect(bullet: BulletBase):
# 生成格挡特效
parryiedTimes += 1
var eff = EffectController.create(ComponentManager.getEffect("Parry"), position + (bullet.position - position).normalized() * 200) # 从子弹位置,面向其他子弹的方向前进150
eff.modulate = bullet.modulate.blend(bullet.texture.modulate)
eff.rotation = position.angle_to_point(bullet.position)
eff.shot()
launcher.impluse((position - bullet.position).normalized() * bullet.speed ** (1.0 / 2) * 250)
func penerateEffect(entity: EntityBase):
parryiedTimes += 1
var eff = EffectController.create(ComponentManager.getEffect("ParryEntity"), position)
eff.rotation = position.angle_to_point(position)
eff.shot()
entity.impluse((position - entity.position).normalized() * 450)
func generateParryBall(targetBaseDamage: float):
var cycler = launcher.getOrCreateCycleTimer("parry", 2000, 100)
if len(cycler.bullets) < maxBallCount: # 玩家最多只能拥有多少气
for b in BulletBase.generate(
ComponentManager.getBullet("ParryBall"), # 生成气的子弹
launcher,
position,
0
):
if b is ParryBallBullet:
b.atk = atk * targetBaseDamage
func spawn():
var varians = randi_range(0, 1)
var inverts = [2]
@@ -22,25 +48,17 @@ func spawn():
eff.shot()
func succeedToHit(_dmg: float, entity: EntityBase):
if parryiedTimes < maxParryTimes && MathTool.rate(parryRate):
parryiedTimes += 1
var effSpawn = entity.texture.global_position
var eff = EffectController.create(ComponentManager.getEffect("ParryEntity"), effSpawn)
eff.rotation = position.angle_to_point(effSpawn)
eff.shot()
entity.impluse((effSpawn - position).normalized() * 450)
penerateEffect(entity)
func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞
if !is_instance_valid(launcher): return
if BulletTool.canDamage(bullet, launcher): # 其他子弹可以使当前子弹的发射者受伤吗?
if parryiedTimes < maxParryTimes && MathTool.rate(parryRate): # 一个刀光最多格挡多少个敌方子弹?
parryiedTimes += 1
# 生成格挡特效
var eff = EffectController.create(ComponentManager.getEffect("Parry"), position + (bullet.position - position).normalized() * 200) # 从子弹位置,面向其他子弹的方向前进150
eff.modulate = bullet.modulate.blend(bullet.texture.modulate)
eff.rotation = position.angle_to_point(bullet.position)
eff.shot()
launcher.impluse((position - bullet.position).normalized() * bullet.speed ** (1.0 / 2) * 250)
var targetBaseDamage = bullet.baseDamage
# 可以格挡 挥舞运动(近战攻击)、射弹运动(远程攻击)和猛冲运动 的子弹,射弹如果被弹反则不会产生气力
# 魔法运动和召唤运动的子弹虽不能格挡,但是可以储能,吐息运动的子弹会对发射者产生击退
if bullet.motionType == BulletBase.MotionType.PROJECTILE:
# 无论如何都要生成格挡特效
parryEffect(bullet)
# 弹反 还是 格挡?
if MathTool.rate(reflectRate):
bullet.look_at(bullet.launcher.getTrackingAnchor())
@@ -52,26 +70,24 @@ func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞
bullet.animator.speed_scale *= 0.5
else:
bullet.tryDestroy()
generateParryBall(targetBaseDamage)
elif bullet.motionType == BulletBase.MotionType.SWING:
parryEffect(bullet)
bullet.hitbox.disabled = true
generateParryBall(targetBaseDamage)
elif bullet.motionType == BulletBase.MotionType.SPRINT:
parryEffect(bullet)
bullet.tryDestroy()
bullet.launcher.velocity *= -0.1
generateParryBall(targetBaseDamage)
elif bullet.motionType == BulletBase.MotionType.BREATH:
penerateEffect(bullet.launcher)
bullet.hitbox.disable = true
bullet.launcher.impluse(Vector2.from_angle(bullet.rotation) * -500)
elif bullet.motionType == BulletBase.MotionType.SUMMON || bullet.motionType == BulletBase.MotionType.MAGIC:
penerateEffect(bullet.launcher)
launcher.storeEnergy(sqrt(bullet.baseDamage))
var cycler = launcher.getOrCreateCycleTimer("parry", 2000, 100)
if len(cycler.bullets) < maxBallCount: # 玩家最多只能拥有多少气
for b in BulletBase.generate(
ComponentManager.getBullet("ParryBall"), # 生成气的子弹
launcher,
position,
0
):
if b is ParryBallBullet:
b.atk = atk * targetBaseDamage
func refract(_newBullet: BulletBase, _entity: EntityBase, _index: int, _total: int, _lastBullet: float):
return null
func split(_newBullet: BulletBase, _index: int, _total: int, _lastBullet: float):
+1 -1
View File
@@ -57,7 +57,7 @@ static var WAVE_TESTMOB = [
]
static var WAVE_EMPTY = []
static var waveReleaseConfig = [WAVE_TESTBOSS, 1]
static var waveDebugConfig = [WAVE_TESTMOB, 1]
static var waveDebugConfig = [WAVE_TESTBOSS, 1]
static var current: int = startWith(waveReleaseConfig[1]) if WorldManager.isRelease() else startWith(waveDebugConfig[1])
static var data = waveReleaseConfig[0] if WorldManager.isRelease() else waveDebugConfig[0]