Added multiple skills

This commit is contained in:
2024-02-13 21:04:35 +01:00
parent 7937645028
commit cf155d9aab
5 changed files with 43 additions and 23 deletions

View File

@ -1,7 +1,7 @@
class_name Player
extends CharacterBody3D
signal attacked
signal skill_used(slot: int)
signal dashed
signal jumped
signal name_changed(new_name: String)
@ -10,8 +10,8 @@ signal direction_changed
var id: String
var controller: Controller
func attack():
attacked.emit()
func use_skill(slot: int):
skill_used.emit(slot)
func dash():
dashed.emit()

View File

@ -11,7 +11,7 @@ var skip: int
func _ready():
var player := owner as Player
player.dashed.connect(dash)
player.attacked.connect(attack)
player.skill_used.connect(use_skill)
movement = player.find_child("Movement")
animation_player = $AnimationPlayer
@ -24,6 +24,11 @@ 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)
@ -41,8 +46,12 @@ func play_movement():
func dash():
play_with_duration("human/roll", 1.0)
func attack():
play_with_duration("human/slash", 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

View File

@ -29,6 +29,7 @@ func _unhandled_input(event):
if event.is_action_pressed("dash"):
player.dash()
if event.is_action_pressed("attack"):
player.attack()
for i in range(4):
if event.is_action_pressed("skill_%d" % (i + 1)):
player.use_skill(i)

View File

@ -7,9 +7,9 @@ var area: Area3D
func _ready():
player = owner
area = %MeleeArea
player.attacked.connect(attack)
player.skill_used.connect(use_skill)
func attack():
func use_skill(_slot: int):
await get_tree().create_timer(0.7).timeout
area.monitoring = true
await get_tree().create_timer(0.1).timeout