This commit is contained in:
Paul Black 2023-04-15 15:04:16 -06:00
parent 0dfd5fcc10
commit b38ab10ba1
5 changed files with 20 additions and 12 deletions

View file

@ -47,6 +47,7 @@ var AIHit = false # Used so the AI knows to take damage
var iAmDeadAndInnocent = false # Used to keep track of when an innocent dies in TTT
var spawnCotton = false # bullet will change this to true
var addedMenuScene = false # Used for teddy.gd, fixes multiple menu bug
var tutorialCompleted = false # Used in the save file, to know if a play should go to tutorial first
func _process(delta):
#if not spawnCoordsInitalized:
@ -116,7 +117,7 @@ func reset_variables_hard():
iAmDeadAndInnocent = false
func save_data():
SettingsFile.save_data(mouseSensitivity, playerName, volumeModifer)
SettingsFile.save_data()
func spawn_locations():
if mapName == "Toyland":

View file

@ -17,6 +17,10 @@ func _ready():
$Button.disabled = false
$AudioStreamPlayer.playing = false
if Global.playingGame == false:
if not Global.tutorialCompleted:
get_tree().change_scene_to_file("res://scenes/tutorial.tscn")
Global.mapName = "Tutorial"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
Global.reset_variables_hard()
$musicPanel.visible = true
$musicPanel/playingLabel.text = musicName

View file

@ -6,6 +6,8 @@ func _ready():
Global.playerHealth = 100
Global.fatigue = 100
Global.roundTimer = 90.0
Global.tutorialCompleted = true
Global.save_data()
func _process(delta):

View file

@ -38,13 +38,11 @@ func create_server(port, maxPlayers):
add_player_node(new_peer_id)
)
### NOT WORKING YET, THIS SIGNAL SEEMS TO BE CALLED WHEN CLIENT LOOSES CONNECTION TO SERVER NOT WHEN SERVER LOOSES CONNECTION TO CLIENT (sometimes???)
peer.peer_disconnected.connect(
func(peer_id):
rpc_id(peer_id, "disconnect_peer_from_server", peer_id)
func():
peer_disconnected()
)
func load_map(map):
Global.multiplayerCurrent = true
get_tree().change_scene_to_file(map)
@ -73,8 +71,7 @@ func add_previously_connected_player_characters(peer_ids):
for peer_id in peer_ids:
add_player_node(peer_id)
@rpc
func disconnect_peer_from_server(peer_id):
func peer_disconnected():
print("Server connection lost...")
Global.HUDStartLabelText = "Connection lost to server!"

View file

@ -5,7 +5,8 @@ const SETTINGS_FILE = "user://settings.vars" # user:// path varies depending on
var settings_template = { # Default values if we don't already have a settings file. Assigned in save_data()
'mousesense': 0.01,
'playername' : "player",
'volume' : 0.5
'volume' : 0.5,
'tutorialCompleted' : false
}
var settings_data = {} # This gets filled as soon as load_data() is called.
@ -29,11 +30,12 @@ func check_data(): # Makes sure the save file exists
var file2 = FileAccess.open(SETTINGS_FILE, FileAccess.WRITE)
file2.store_line(JSON.stringify(settings_template)) # Writes settings_template to our file SETTINGS_FILE
func save_data(mousesense, playername, volume): # It's required you pass both the mouse sensitivity and the player name to save current data
func save_data():
var file = FileAccess.open(SETTINGS_FILE, FileAccess.WRITE)
settings_data['mousesense'] = mousesense
settings_data['playername'] = playername
settings_data['volume'] = volume
settings_data['mousesense'] = Global.mouseSensitivity
settings_data['playername'] = Global.playerName
settings_data['volume'] = Global.volumeModifer
settings_data['tutorialCompleted'] = Global.tutorialCompleted
file.store_line(JSON.stringify(settings_data))
func load_data():
@ -43,6 +45,8 @@ func load_data():
var mousesense = settings_data['mousesense']
var playername = settings_data['playername']
var volume = settings_data['volume']
var tutorialCompleted = settings_data['tutorialCompleted']
Global.mouseSensitivity = mousesense
Global.playerName = playername
Global.volumeModifer = volume
Global.tutorialCompleted = tutorialCompleted