mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-29 07:21:54 +08:00
3089af3ea0
确保在子弹分裂和折射时检查返回的子弹对象是否有效,避免空引用异常
29 lines
884 B
GDScript
29 lines
884 B
GDScript
extends BulletBase
|
|
class_name ParryBallBullet
|
|
|
|
var cycler: CycleTimer
|
|
var atk: float = 0
|
|
|
|
func spawn():
|
|
cycler = launcher.getOrCreateCycleTimer("parry")
|
|
cycler.host(self )
|
|
launcher.sprintMultiplier += 1
|
|
func destroy(_beacuseMap: bool):
|
|
launcher.sprintMultiplier -= 1
|
|
func ai():
|
|
PresetBulletAI.selfRotate(self , 5)
|
|
hitbox.disabled = !launcher.sprinting # 玩家在冲刺时气的碰撞箱才生效
|
|
hitbox.global_position = launcher.position
|
|
func succeedToHit(_dmg: float, entity: EntityBase): # 当撞到敌人时
|
|
for bullet in BulletBase.generate(
|
|
ComponentManager.getBullet("QKSword"),
|
|
launcher,
|
|
entity.position,
|
|
0
|
|
):
|
|
if bullet is QKSwordBullet:
|
|
bullet.baseDamage = atk
|
|
bullet.position = entity.texture.global_position + MathTool.sampleInRing(200, 500)
|
|
bullet.tracer = entity
|
|
bullet.look_at(entity.getTrackingAnchor()) # 生成的乾坤剑面向敌人
|