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

feat(子弹): 添加紫色水晶子弹的爆炸效果和销毁逻辑

refactor(子弹基类): 重构销毁逻辑防止重复调用
fix(敌人): 调整小鸡boss的出现波次和激光音效
style(场景文件): 整理动画资源顺序
This commit is contained in:
2025-08-29 12:42:44 +08:00
parent 2a8ea238ad
commit f52f7cda8e
9 changed files with 68 additions and 37 deletions
+16 -8
View File
@@ -23,6 +23,7 @@ class_name BulletBase
var launcher: EntityBase = null
var spawnInWhen: float = 0
var spawnInWhere: Vector2 = Vector2.ZERO
var destroying: bool = false
func _ready():
register()
@@ -35,17 +36,19 @@ func _ready():
animator.play("spawn")
await animator.animation_finished
if freeAfterSpawn:
destroy()
tryDestroy()
if autoLoopAnimation:
animator.play("loop")
func _process(_delta: float) -> void:
if destroying: return
if lifeTime > 0:
if WorldManager.getTime() - spawnInWhen >= lifeTime:
destroy()
tryDestroy()
if lifeDistance > 0:
if position.distance_to(spawnInWhere) >= lifeDistance:
destroy()
tryDestroy()
func _physics_process(_delta: float) -> void:
if destroying: return
if is_instance_valid(launcher) and (launcher.isPlayer() or is_instance_valid(launcher.currentFocusedBoss)):
launcher.position -= Vector2.from_angle(rotation) * recoil
ai()
@@ -61,7 +64,7 @@ func hit(target: Node):
if MathTool.rate(fullPenerate()):
penerate -= entity.fields[FieldStore.Entity.PENARATION_RESISTANCE]
else:
destroy()
tryDestroy()
func forward(direction: Vector2):
position += direction.normalized() * speed * GameRule.bulletSpeedMultiplier
func fullPenerate():
@@ -71,15 +74,20 @@ func timeLived():
func dotLoop():
if await applyDot():
await dotLoop()
func tryDestroy():
if destroying: return
destroying = true
await destroy()
if autoDestroyAnimation:
animator.play("destroy")
await animator.animation_finished
queue_free()
# 抽象方法
func ai():
pass
func destroy():
if autoDestroyAnimation:
animator.play("destroy")
await animator.animation_finished
queue_free()
pass
func spawn():
pass
func applyDot():
+9
View File
@@ -15,3 +15,12 @@ func shot():
if oneShot:
await cloned.finished
cloned.queue_free()
static func create(scene: PackedScene, spawnPosition: Vector2, parent: Node2D = null) -> EffectController:
var cloned = scene.instantiate() as EffectController
cloned.global_position = spawnPosition
if parent:
parent.add_child(cloned)
else:
WorldManager.rootNode.add_child(cloned)
return cloned