Raise-Your-Wand/Scripts/SpellSlot.gd

27 lines
694 B
GDScript3
Raw Normal View History

class_name SpellSlot extends TextureRect
@onready var overlay: ColorRect = $Overlay
@onready var particles: GPUParticles2D = $GPUParticles2D
@onready var data: Data = $/root/Root/Data
@export var spell: Spell
var timer: float = 0
var canCast: bool = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if (spell == null || !data.playing): return
timer = clampf(timer - delta, 0, spell.cooldown)
if (!canCast && timer == 0):
canCast = true
particles.emitting = true
overlay.scale.y = timer / spell.cooldown
func setSpell(spel: Spell):
spell = spel
texture = spel.icon
func spellCast(down: float):
timer = down
canCast = false