implement drowning

This commit is contained in:
Haze Weathers 2023-06-29 23:01:59 -04:00
parent 4958c420d8
commit 325f2a6dd3
2 changed files with 63 additions and 11 deletions

View file

@ -260,6 +260,10 @@ func _on_Dead_state_entered() -> void:
#refill oxygen
oxygen_timer.start()
func _on_Drowning_state_entered() -> void:
state_chart.send_event("died")
animation_player.play("drown")
func _on_Respawn_state_entered() -> void:
global_position = Game.respawn_point
graphics.visible = true
@ -394,6 +398,15 @@ func _process_movement(delta: float) -> void:
if is_on_wall():
state_chart.send_event("push_start")
func _process_floating_up(delta: float) -> void:
graphics.global_position.y -= 50.0 * delta
var sprite_sector = Game.get_sector(Vector2(global_position.x, graphics.global_position.y))
if sprite_sector != Game.current_sector:
graphics.visible = false
graphics.position = Vector2.ZERO
emit_signal("died")
state_chart.send_event("respawn")
# COLLISION CALLBACKS #
func _on_Hitbox_body_entered(body: Node) -> void:
@ -407,10 +420,9 @@ func _on_Ducking_event_received(event):
func _on_OxygenTimer_timeout():
if underwater: die()
if underwater:
state_chart.send_event("drown")
#Reset low oxygen effect when leaving level
func _on_Player_tree_exited():
set_underwater_audio(false)