Bandage for #35

This commit is contained in:
Paul Black 2023-03-17 12:11:47 -06:00
parent 6183e16fcb
commit 686e2e9159
6 changed files with 61 additions and 26 deletions

View file

@ -64,6 +64,7 @@ func _unhandled_input(event):
if menuOpen == false: if menuOpen == false:
if Input.is_action_just_pressed("menu"): if Input.is_action_just_pressed("menu"):
menuOpen = true menuOpen = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
var scene_trs = load("res://scenes/mainmenu.tscn") var scene_trs = load("res://scenes/mainmenu.tscn")
var scene = scene_trs.instantiate() var scene = scene_trs.instantiate()
globalscene = scene globalscene = scene

View file

@ -68,6 +68,7 @@ offset_bottom = 369.0
text = "Master Volume" text = "Master Volume"
[node name="volumeSlider" type="HSlider" parent="."] [node name="volumeSlider" type="HSlider" parent="."]
layout_mode = 0
offset_left = 487.0 offset_left = 487.0
offset_top = 380.0 offset_top = 380.0
offset_right = 671.0 offset_right = 671.0

View file

@ -75,6 +75,35 @@ func reset_variables():
playerAlive = true playerAlive = true
playerPleaseRespawn = false playerPleaseRespawn = false
func reset_variables_hard():
print("Variables were HARD reset")
fatigue = 100
playerHealth = 100
playerDead = false
playerAlive = true
playerPleaseRespawn = false
connectedPlayers = []
Networking.connected_peers = []
connectedPlayersByPeerID = []
roundInSession = false
playingGame = false
consoleOpen = false
godMode = false
multiplayerCurrent = false
teddyAuthorityID = null
miniMenuResume = false
HUDStartLabelText = ""
lastPersonToHitMe = 0
HUDPlayerDied = false
respawnTimeModifier = 1.0
menuLightSwitch = false
gamemode = "Deathmatch"
chosenRunner = null
iAmRunner = false
runnerDead = false
roundTimer = 300.0
spawnCoordsInitalized = false
func save_data(): func save_data():
SettingsFile.save_data(mouseSensitivity, playerName, volumeModifer) SettingsFile.save_data(mouseSensitivity, playerName, volumeModifer)

View file

@ -17,8 +17,7 @@ func _ready():
$Button.disabled = false $Button.disabled = false
$AudioStreamPlayer.playing = false $AudioStreamPlayer.playing = false
if Global.playingGame == false: if Global.playingGame == false:
Global.connectedPlayers = [] Global.reset_variables_hard()
Networking.connected_peers = []
$musicPanel.visible = true $musicPanel.visible = true
$musicPanel/playingLabel.text = musicName $musicPanel/playingLabel.text = musicName
$musicPanel/authorLabel.text = musicAuthor $musicPanel/authorLabel.text = musicAuthor

View file

@ -19,8 +19,12 @@ func create_server(port, maxPlayers):
peer.peer_connected.connect( peer.peer_connected.connect(
func(new_peer_id): func(new_peer_id):
print("NEW CONNECTION FROM ", new_peer_id)
await get_tree().create_timer(0.5).timeout ## REQUIRED, THE RPC IS MADE BEFORE THE CLIENT IS FULLY CONNECTED await get_tree().create_timer(0.5).timeout ## REQUIRED, THE RPC IS MADE BEFORE THE CLIENT IS FULLY CONNECTED
if connected_peers.has(new_peer_id):
print("CONFLICT ID FOUND")
return
else:
print("NEW CONNECTION FROM ", new_peer_id)
rpc_id(new_peer_id, "sync_names", Global.connectedPlayers) rpc_id(new_peer_id, "sync_names", Global.connectedPlayers)
rpc_id(new_peer_id, "sync_respawn_speed", Global.respawnTimeModifier) rpc_id(new_peer_id, "sync_respawn_speed", Global.respawnTimeModifier)
rpc_id(new_peer_id, "sync_gamemode", Global.gamemode) rpc_id(new_peer_id, "sync_gamemode", Global.gamemode)
@ -31,7 +35,7 @@ func create_server(port, maxPlayers):
) )
### NOT WORKING YET ### NOT WORKING YET
peer.peer_disconnected.disconnect( peer.peer_disconnected.connect(
func(peer_id): func(peer_id):
rpc("disconnect_peer", peer_id) rpc("disconnect_peer", peer_id)
) )

View file

@ -10,6 +10,7 @@ func _process(delta):
func _on_yes_button_pressed(): func _on_yes_button_pressed():
Networking.peer.close()
Global.playingGame = false Global.playingGame = false
get_tree().change_scene_to_file(Global.goScene) get_tree().change_scene_to_file(Global.goScene)