Added skill system

This commit is contained in:
2024-02-13 23:12:32 +01:00
parent cf155d9aab
commit d87d4c9e3f
15 changed files with 117 additions and 43 deletions

View File

@ -11,7 +11,6 @@ var skip: int
func _ready():
var player := owner as Player
player.dashed.connect(dash)
player.skill_used.connect(use_skill)
movement = player.find_child("Movement")
animation_player = $AnimationPlayer
@ -24,11 +23,6 @@ func _process(_delta):
animation_player.play(next_animation)
if animation_player.current_animation == "human/spin":
animation_player.speed_scale = 2.0
else:
animation_player.speed_scale = 1.0
func play_movement():
if !movement:
play(RESET)
@ -46,19 +40,14 @@ func play_movement():
func dash():
play_with_duration("human/roll", 1.0)
func use_skill(slot: int):
match slot:
0:
play_with_duration("human/spin", 0.9)
1:
play_with_duration("human/slash", 1.0)
func play(action_name: StringName):
next_animation = action_name
func play_with_duration(action_name: StringName, duration: float):
func play_with_duration(action_name: StringName, duration: float, speed: float = 1.0):
next_animation = action_name
skip += 1
animation_player.speed_scale = speed
await get_tree().create_timer(duration).timeout
animation_player.speed_scale = 1.0
skip -= 1