nc543 5079a77296 Main Menu and AI
- Mostly finished the settings menu
- Got basic AI working on easy difficulty
- Changed when animations are loaded
- Music now changes when you hit play
- Changed how AI will work. All enemies should only need the combatant script now
2024-05-12 00:22:34 -04:00

40 lines
1.1 KiB
GDScript

extends "res://Scripts/animationBase.gd"
var path: PathFollow2D
var failPath: PathFollow2D
var casting: bool = true
var timer: float = 0
@onready var texture: TextureRect = $Path2D/PathFollow2D/TextureRect
# Called when the node enters the scene tree for the first time.
func _ready():
if !inverted:
path = $Path2D/PathFollow2D
failPath = $Path2D/PathFollow2D/Path2D/PathFollow2D
else:
path = $Path2D/PathFollow2D
failPath = $Path2D/PathFollow2D/Path2D/PathFollow2D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if casting:
if targetProg / finalProg < 0.7:
timer = clampf(timer + delta, 0, clampf(targetProg / finalProg, 0, 0.35))
path.progress_ratio = timer
else:
timer = clampf(timer + delta, 0, 1)
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() -> void:
casting = false
texture.get_parent().remove_child(texture)
failPath.add_child(texture)
timer = 0