Game resets on player death.
This commit is contained in:
parent
0ea4a45b06
commit
590e786d83
|
|
@ -6,7 +6,7 @@
|
|||
[ext_resource path="res://lib/classes/animated_sprite_state_receiver.gd" type="Script" id=4]
|
||||
[ext_resource path="res://lib/classes/audiostreamplayer_state_receiver.gd" type="Script" id=5]
|
||||
|
||||
[node name="Actor" type="KinematicBody2D"]
|
||||
[node name="Actor" type="KinematicBody2D" groups=["world"]]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 2 )
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,18 @@ onready var current_music_track :AudioStream
|
|||
|
||||
onready var viewport_container = get_node("/root/Main/ViewportContainer") #$ViewportContainer
|
||||
onready var viewport = get_node("/root/Main/ViewportContainer/Viewport") # $ViewportContainer/Viewport
|
||||
onready var camera_guide :CameraGuide = get_node("/root/Main/ViewportContainer/Viewport/World/CameraGuide")
|
||||
onready var camera_guide :CameraGuide = get_node("/root/Main/ViewportContainer/Viewport/CameraGuide")
|
||||
|
||||
func _ready():
|
||||
NetworkManager.connect("game_started", self, "_on_game_started")
|
||||
NetworkManager.connect("game_ended", self, "_on_game_ended")
|
||||
|
||||
func _on_game_started():
|
||||
camera_guide.enable_tracking()
|
||||
|
||||
func _on_game_ended():
|
||||
camera_guide.disable_tracking()
|
||||
camera_guide.reset_position()
|
||||
|
||||
func change_music_track(_music_track :AudioStream ):
|
||||
if current_music_track != _music_track:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ signal player_list_changed()
|
|||
signal connection_failed()
|
||||
signal connection_succeeded()
|
||||
signal game_ended()
|
||||
signal game_started()
|
||||
signal game_error(what)
|
||||
|
||||
# Default game server port. Can be any number between 1024 and 49151.
|
||||
|
|
@ -88,6 +89,8 @@ remote func pre_start_game(spawn_points):
|
|||
var world :Node = load("res://src/levels/TestBox.tscn").instance()
|
||||
var ui :Node = load("res://src/ui/HUD.tscn").instance()
|
||||
world.set_name("World")
|
||||
world.add_to_group('world')
|
||||
ui.add_to_group('world')
|
||||
|
||||
get_tree().get_root().get_node("/root/Main/ViewportContainer/Viewport").add_child(world)
|
||||
get_tree().get_root().get_node("/root/Main/ViewportContainer/Viewport").add_child(ui)
|
||||
|
|
@ -130,7 +133,7 @@ remote func pre_start_game(spawn_points):
|
|||
|
||||
remote func post_start_game():
|
||||
get_tree().set_pause(false) # Unpause and unleash the game!
|
||||
|
||||
emit_signal("game_started")
|
||||
|
||||
remote func ready_to_start(id):
|
||||
assert(get_tree().is_network_server())
|
||||
|
|
@ -184,9 +187,10 @@ func begin_game():
|
|||
|
||||
|
||||
func end_game():
|
||||
if has_node("/root/Main/ViewportContainer/Viewport/World"): # Game is in progress.
|
||||
# End it
|
||||
get_node("/root/Main/ViewportContainer/Viewport/World").queue_free()
|
||||
get_tree().call_group("world","queue_free")
|
||||
# if has_node("/root/Main/ViewportContainer/Viewport/World"): # Game is in progress.
|
||||
# # End it
|
||||
# get_node("/root/Main/ViewportContainer/Viewport/World").queue_free()
|
||||
|
||||
emit_signal("game_ended")
|
||||
players.clear()
|
||||
|
|
|
|||
|
|
@ -200,3 +200,4 @@ func _on_Movement_StateMachine_state_changed(old_state_name, new_state):
|
|||
|
||||
func _on_Health_Component_health_depleted():
|
||||
movement_state_machine.change_to_known_state('death')
|
||||
NetworkManager.end_game()
|
||||
|
|
|
|||
|
|
@ -12,14 +12,21 @@ var _is_tracking :bool = true
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
## Do not track until told to
|
||||
disable_tracking()
|
||||
|
||||
func enable_tracking() -> void:
|
||||
##TODO: add extra collission checks here to make sure we aren't stuck maybe?
|
||||
_is_tracking = true
|
||||
self.set_physics_process(true)
|
||||
|
||||
func disable_tracking() -> void:
|
||||
_is_tracking = false
|
||||
self.set_physics_process(false)
|
||||
|
||||
func reset_position() -> void:
|
||||
## Set to half screen
|
||||
global_position = game_size / 2
|
||||
|
||||
var flip_tracker = 0.0
|
||||
var stuck_check: bool
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
radius = 6.0
|
||||
height = 2.0
|
||||
|
||||
[node name="MushroomPew" instance=ExtResource( 1 )]
|
||||
[node name="MushroomPew" groups=["world"] instance=ExtResource( 1 )]
|
||||
velocity_pps = 300.0
|
||||
lifespan = 0.5
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user