2026-03-16 23:35:22 +08:00
|
|
|
extends BulletBase
|
|
|
|
|
class_name ParrierBullet
|
|
|
|
|
|
2026-03-17 06:49:46 +08:00
|
|
|
@export var parryRate: float = 1
|
|
|
|
|
|
2026-03-21 13:51:17 +08:00
|
|
|
var parryiedTimes: int = 0
|
|
|
|
|
var maxParryTimes: int = 1
|
2026-03-21 14:37:46 +08:00
|
|
|
var maxBallCount: int = 3
|
|
|
|
|
var atk: float = 0
|
2026-03-21 13:51:17 +08:00
|
|
|
|
2026-03-19 22:58:50 +08:00
|
|
|
func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞
|
|
|
|
|
if BulletTool.canDamage(bullet, launcher): # 其他子弹可以使当前子弹的发射者受伤吗?
|
2026-03-21 13:51:17 +08:00
|
|
|
if parryiedTimes < maxParryTimes && MathTool.rate(parryRate): # 一个刀光最多格挡多少个敌方子弹?
|
|
|
|
|
parryiedTimes += 1
|
2026-03-19 22:58:50 +08:00
|
|
|
# 生成格挡特效
|
|
|
|
|
var eff = EffectController.create(ComponentManager.getEffect("Parry"), position + (bullet.position - position).normalized() * 150) # 从子弹位置,面向其他子弹的方向前进150
|
2026-03-17 22:15:28 +08:00
|
|
|
eff.modulate = bullet.modulate.blend(bullet.texture.modulate)
|
2026-03-17 06:49:46 +08:00
|
|
|
eff.shot()
|
2026-03-19 22:58:50 +08:00
|
|
|
# 摧毁其他子弹
|
2026-03-17 06:49:46 +08:00
|
|
|
bullet.tryDestroy()
|
2026-03-17 22:58:04 +08:00
|
|
|
var cycler = launcher.getOrCreateCycleTimer("parry", 2000, 100)
|
2026-03-21 14:37:46 +08:00
|
|
|
if len(cycler.bullets) < maxBallCount: # 玩家最多只能拥有5点气
|
2026-03-17 22:58:04 +08:00
|
|
|
for b in BulletBase.generate(
|
2026-03-19 22:58:50 +08:00
|
|
|
ComponentManager.getBullet("ParryBall"), # 生成气的子弹
|
2026-03-17 22:58:04 +08:00
|
|
|
launcher,
|
|
|
|
|
position,
|
|
|
|
|
0
|
|
|
|
|
):
|
|
|
|
|
if b is ParryBallBullet:
|
2026-03-21 14:37:46 +08:00
|
|
|
b.atk = atk
|