Despirate tweaks to make game end more gracefully.
This commit is contained in:
parent
33a9848524
commit
07e98d0736
|
|
@ -49,20 +49,27 @@ func change_level(_level_name :String, _position_name :String):
|
|||
var new_level = load("res://src/levels/" + _level_name + ".tscn" ).instance()
|
||||
#print (get_tree().get_root().get_children())
|
||||
|
||||
for l in get_node("/root/Main/ViewportContainer/Viewport/World").get_children():
|
||||
for l in viewport.get_children():
|
||||
#print (get_node("/root/Main").get_children())
|
||||
if l is Level:
|
||||
camera_guide.disable_tracking()
|
||||
SceneTransition.transition_dissolve("foo")
|
||||
yield(SceneTransition,"done")
|
||||
##TODO: Disabled signal based yield because I think it was taking too long
|
||||
# No more errors but I'd like to know how to do this.
|
||||
#SceneTransition.transition_dissolve("foo")
|
||||
#yield(SceneTransition,"done")
|
||||
yield(SceneTransition.transition_dissolve("foo"), "completed")
|
||||
print(l)
|
||||
get_node("/root/Main/ViewportContainer/Viewport/World").remove_child(l)
|
||||
get_node("/root/Main/ViewportContainer/Viewport/World").add_child(new_level)
|
||||
get_node("/root/Main/ViewportContainer/Viewport/World").move_child(new_level,1)
|
||||
viewport.remove_child(l)
|
||||
viewport.add_child(new_level)
|
||||
##TODO: make this right below scene transition
|
||||
viewport.move_child(new_level,2)
|
||||
#get_node("/root/Main/ViewportContainer/Viewport/World").remove_child(l)
|
||||
#get_node("/root/Main/ViewportContainer/Viewport/World").add_child(new_level)
|
||||
#get_node("/root/Main/ViewportContainer/Viewport/World").move_child(new_level,1)
|
||||
##TODO: Probably set start position
|
||||
if new_level.entrances.has(_position_name):
|
||||
player_start_position = new_level.entrances[_position_name].transform.origin
|
||||
print (get_node("/root/Main/ViewportContainer/Viewport").get_children())
|
||||
#print (get_node("/root/Main/ViewportContainer/Viewport").get_children())
|
||||
#get_node("/root/Main/ViewportContainer/Viewport/CameraGuide").global_position = Vector2(160,90)
|
||||
SceneTransition.reset()
|
||||
camera_guide.transform.origin = Vector2(160,90)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ func _player_connected(id):
|
|||
|
||||
# Callback from SceneTree.
|
||||
func _player_disconnected(id):
|
||||
if has_node("/root/Main"): # Game is in progress.
|
||||
##TODO: Need better way to determine a game is running
|
||||
if has_node("/root/Main/ViewportContainer/Viewport/1"): # Game is in progress.
|
||||
if get_tree().is_network_server():
|
||||
emit_signal("game_error", "Player " + players[id] + " disconnected")
|
||||
end_game()
|
||||
|
|
@ -130,6 +131,8 @@ remote func pre_start_game(spawn_points):
|
|||
|
||||
get_tree().get_root().get_node("/root/Main/ViewportContainer/Viewport/Lobby").hide()
|
||||
|
||||
## Clear the PlayerInfo table in case this is a restart.
|
||||
PlayerInfo.reset()
|
||||
var player_scene = load("res://src/actors/players/playerE/PlayerE.tscn")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ func get_player_data(index :int) -> PlayerData:
|
|||
else:
|
||||
return null
|
||||
|
||||
func reset():
|
||||
_player_data.clear()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ func _ready():
|
|||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
debug_text = ''
|
||||
for _player_id in NetworkManager.get_player_ids():
|
||||
debug_text += str(_player_id) + '\n'
|
||||
#func _process(delta):
|
||||
# debug_text = ''
|
||||
# for _player_id in NetworkManager.get_player_ids():
|
||||
# debug_text += str(_player_id) + '\n'
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ var entrances:Dictionary
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
add_to_group("world")
|
||||
LevelInfo.player_start_position = player_start.transform.origin
|
||||
if music_track:
|
||||
LevelInfo.change_music_track(music_track)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ radius = 5.09902
|
|||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
|
||||
[node name="CloneBox" instance=ExtResource( 1 )]
|
||||
[node name="CloneBox" groups=["world"] instance=ExtResource( 1 )]
|
||||
|
||||
[node name="TileMap Collision" parent="." index="1"]
|
||||
tile_set = ExtResource( 2 )
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ points = PoolVector2Array( 20, 20, 0.326027, 20, 0.326027, 0.605103, 20, 0.60510
|
|||
|
||||
[sub_resource type="CircleShape2D" id=6]
|
||||
|
||||
[node name="TestBox" instance=ExtResource( 1 )]
|
||||
[node name="TestBox" groups=["world"] instance=ExtResource( 1 )]
|
||||
music_track = ExtResource( 5 )
|
||||
|
||||
[node name="TileMap Collision" parent="." index="1"]
|
||||
|
|
@ -64,7 +64,7 @@ tile_data = PoolIntArray( 524288, 0, 2, 524307, 0, 3 )
|
|||
position = Vector2( 80, 131 )
|
||||
|
||||
[node name="Hitbox_Component" parent="." index="4" instance=ExtResource( 3 )]
|
||||
damage_amount = 10
|
||||
damage_amount = 90
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="Hitbox_Component" index="0"]
|
||||
margin_left = 266.0
|
||||
|
|
|
|||
|
|
@ -96,3 +96,13 @@ func _on_start_pressed():
|
|||
|
||||
func _on_find_public_ip_pressed():
|
||||
OS.shell_open("https://icanhazip.com/")
|
||||
|
||||
|
||||
func _on_Lobby_focus_entered():
|
||||
if visible:
|
||||
$Connect/Join.grab_focus()
|
||||
|
||||
|
||||
func _on_Lobby_visibility_changed():
|
||||
if visible:
|
||||
$Connect/Join.grab_focus()
|
||||
|
|
|
|||
|
|
@ -169,6 +169,8 @@ margin_bottom = 58.0
|
|||
size_flags_horizontal = 2
|
||||
size_flags_vertical = 2
|
||||
|
||||
[connection signal="focus_entered" from="." to="." method="_on_Lobby_focus_entered"]
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_Lobby_visibility_changed"]
|
||||
[connection signal="pressed" from="Players/Start" to="." method="_on_start_pressed"]
|
||||
[connection signal="pressed" from="Players/FindPublicIP" to="." method="_on_find_public_ip_pressed"]
|
||||
[connection signal="pressed" from="Connect/Host" to="." method="_on_host_pressed"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user