
- Increased text contrast in tavern - Fixed typo in cauterize wound description - (hopefully) fixed rare crash involving casting a spell and getting stunned
56 lines
1.4 KiB
GDScript
56 lines
1.4 KiB
GDScript
class_name AnimationBase extends Node2D
|
|
|
|
signal animationFinished(spell: Spell)
|
|
|
|
@onready var animationPlayer: AnimationPlayer = $AnimationPlayer
|
|
@onready var data: Data = $/root/Root/Data
|
|
|
|
@export var inverted: bool = false
|
|
@export var index: int = -1
|
|
@export var finalIndex: int = 0
|
|
@export var spell: Spell
|
|
@export var soundEffect: String
|
|
@export var soundPlayedIndex: int = -2
|
|
|
|
var attackName: String = "attackSegment"
|
|
var inverseName: String = "attackInverse"
|
|
var targetProg: float
|
|
var finalProg: float
|
|
var stream: AudioStream
|
|
var timing: float = 0
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
if (soundEffect != ""):
|
|
stream = load(soundEffect)
|
|
if (stream == null): print(spell.name + " failed")
|
|
if inverted:
|
|
attackName = inverseName
|
|
|
|
func _process(delta):
|
|
if (!data.playing): self.queue_free()
|
|
timing += delta
|
|
if (timing > 10): self.queue_free()
|
|
|
|
func castFailed() -> void:
|
|
die()
|
|
|
|
func setProgress(target: float, final: float = finalProg) -> void:
|
|
targetProg = target
|
|
finalProg = final
|
|
if (index > -1):
|
|
if (animationPlayer.has_animation(attackName + str(index))): animationPlayer.queue(attackName + str(index))
|
|
if (index == soundPlayedIndex && soundEffect != ""):
|
|
data.playSound(stream)
|
|
index += 1
|
|
|
|
func animFinished(_s: String):
|
|
if (index == finalIndex):
|
|
if (index == soundPlayedIndex && soundEffect != ""):
|
|
data.playSound(stream)
|
|
animationFinished.emit(spell)
|
|
die()
|
|
|
|
func die():
|
|
queue_free()
|