2025-09-13 22:46:25 +08:00
|
|
|
extends BulletBase
|
|
|
|
|
|
|
|
|
|
@export var allColor: GradientTexture1D = null
|
2025-09-14 08:23:26 +08:00
|
|
|
@export var length: float = 1000
|
2025-09-13 22:46:25 +08:00
|
|
|
|
2025-09-14 08:23:26 +08:00
|
|
|
@onready var track: ShaderStage = $"%track"
|
2025-09-13 22:46:25 +08:00
|
|
|
@onready var sword: Sprite2D = $"%sword"
|
|
|
|
|
@onready var points: GPUParticles2D = $"%points"
|
|
|
|
|
var myColor: Color
|
2026-01-17 12:30:09 +08:00
|
|
|
|
2025-09-13 22:46:25 +08:00
|
|
|
func spawn():
|
|
|
|
|
myColor = allColor.gradient.sample(randf())
|
|
|
|
|
track.material = track.material.duplicate()
|
|
|
|
|
points.process_material = points.process_material.duplicate()
|
|
|
|
|
setColor(myColor)
|
2025-09-14 17:10:17 +08:00
|
|
|
track.size.y = length
|
2025-09-14 08:23:26 +08:00
|
|
|
TickTool.modifyAnimationKey(animator, "spawn", "sword:position:x", Animation.TrackType.TYPE_BEZIER, 2.5, length / -2)
|
|
|
|
|
TickTool.modifyAnimationKey(animator, "spawn", "sword:position:x", Animation.TrackType.TYPE_BEZIER, 3, length / 2)
|
|
|
|
|
TickTool.modifyAnimationKey(animator, "spawn", "%hitbox:position:x", Animation.TrackType.TYPE_BEZIER, 2.5, length / -2)
|
|
|
|
|
TickTool.modifyAnimationKey(animator, "spawn", "%hitbox:position:x", Animation.TrackType.TYPE_BEZIER, 3, length / 2)
|
|
|
|
|
await TickTool.millseconds(2500)
|
|
|
|
|
points.emitting = true
|
2025-09-13 22:46:25 +08:00
|
|
|
func setColor(color: Color):
|
2025-09-14 17:10:17 +08:00
|
|
|
color.v *= 2
|
2025-09-14 13:02:00 +08:00
|
|
|
var result = Color(color)
|
|
|
|
|
result.a = 0
|
2025-09-14 17:10:17 +08:00
|
|
|
track.material.set_shader_parameter("laser_color", result)
|
2025-09-13 22:46:25 +08:00
|
|
|
sword.modulate = color
|
2025-09-14 13:02:00 +08:00
|
|
|
points.process_material.color = color
|