2024-05-03 07:56:32 -04:00
|
|
|
extends "res://Scripts/animationBase.gd"
|
|
|
|
|
2024-05-03 19:45:30 -04:00
|
|
|
var path: PathFollow2D
|
|
|
|
var failPath: PathFollow2D
|
|
|
|
var casting: bool = true
|
|
|
|
var timer: float = 0
|
|
|
|
@onready var texture: TextureRect = $Path2D/PathFollow2D/TextureRect
|
|
|
|
|
2024-05-03 07:56:32 -04:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2024-05-03 19:45:30 -04:00
|
|
|
if !inverted:
|
|
|
|
path = $Path2D/PathFollow2D
|
|
|
|
failPath = $Path2D/PathFollow2D/Path2D/PathFollow2D
|
2024-05-03 07:56:32 -04:00
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
2024-05-03 19:45:30 -04:00
|
|
|
if casting:
|
|
|
|
timer = clampf(timer + delta, 0, targetProg / finalProg)
|
|
|
|
path.progress_ratio = timer
|
|
|
|
if path.progress_ratio == 1:
|
|
|
|
self.free()
|
|
|
|
else:
|
|
|
|
timer = clampf(timer + (1.25 * delta), 0, 1)
|
|
|
|
failPath.progress_ratio = timer
|
|
|
|
if failPath.progress_ratio == 1:
|
|
|
|
self.free()
|
|
|
|
|
|
|
|
func castFailed():
|
|
|
|
casting = false
|
|
|
|
texture.get_parent().remove_child(texture)
|
|
|
|
failPath.add_child(texture)
|
|
|
|
timer = 0
|