2024-08-05 22:35:50 +02:00
## freeftf
## Copyright (C) 2024 Patrick_Pluto
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
2024-08-02 22:38:08 +02:00
##
2024-08-05 22:35:50 +02:00
## You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
2024-08-02 22:38:08 +02:00
2024-08-02 00:55:56 +02:00
extends Node
2024-08-05 22:35:50 +02:00
var settings = { " save_version " = 2 , " fps_counter " = 1 }
2024-08-02 00:55:56 +02:00
var computers = 0
2024-08-02 20:13:42 +02:00
var players = 0
2024-08-05 22:35:50 +02:00
var map_name = " mansion "
2024-08-06 23:28:40 +02:00
var is_running = false
var frozen = 0
var dead = 0
var escaped = 0
var player_escaped = false
var is_beast = false
2024-08-05 22:35:50 +02:00
func _ready ( ) :
if FileAccess . file_exists ( " user://settings.json " ) :
var temp = Load . loadJSON ( " user://settings.json " )
if ! ( temp is Dictionary ) or settings [ " save_version " ] != temp [ " save_version " ] :
Save . saveJSON ( " user://settings.json " , settings )
else :
settings = temp
else :
Save . saveJSON ( " user://settings.json " , settings )
2024-08-06 11:13:52 +02:00
if OS . is_debug_build ( ) :
settings [ " fps_counter " ] = 1
2024-08-02 00:55:56 +02:00
2024-08-06 23:28:40 +02:00
func freeze ( ) :
players -= 1
frozen += 1
2024-08-03 22:24:08 +02:00
2024-08-06 23:28:40 +02:00
func unfreeze ( ) :
players += 1
frozen -= 1
func died ( ) :
frozen -= 1
dead += 1
func has_escaped ( ) :
players -= 1
escaped += 1
func _process ( delta ) :
if is_running and players < = 0 :
get_tree ( ) . change_scene_to_file ( " res://menus/result.tscn " )
Input . set_mouse_mode ( Input . MOUSE_MODE_VISIBLE )
is_running = false
2024-08-03 22:24:08 +02:00
func reset ( ) :
computers = 0
players = 0
2024-08-06 23:28:40 +02:00
is_running = false
frozen = 0
dead = 0
escaped = 0
player_escaped = false
is_beast = false
2024-08-02 20:13:42 +02:00
2024-08-05 22:35:50 +02:00
func save_setting ( setting_name , value ) :
settings [ setting_name ] = value
Save . saveJSON ( " user://settings.json " , settings )
func apply_settings ( ) :
2024-08-06 23:28:40 +02:00
players = Server . players_numbered . size ( ) - 1
is_running = true
2024-08-02 20:13:42 +02:00