Start of animation player state mashine

This commit is contained in:
Paul Norberger
2020-04-19 10:19:32 +02:00
parent d71b728e94
commit 917aff815a
15 changed files with 88 additions and 63 deletions

View File

@@ -7,25 +7,3 @@ func _ready():
"split_up": $SplitUp,
"stagger": $Stagger
}
func _change_state(state_name):
# The base state_machine interface this node extends does most of the work
if not _active:
return
if state_name in ["stagger"]:
states_stack.push_front(states_map[state_name])
if state_name == "jump" and current_state == $Move:
$Jump.initialize($Move.speed, $Move.velocity)
._change_state(state_name)
func _input(event):
"""
Here we only handle input that can interrupt states, attacking in this case
otherwise we let the state node handle it
"""
if event.is_action_pressed("attack"):
if current_state == $Attack:
return
_change_state("attack")
return
current_state.handle_input(event)

View File

@@ -1,4 +1,4 @@
extends "res://Boss/SlimeBoss/States/Motion/MotionState.gd"
extends "res://Overlap/StateMachine/MotionState.gd"
func enter():
owner.get_node("AnimationPlayer").play("MoveDown") # TODO: Replace animation
@@ -9,4 +9,5 @@ func handle_input(event):
func update(delta):
var input_direction = get_input_direction()
if input_direction:
emit_signal("finished", "move")
# emit_signal("finished", "move")
pass

View File

@@ -1,7 +0,0 @@
extends "res://Overlap/StateMachine/State.gd"
func get_input_direction():
var input_direction = Vector2()
input_direction.x = int(Input.is_action_pressed("move_right")) - int(Input.is_action_pressed("move_left"))
input_direction.y = int(Input.is_action_pressed("move_down")) - int(Input.is_action_pressed("move_up"))
return input_direction