diff --git a/client/autoloads/gamestate.gd b/client/autoloads/gamestate.gd index c1a09033c5c1cf9f78e9b437377128782f2dd8f7..f257010295459f6eed1157b359d5a299db1ffc3e 100644 --- a/client/autoloads/gamestate.gd +++ b/client/autoloads/gamestate.gd @@ -193,7 +193,8 @@ func registerItem(itemId: int,itemType: int, position:Vector3): get_node("/root/game").addItem(itemId,itemType,position) func deleteItem(itemId: int): - get_node("/root/game/itemCollection/item"+str(itemId)).deleteItemClient() + if get_node("/root/game/itemCollection").has_node("item"+str(itemId)): + get_node("/root/game/itemCollection/item"+str(itemId)).deleteItemClient() func updateKills(networkId, kills): get_node("/root/game/"+str(networkId)).giveKill(kills) diff --git a/client/autoloads/interfaces.gd b/client/autoloads/interfaces.gd index 46f17386ea60626fe04901c1f03bcab184d3d7be..7b8be8694589e08c8cbb388725b75747e715db8e 100644 --- a/client/autoloads/interfaces.gd +++ b/client/autoloads/interfaces.gd @@ -83,15 +83,15 @@ var debug_display = null func _ready(): # Randomize the random number generator, so we get random values randomize() - + # Make a new canvas layer. # This is so our popup always appears on top of everything else canvas_layer = CanvasLayer.new() add_child(canvas_layer) - + #set screen size to the viewport size OS.set_window_maximized(true) - + func loadNewScene(new_scene_path): # Change scenes @@ -105,19 +105,19 @@ func loadNewScene(new_scene_path): # if Input.is_action_just_pressed("ui_cancel"): # if popup == null: # # Make a new popup scene - + # # Connect the signals # popup.get_node("Button_quit").connect("pressed", self, "popup_quit") # popup.connect("popup_hide", self, "popup_closed") # popup.get_node("Button_resume").connect("pressed", self, "popup_closed") - + # # Add it as a child, and make it pop up in the center of the screen # canvas_layer.add_child(popup) # popup.popup_centered() - + # # Make sure the mouse is visible # Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - + # # Pause the game # get_tree().paused = true @@ -125,7 +125,7 @@ func loadNewScene(new_scene_path): # func popup_closed(): # # Unpause the game # get_tree().paused = false - + # # If we have a popup, destoy it # if popup != null: # popup.queue_free() @@ -134,14 +134,14 @@ func loadNewScene(new_scene_path): # func popup_quit(): # get_tree().paused = false - + # # Make sure the mouse is visible # Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) - + # # If we have a popup, destoy it # if popup != null: # popup.queue_free() # popup = null - + # # Go back to the title screen scene # loadNewScene(MAIN_MENU_PATH) diff --git a/client/project.godot b/client/project.godot index 95771b898db2445a935ccf64468bd156a4870aba..ed776308191e1eaecad39533f625733f231d001d 100644 --- a/client/project.godot +++ b/client/project.godot @@ -28,6 +28,12 @@ saveSettings="*res://autoloads/saveSettings.gd" [input] +ui_up={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) + ] +} movementLeft={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null) @@ -38,6 +44,7 @@ movementJump={ "deadzone": 0.5, "events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"unicode":0,"echo":false,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null) ] } movementRight={ diff --git a/server/autoloads/gamestate.gd b/server/autoloads/gamestate.gd index bd380bf1b14e87df8c734be4b69ce08fbd276140..d664c20e2c65a809824dc3e75259e74109420087 100644 --- a/server/autoloads/gamestate.gd +++ b/server/autoloads/gamestate.gd @@ -21,7 +21,7 @@ var players:Dictionary = {} const START_UP_DELAY:int = 5 signal serverValidation -const LOADING_DELAY:float = 10.0 +const LOADING_DELAY:float = 60.0 var clientsLoaded:Timer signal readyToProcess @@ -35,6 +35,7 @@ const MAX_SPAWN_POINT = 70 var rng = RandomNumberGenerator.new() +signal finishLoading func _ready(): @@ -201,6 +202,11 @@ func spawnPlayer(): newPlayer.translate(spawnPosition) listAvailableSpawn.remove(i) +#Wait loading timeout +func timerLoadingDelay(): + yield(clientsLoaded,"timeout") + emit_signal("finishLoading") + # Wait for server validation and start the game # => TODO: server validation timeout ? @@ -220,13 +226,15 @@ func startGame() -> void: get_tree().get_root().add_child(game) spawnPlayer() + timerLoadingDelay() # Broadcast the beginning of the game to the clients loaded for clientNetworkId in registeredClients: network.loadGame(clientNetworkId, players) + while(len(missingClients)!=0 && clientsLoaded.get_time_left()!=0): + yield(self,"finishLoading") - yield(clientsLoaded, "timeout") print("loading timeout") emit_signal("readyToProcess") @@ -249,6 +257,7 @@ func clientGameLoaded(clientId:int): return missingClients.erase(clientId) + emit_signal("finishLoading") # Kick a client from the game with a message