48 lines
1.3 KiB
GDScript
48 lines
1.3 KiB
GDScript
extends State
|
|
|
|
export (NodePath) var jump_node
|
|
export (NodePath) var fall_node
|
|
export (NodePath) var move_node
|
|
export (NodePath) var fire_node
|
|
|
|
onready var jump_state: State = get_node(jump_node)
|
|
onready var fall_state: State = get_node(fall_node)
|
|
onready var move_state: State = get_node(move_node)
|
|
onready var fire_state: State = get_node(fire_node)
|
|
|
|
func enter() -> void:
|
|
.enter()
|
|
parent.set_hurtbox(true)
|
|
parent.velocity.x = 0
|
|
|
|
func process_input(_event: InputEvent) -> State:
|
|
# if get_jump() and parent.is_on_floor():
|
|
# return jump_state
|
|
|
|
if move_component.wants_jump() and parent.is_on_floor():
|
|
return jump_state
|
|
# if move_component.get_movement_direction() != 0.0:
|
|
# return move_state
|
|
if move_component.wants_shoot():
|
|
return fire_state
|
|
|
|
# move_component.wants_jump()
|
|
move_component.get_movement_direction()
|
|
|
|
# if Input.is_action_just_pressed('dash'):
|
|
# return dash_state
|
|
return null
|
|
|
|
func process_physics(delta: float) -> State:
|
|
parent.velocity.y += gravity * delta
|
|
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
|
parent.velocity.x = move_component.desired_movement_vector.x * move_speed
|
|
parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
|
|
|
if parent.velocity.x != 0.0:
|
|
return move_state
|
|
|
|
if !parent.is_on_floor():
|
|
return fall_state
|
|
return null
|