generated from krampus/template-godot4
Practice manager respawns player on death
This commit is contained in:
parent
0952cd7486
commit
478b1e0849
|
@ -426,7 +426,6 @@ func finish_death() -> void:
|
||||||
print_debug("finishing death sequence")
|
print_debug("finishing death sequence")
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
player.die()
|
player.die()
|
||||||
queue_free()
|
|
||||||
|
|
||||||
|
|
||||||
func _set_club_type(new_club_type: Club.Type) -> void:
|
func _set_club_type(new_club_type: Club.Type) -> void:
|
||||||
|
@ -530,6 +529,8 @@ func _process(delta: float) -> void:
|
||||||
# REMOVEME
|
# REMOVEME
|
||||||
if Input.is_action_just_pressed("ui_menu"):
|
if Input.is_action_just_pressed("ui_menu"):
|
||||||
print("Debugging...")
|
print("Debugging...")
|
||||||
|
if Input.is_action_just_pressed("debug_2"):
|
||||||
|
player.life -= 90
|
||||||
|
|
||||||
## Visual updates
|
## Visual updates
|
||||||
# Rotation
|
# Rotation
|
||||||
|
@ -645,6 +646,7 @@ func _process(delta: float) -> void:
|
||||||
phase = Phase.AIM
|
phase = Phase.AIM
|
||||||
Phase.DEAD:
|
Phase.DEAD:
|
||||||
start_death()
|
start_death()
|
||||||
|
phase = Phase.FINISHED
|
||||||
|
|
||||||
|
|
||||||
func _on_ball_sleeping_state_changed() -> void:
|
func _on_ball_sleeping_state_changed() -> void:
|
||||||
|
|
|
@ -101,6 +101,11 @@ func die() -> void:
|
||||||
on_death.emit(self)
|
on_death.emit(self)
|
||||||
|
|
||||||
|
|
||||||
|
func deconstruct() -> void:
|
||||||
|
if is_instance_valid(shot_setup):
|
||||||
|
shot_setup.queue_free()
|
||||||
|
|
||||||
|
|
||||||
## Create a debug player instance
|
## Create a debug player instance
|
||||||
static func create_debug() -> WorldPlayer:
|
static func create_debug() -> WorldPlayer:
|
||||||
var instance := WorldPlayer.new()
|
var instance := WorldPlayer.new()
|
||||||
|
|
|
@ -22,5 +22,6 @@ func on_turn_finished(_source: ShotSetup) -> void:
|
||||||
|
|
||||||
|
|
||||||
func on_player_death(source: WorldPlayer) -> void:
|
func on_player_death(source: WorldPlayer) -> void:
|
||||||
# TODO game over screen
|
# Respawn player
|
||||||
winner.emit(source)
|
source.life = WorldPlayer.MAX_LIFE
|
||||||
|
spawning.emit(source)
|
||||||
|
|
|
@ -25,6 +25,7 @@ func on_player_death(player: WorldPlayer) -> void:
|
||||||
on_turn_finished(player.shot_setup)
|
on_turn_finished(player.shot_setup)
|
||||||
|
|
||||||
players.erase(player)
|
players.erase(player)
|
||||||
|
player.deconstruct()
|
||||||
print("Player 0 phase: ", ShotSetup.Phase.keys()[players[0].shot_setup.phase])
|
print("Player 0 phase: ", ShotSetup.Phase.keys()[players[0].shot_setup.phase])
|
||||||
if len(players) == 1:
|
if len(players) == 1:
|
||||||
on_win_condition()
|
on_win_condition()
|
||||||
|
|
|
@ -31,6 +31,7 @@ func _ready() -> void:
|
||||||
manager.winner.connect(_on_winner)
|
manager.winner.connect(_on_winner)
|
||||||
|
|
||||||
manager.initialize()
|
manager.initialize()
|
||||||
|
|
||||||
if not manager.players:
|
if not manager.players:
|
||||||
push_warning("Warning: Starting game world with no players!")
|
push_warning("Warning: Starting game world with no players!")
|
||||||
|
|
||||||
|
@ -51,7 +52,8 @@ func _spawn_player(player: WorldPlayer) -> void:
|
||||||
var spawn_point := _random_spawn()
|
var spawn_point := _random_spawn()
|
||||||
var shot_setup := player.shot_setup
|
var shot_setup := player.shot_setup
|
||||||
shot_setup.global_transform = spawn_point.global_transform
|
shot_setup.global_transform = spawn_point.global_transform
|
||||||
spawn_point.add_sibling(shot_setup)
|
if not shot_setup.get_parent():
|
||||||
|
spawn_point.add_sibling(shot_setup)
|
||||||
|
|
||||||
|
|
||||||
func _on_winner(_player: WorldPlayer) -> void:
|
func _on_winner(_player: WorldPlayer) -> void:
|
||||||
|
|
Loading…
Reference in New Issue