mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-31 08:21:54 +08:00
feat(子弹): 添加紫色水晶子弹的爆炸效果和销毁逻辑
refactor(子弹基类): 重构销毁逻辑防止重复调用 fix(敌人): 调整小鸡boss的出现波次和激光音效 style(场景文件): 整理动画资源顺序
This commit is contained in:
@@ -3,3 +3,5 @@ class_name PurpleCrystal
|
||||
|
||||
func ai():
|
||||
PresetsAI.forward(self, rotation)
|
||||
func destroy():
|
||||
EffectController.create(preload("res://components/Effects/PurpleCrystalExplosion.tscn"), global_position).shot()
|
||||
|
||||
@@ -12,7 +12,7 @@ static var current: int = 0
|
||||
static var data: Array[Wave] = [
|
||||
# entity, minCount, maxCount, isBoss, from, to, per
|
||||
create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1),
|
||||
create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 0, INF, 5),
|
||||
create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 8, INF, 6),
|
||||
]
|
||||
|
||||
static func create(
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user