2024-05-13 22:38:17 -04:00
|
|
|
extends AnimationBase
|
2024-05-03 19:45:30 -04:00
|
|
|
|
2024-05-04 11:48:54 -04:00
|
|
|
@export var explodeDur: float = 0.2
|
2024-05-13 22:38:17 -04:00
|
|
|
@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:
|
2024-05-13 22:38:17 -04:00
|
|
|
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):
|
2024-05-13 22:38:17 -04:00
|
|
|
if (exploding):
|
2024-05-04 11:48:54 -04:00
|
|
|
timer += delta
|
|
|
|
if timer > explodeDur:
|
2024-05-13 22:38:17 -04:00
|
|
|
self.queue_free()
|
2024-05-03 19:45:30 -04:00
|
|
|
|
2024-05-12 00:22:34 -04:00
|
|
|
func setProgress(target: float, final: float = finalProg) -> void:
|
|
|
|
targetProg = target
|
|
|
|
finalProg = final
|
2024-05-13 22:38:17 -04:00
|
|
|
if (index > -1):
|
|
|
|
animationPlayer.queue(attackName + str(index))
|
|
|
|
index += 1
|
2024-05-12 00:22:34 -04:00
|
|
|
|
2024-05-09 22:21:58 -04:00
|
|
|
func explode() -> void:
|
2024-05-13 22:38:17 -04:00
|
|
|
particles.position = ballofayr.position
|
2024-05-04 11:48:54 -04:00
|
|
|
ballofayr.hide()
|
|
|
|
particles.emitting = true
|
|
|
|
exploding = true
|
|
|
|
timer = 0
|
|
|
|
|
2024-05-13 22:38:17 -04:00
|
|
|
func animFinished(s: String):
|
|
|
|
print("Animation finished with indices " + str(index) + " and " + str(finalIndex))
|
|
|
|
if (index == finalIndex):
|
|
|
|
animationFinished.emit(spell)
|
|
|
|
explode()
|
|
|
|
|
2024-05-09 22:21:58 -04:00
|
|
|
func castFailed() -> void:
|
2024-05-04 11:48:54 -04:00
|
|
|
explode()
|