nc5432 847a41eaad Animations and bug fixes
- Converted the rock throw animation to the new system
- Converted the fireball animation to the new system (needs to be inverted still)
- Spell variable now get set to null after use or they get interrupted
- Made some code more readable
2024-05-13 22:38:17 -04:00

46 lines
1.2 KiB
GDScript

extends AnimationBase
@export var explodeDur: float = 0.2
@onready var ballofayr: AnimatedSprite2D = $AnimatedSprite2D
@onready var animationPlayer: AnimationPlayer = $AnimationPlayer
@onready var particles: GPUParticles2D = $GPUParticles2D
var exploding: bool = false
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
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if (exploding):
timer += delta
if timer > explodeDur:
self.queue_free()
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
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:
explode()