Raise-Your-Wand/Scripts/combatant.gd
nc5432 940fed1170 Background and UI
- Got new backgrounds
- Added health bars
- Added in enemy wizard using the wizard spellbook rather than the old spellbook
- Made the cast indicator smaller since it seemed a bit large
- Started working on enemy AI systems
- Fixed rock throw animation
2024-05-07 21:43:09 -04:00

73 lines
1.6 KiB
GDScript

class_name Combatant extends Node2D
signal healthChanged(health: float)
@onready var renderer: AnimatedSprite2D = $AnimatedSprite2D
@onready var healthbar: HealthBar = $HealthBar
@onready var data: Data = get_node("/root/Arena/Data")
@export var spellbook: Spellbook
@export var maxHealth: float = 10
@export var health: float = maxHealth
@export var player: bool = false
var casting: bool = false
var castCooldown: float = 0
# Called when the node enters the scene tree for the first time.
func _ready():
renderer.animation_finished.connect(animationFinished)
renderer.play("idle")
spellbook.initCooldowns()
healthbar.maxHealth = maxHealth
if !player:
data.opponent = self
renderer.flip_h = true
healthbar.position.x *= -1
match data.difficulty:
Data.Difficulty.EASY: castCooldown = 3
Data.Difficulty.NORMAL: castCooldown = 1
Data.Difficulty.HARD: castCooldown = 0.5
Data.Difficulty.GAMER: castCooldown = 0
else:
data.player = self
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if !player:
match data.difficulty:
Data.Difficulty.EASY: _easyAI(delta)
Data.Difficulty.NORMAL: _normalAI(delta)
Data.Difficulty.HARD: _hardAI(delta)
Data.Difficulty.GAMER: _gamerAI(delta)
func _easyAI(delta):
pass
func _normalAI(delta):
pass
func _hardAI(delta):
pass
func _gamerAI(delta):
pass
func _finishedCasting():
pass
func timing(delta):
castCooldown -= delta
if castCooldown <= 0:
pass
func alterHealth(change: float, stun: bool):
health += change
if stun:
casting = false
renderer.play("hit")
healthChanged.emit(health)
func animationFinished():
renderer.play("idle")