46 lines
1.2 KiB
GDScript3
Raw Normal View History

extends AnimationBase
2024-05-03 19:45:30 -04:00
2024-05-04 11:48:54 -04:00
@export var explodeDur: float = 0.2
@onready var ballofayr: AnimatedSprite2D = $AnimatedSprite2D
@onready var animationPlayer: AnimationPlayer = $AnimationPlayer
@onready var particles: GPUParticles2D = $GPUParticles2D
2024-05-04 11:48:54 -04:00
var exploding: bool = false
2024-05-03 19:45:30 -04:00
var timer: float = 0
var size: Vector2 = Vector2(0, 0)
# Called when the node enters the scene tree for the first time.
func _ready():
if inverted:
attackName = inverseName
2024-05-03 19:45:30 -04:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if (exploding):
2024-05-04 11:48:54 -04:00
timer += delta
if timer > explodeDur:
self.queue_free()
2024-05-03 19:45:30 -04:00
func setProgress(target: float, final: float = finalProg) -> void:
targetProg = target
finalProg = final
if (index > -1):
animationPlayer.queue(attackName + str(index))
index += 1
func explode() -> void:
particles.position = ballofayr.position
2024-05-04 11:48:54 -04:00
ballofayr.hide()
particles.emitting = true
exploding = true
timer = 0
func animFinished(s: String):
print("Animation finished with indices " + str(index) + " and " + str(finalIndex))
if (index == finalIndex):
animationFinished.emit(spell)
explode()
func castFailed() -> void:
2024-05-04 11:48:54 -04:00
explode()