mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
fb0b98c96e
添加红水晶武器系统,包括武器、子弹、特效和音效资源 - 新增红水晶武器脚本及场景,实现爆炸伤害功能 - 添加红水晶子弹逻辑,支持半径爆炸效果 - 加入红水晶爆炸特效和音效 - 更新角色武器库包含红水晶武器 - 调整现有水晶武器描述和数值 - 扩展子弹基类支持首帧回调 - 更新特效控制器支持音效播放等待
41 lines
1.1 KiB
GDScript
41 lines
1.1 KiB
GDScript
extends Node2D
|
|
class_name EffectController
|
|
|
|
@export var oneShot: bool = true
|
|
@export var spawnSound: String = ""
|
|
@export var spawnAnimation: String = ""
|
|
|
|
@onready var particles: GPUParticles2D = $"%particles"
|
|
@onready var sounds: Node2D = $"%sounds"
|
|
@onready var animator: AnimationPlayer = $"%animator"
|
|
|
|
func _ready():
|
|
particles.emitting = false
|
|
particles.one_shot = oneShot
|
|
var sound = sounds.get_node_or_null(spawnSound)
|
|
if sound and sound.stream:
|
|
sound.play()
|
|
if spawnAnimation:
|
|
animator.play(spawnAnimation)
|
|
func shot():
|
|
var cloned = particles.duplicate() as GPUParticles2D
|
|
cloned.emitting = true
|
|
add_child(cloned)
|
|
if oneShot:
|
|
await cloned.finished
|
|
cloned.queue_free()
|
|
if spawnSound:
|
|
var sound: AudioStreamPlayer2D = sounds.get_node(spawnSound)
|
|
if sound.playing:
|
|
await sound.finished
|
|
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
|