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")
|
||||
get_tree().paused = false
|
||||
player.die()
|
||||
queue_free()
|
||||
|
||||
|
||||
func _set_club_type(new_club_type: Club.Type) -> void:
|
||||
|
@ -530,6 +529,8 @@ func _process(delta: float) -> void:
|
|||
# REMOVEME
|
||||
if Input.is_action_just_pressed("ui_menu"):
|
||||
print("Debugging...")
|
||||
if Input.is_action_just_pressed("debug_2"):
|
||||
player.life -= 90
|
||||
|
||||
## Visual updates
|
||||
# Rotation
|
||||
|
@ -645,6 +646,7 @@ func _process(delta: float) -> void:
|
|||
phase = Phase.AIM
|
||||
Phase.DEAD:
|
||||
start_death()
|
||||
phase = Phase.FINISHED
|
||||
|
||||
|
||||
func _on_ball_sleeping_state_changed() -> void:
|
||||
|
|
|
@ -101,6 +101,11 @@ func die() -> void:
|
|||
on_death.emit(self)
|
||||
|
||||
|
||||
func deconstruct() -> void:
|
||||
if is_instance_valid(shot_setup):
|
||||
shot_setup.queue_free()
|
||||
|
||||
|
||||
## Create a debug player instance
|
||||
static func create_debug() -> WorldPlayer:
|
||||
var instance := WorldPlayer.new()
|
||||
|
|
|
@ -22,5 +22,6 @@ func on_turn_finished(_source: ShotSetup) -> void:
|
|||
|
||||
|
||||
func on_player_death(source: WorldPlayer) -> void:
|
||||
# TODO game over screen
|
||||
winner.emit(source)
|
||||
# Respawn player
|
||||
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)
|
||||
|
||||
players.erase(player)
|
||||
player.deconstruct()
|
||||
print("Player 0 phase: ", ShotSetup.Phase.keys()[players[0].shot_setup.phase])
|
||||
if len(players) == 1:
|
||||
on_win_condition()
|
||||
|
|
|
@ -31,6 +31,7 @@ func _ready() -> void:
|
|||
manager.winner.connect(_on_winner)
|
||||
|
||||
manager.initialize()
|
||||
|
||||
if not manager.players:
|
||||
push_warning("Warning: Starting game world with no players!")
|
||||
|
||||
|
@ -51,6 +52,7 @@ func _spawn_player(player: WorldPlayer) -> void:
|
|||
var spawn_point := _random_spawn()
|
||||
var shot_setup := player.shot_setup
|
||||
shot_setup.global_transform = spawn_point.global_transform
|
||||
if not shot_setup.get_parent():
|
||||
spawn_point.add_sibling(shot_setup)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue