SchildDerStaerke/scripts/knight.gd

30 lines
1018 B
GDScript

class_name Knight extends Player
var attacks := ["1h_slice_diagonal", "1h_slice_horizontal", "1h_attack_chop"]
var footsteps := [
"res://resources/audio/footstep_grass_000.ogg",
"res://resources/audio/footstep_grass_001.ogg",
"res://resources/audio/footstep_grass_002.ogg",
"res://resources/audio/footstep_grass_003.ogg",
"res://resources/audio/footstep_grass_004.ogg"
]
func _input(event: InputEvent) -> void:
# Attack
if event.is_action_pressed("attack"):
if enough_stamina_available(attack_cost):
use_stamina(attack_cost)
if state == States.blocking:
anim_state.travel("Block_Attack")
else:
anim_state.travel(attacks.pick_random())
# Block
if Input.is_action_pressed("block"): state = States.blocking
if Input.is_action_just_released("block"): state = States.idle
anim_tree.set("parameters/conditions/blocking", state == States.blocking)
anim_tree.set("parameters/conditions/not_blocking", state != States.blocking)
# Calls the _input() from player.gd
super._input(event)