2024-05-02 14:27:28 -04:00
|
|
|
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.
|
2024-05-03 19:45:30 -04:00
|
|
|
func _process(_delta):
|
2024-05-02 14:27:28 -04:00
|
|
|
if !player:
|
|
|
|
_aiControlled()
|
|
|
|
|
|
|
|
func _aiControlled():
|
|
|
|
pass
|
|
|
|
|
|
|
|
func alterHealth(damage: float, stun: bool):
|
|
|
|
health -= damage
|
|
|
|
if stun:
|
|
|
|
casting = false
|
|
|
|
renderer.play("hit")
|
|
|
|
|
2024-05-03 19:45:30 -04:00
|
|
|
func enableParticles(_strength: float):
|
2024-05-02 14:28:44 -04:00
|
|
|
particleSystem.emitting = true
|
|
|
|
|
|
|
|
|
2024-05-02 14:27:28 -04:00
|
|
|
func animationFinished():
|
|
|
|
renderer.play("idle")
|
|
|
|
|