Compare commits
2 Commits
b5d9e9268c
...
f67fdbbe3e
| Author | SHA1 | Date | |
|---|---|---|---|
| f67fdbbe3e | |||
| 45cff3f039 |
|
|
@ -36,14 +36,15 @@ func _ready():
|
||||||
#check for unique state name
|
#check for unique state name
|
||||||
if !(states_index.has(this_state.name)):
|
if !(states_index.has(this_state.name)):
|
||||||
# call setup
|
# call setup
|
||||||
this_state.setup()
|
var dupe_state = this_state.duplicate()
|
||||||
|
dupe_state.setup()
|
||||||
if debug_state_machine:
|
if debug_state_machine:
|
||||||
print("Initializing State Node: ", s)
|
print("Initializing State Node: ", s)
|
||||||
this_state.debug_state = true
|
dupe_state.debug_state = true
|
||||||
if this_state.state_timeout != null:
|
if dupe_state.state_timeout != null:
|
||||||
add_child(this_state.state_timeout)
|
add_child(dupe_state.state_timeout)
|
||||||
# Add to state index
|
# Add to state index
|
||||||
states_index[this_state.name] = this_state
|
states_index[dupe_state.name] = dupe_state
|
||||||
else:
|
else:
|
||||||
push_error("Multiple states with same name in: ")
|
push_error("Multiple states with same name in: ")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -284,8 +284,8 @@ crouch_1={
|
||||||
}
|
}
|
||||||
jump_1={
|
jump_1={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":32,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
dash_1={
|
dash_1={
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ func get_movement_direction() -> float:
|
||||||
var _wants_jump :bool
|
var _wants_jump :bool
|
||||||
func wants_jump() -> bool:
|
func wants_jump() -> bool:
|
||||||
if Input.is_action_just_pressed("jump_" + str(player_number)) and stamina_component.stamina >= state_stamina_cost["jump"]:
|
if Input.is_action_just_pressed("jump_" + str(player_number)) and stamina_component.stamina >= state_stamina_cost["jump"]:
|
||||||
desired_movement_vector.y = UP
|
##Bugfix: Both players jump.
|
||||||
|
#desired_movement_vector.y = UP
|
||||||
_wants_jump = true
|
_wants_jump = true
|
||||||
return true
|
return true
|
||||||
else:
|
else:
|
||||||
|
|
@ -130,7 +131,8 @@ func flip_sprite_to_movement_direction():
|
||||||
parent.transform.x.x = desired_movement_vector.x
|
parent.transform.x.x = desired_movement_vector.x
|
||||||
|
|
||||||
func _state_process_physics_idle():
|
func _state_process_physics_idle():
|
||||||
if desired_movement_vector.y == UP:
|
##Bugfix
|
||||||
|
if _wants_jump:
|
||||||
request_state_change.call_func('jump')
|
request_state_change.call_func('jump')
|
||||||
|
|
||||||
if _wants_crouch == true:
|
if _wants_crouch == true:
|
||||||
|
|
@ -303,7 +305,7 @@ func _state_process_physics_move():
|
||||||
# flip sprite in direction
|
# flip sprite in direction
|
||||||
flip_sprite_to_movement_direction()
|
flip_sprite_to_movement_direction()
|
||||||
|
|
||||||
if desired_movement_vector.y == UP:
|
if _wants_jump:
|
||||||
request_state_change.call_func('jump')
|
request_state_change.call_func('jump')
|
||||||
|
|
||||||
if desired_movement_vector.x == 0:
|
if desired_movement_vector.x == 0:
|
||||||
|
|
@ -428,6 +430,7 @@ func _state_process_physics_crouch_move():
|
||||||
# print("Movement State Idle State Entered!")
|
# print("Movement State Idle State Entered!")
|
||||||
|
|
||||||
func _on_state_entered_jump():
|
func _on_state_entered_jump():
|
||||||
|
print ("how many times do I get called?")
|
||||||
#TODO: Make this a state variable
|
#TODO: Make this a state variable
|
||||||
# I used to call it 'jump_force' like an idiot.
|
# I used to call it 'jump_force' like an idiot.
|
||||||
velocity.y = -200
|
velocity.y = -200
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,6 @@ func _ready():
|
||||||
selected_inventory_items.set_player_number(player_number)
|
selected_inventory_items.set_player_number(player_number)
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta):
|
func _process(delta):
|
||||||
# pass
|
if PlayerInfo.get_player_data(player_number - 1) == null:
|
||||||
|
visible = false
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user