Raise-Your-Wand/Scripts/combatant.gd
2024-05-03 19:45:30 -04:00

39 lines
886 B
GDScript

extends Node2D
class_name Combatant
@export var spellbook: Spellbook
@onready var renderer: AnimatedSprite2D = $AnimatedSprite2D
@onready var particleSystem: GPUParticles2D = $chargingParticles
@export var maxHealth: float = 10
@export var health: float = maxHealth
@export var player: bool = false
var casting = false
# Called when the node enters the scene tree for the first time.
func _ready():
renderer.animation_finished.connect(animationFinished)
spellbook.initCooldowns()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if !player:
_aiControlled()
func _aiControlled():
pass
func alterHealth(damage: float, stun: bool):
health -= damage
if stun:
casting = false
renderer.play("hit")
func enableParticles(_strength: float):
particleSystem.emitting = true
func animationFinished():
renderer.play("idle")