Player cleanup
This commit is contained in:
parent
24d8ea3210
commit
f87eb297ba
|
|
@ -6,6 +6,8 @@ export var player_number: int = 1
|
||||||
onready var player_inventory :InventoryManager = InventoryManager.new()
|
onready var player_inventory :InventoryManager = InventoryManager.new()
|
||||||
onready var stamina_component = $"%Stamina_Component"
|
onready var stamina_component = $"%Stamina_Component"
|
||||||
onready var health_component = $"%Health_Component"
|
onready var health_component = $"%Health_Component"
|
||||||
|
onready var hitbox_component = $Hitbox_Component
|
||||||
|
onready var hurtbox_component = $Hurtbox_Component
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,7 +48,7 @@ func _ready():
|
||||||
player_data.player_stamina = stamina_component.stamina
|
player_data.player_stamina = stamina_component.stamina
|
||||||
else:
|
else:
|
||||||
## puppets cannot get hurt, only network master.
|
## puppets cannot get hurt, only network master.
|
||||||
$Hurtbox_Component.hurtbox_entered_function = ''
|
hurtbox_component.hurtbox_entered_function = ''
|
||||||
|
|
||||||
# Set initial player position in world.
|
# Set initial player position in world.
|
||||||
global_position = LevelInfo.player_start_position
|
global_position = LevelInfo.player_start_position
|
||||||
|
|
@ -67,12 +69,6 @@ func _process(delta):
|
||||||
player_data.player_position = global_position.round()
|
player_data.player_position = global_position.round()
|
||||||
player_data.player_stamina = stamina_component.stamina
|
player_data.player_stamina = stamina_component.stamina
|
||||||
|
|
||||||
##TODO: well I'm not sure I like this but making a whole state receiver is silly
|
|
||||||
if state_damage_amount.has(movement_state_machine.current_state.name):
|
|
||||||
$Hitbox_Component.damage_amount = state_damage_amount[movement_state_machine.current_state.name]
|
|
||||||
else:
|
|
||||||
$Hitbox_Component.damage_amount = 10
|
|
||||||
|
|
||||||
match movement_state_machine.current_state.name:
|
match movement_state_machine.current_state.name:
|
||||||
"idle":
|
"idle":
|
||||||
if Input.is_action_just_released("switch_primary_item_" + str(player_number)):
|
if Input.is_action_just_released("switch_primary_item_" + str(player_number)):
|
||||||
|
|
@ -84,12 +80,19 @@ func _process(delta):
|
||||||
if _selected_item:
|
if _selected_item:
|
||||||
print("Switched Secondary item to: ", _selected_item.name)
|
print("Switched Secondary item to: ", _selected_item.name)
|
||||||
|
|
||||||
|
# Adjust hitbox damage to current states or default
|
||||||
|
##TODO: well I'm not sure I like this but making a whole state receiver is silly
|
||||||
|
if state_damage_amount.has(movement_state_machine.current_state.name):
|
||||||
|
hitbox_component.damage_amount = state_damage_amount[movement_state_machine.current_state.name]
|
||||||
|
else:
|
||||||
|
hitbox_component.damage_amount = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func hit_Receiver(damage):
|
func hit_Receiver(damage):
|
||||||
$Hurtbox_Component.set_hurtbox(false)
|
hurtbox_component.set_hurtbox(false)
|
||||||
health_component.take_damage(damage)
|
health_component.take_damage(damage)
|
||||||
if $Health_Component.health > 0:
|
if health_component.health > 0:
|
||||||
movement_state_machine.change_to_known_state('hurt')
|
movement_state_machine.change_to_known_state('hurt')
|
||||||
#PlayerInfo.player_health = health_component.health
|
#PlayerInfo.player_health = health_component.health
|
||||||
player_data.player_health = health_component.health
|
player_data.player_health = health_component.health
|
||||||
|
|
@ -97,8 +100,9 @@ func hit_Receiver(damage):
|
||||||
if health_component.health <= 0:
|
if health_component.health <= 0:
|
||||||
return
|
return
|
||||||
yield( get_tree().create_timer(2 + movement_state_machine.get_state_reference('hurt').timeout_seconds), "timeout")
|
yield( get_tree().create_timer(2 + movement_state_machine.get_state_reference('hurt').timeout_seconds), "timeout")
|
||||||
$Hurtbox_Component.set_hurtbox(true)
|
hurtbox_component.set_hurtbox(true)
|
||||||
|
|
||||||
|
## Interactable Receiver callback function. Anything touched goes here.
|
||||||
func touch_the_thing(the_thing: Interactable) -> bool:
|
func touch_the_thing(the_thing: Interactable) -> bool:
|
||||||
print("You see! a THING...", the_thing.name)
|
print("You see! a THING...", the_thing.name)
|
||||||
if the_thing is HealthPickup:
|
if the_thing is HealthPickup:
|
||||||
|
|
@ -121,6 +125,7 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
||||||
the_thing.trigger_interaction()
|
the_thing.trigger_interaction()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
func enough_stamina_for(_state_name :String) -> bool:
|
func enough_stamina_for(_state_name :String) -> bool:
|
||||||
if state_stamina_cost.has(_state_name):
|
if state_stamina_cost.has(_state_name):
|
||||||
if stamina_component.stamina >= state_stamina_cost[_state_name]:
|
if stamina_component.stamina >= state_stamina_cost[_state_name]:
|
||||||
|
|
@ -130,8 +135,6 @@ func enough_stamina_for(_state_name :String) -> bool:
|
||||||
## Return true by default because we don't have a cost for this move
|
## Return true by default because we don't have a cost for this move
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##DONE: We need to find a way to 'use' the item.
|
##DONE: We need to find a way to 'use' the item.
|
||||||
func use_primary_item() -> String:
|
func use_primary_item() -> String:
|
||||||
if player_inventory.primary_selection != null: # Have to make sure we even have a second
|
if player_inventory.primary_selection != null: # Have to make sure we even have a second
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user