2023-02-09 13:10:25 -07:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
var SCENE
|
|
|
|
|
|
|
|
func _ready():
|
2023-02-25 15:21:18 -07:00
|
|
|
$playerNameBox.text = Global.playerName
|
2023-02-09 13:10:25 -07:00
|
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
func _on_close_pressed():
|
|
|
|
self.queue_free()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_playground_pressed():
|
2023-02-22 21:31:22 -07:00
|
|
|
$mapSelected.text = "Toyland"
|
2023-03-16 22:59:05 -06:00
|
|
|
Global.mapName = "Toyland"
|
2023-02-22 21:31:22 -07:00
|
|
|
SCENE = "res://scenes/toyland.tscn"
|
2023-05-11 11:09:33 -06:00
|
|
|
toggle_map_render("toyland")
|
2023-02-09 13:10:25 -07:00
|
|
|
|
2023-03-18 01:11:03 -06:00
|
|
|
func _on_islands_pressed():
|
|
|
|
$mapSelected.text = "Islands"
|
|
|
|
Global.mapName = "Islands"
|
|
|
|
SCENE = "res://scenes/islands.tscn"
|
2023-03-23 10:15:36 -06:00
|
|
|
$Islands.visible = true
|
|
|
|
$Toyland.visible = false
|
2023-05-11 11:09:33 -06:00
|
|
|
toggle_map_render("islands")
|
2023-02-09 13:10:25 -07:00
|
|
|
|
2023-04-11 13:31:11 -06:00
|
|
|
func _on_forrest_button_pressed():
|
2023-04-11 22:37:15 -06:00
|
|
|
$mapSelected.text = "Forest"
|
2023-04-11 13:31:11 -06:00
|
|
|
Global.mapName = "Forrest"
|
|
|
|
SCENE = "res://scenes/forrest.tscn"
|
2023-05-11 11:09:33 -06:00
|
|
|
toggle_map_render("forest")
|
|
|
|
|
|
|
|
func _on_toyfactory_button_pressed():
|
|
|
|
$mapSelected.text = "Toy Factory"
|
|
|
|
Global.mapName = "toyfactory"
|
|
|
|
SCENE = "res://scenes/toyfactory.tscn"
|
|
|
|
toggle_map_render("toyfactory")
|
2023-04-11 13:31:11 -06:00
|
|
|
|
2023-02-09 13:10:25 -07:00
|
|
|
func _on_start_button_pressed():
|
|
|
|
var PORT = $portBox.text
|
2023-02-14 11:40:02 -07:00
|
|
|
var MAX_PLAYERS = $playerBox.text
|
2023-02-09 13:10:25 -07:00
|
|
|
var intPORT = int(PORT)
|
2023-02-14 11:40:02 -07:00
|
|
|
var intMAX = int(MAX_PLAYERS)
|
2023-02-09 13:10:25 -07:00
|
|
|
if PORT:
|
2023-02-14 11:40:02 -07:00
|
|
|
prints("Player chose port:", intPORT)
|
2023-02-23 10:19:37 -07:00
|
|
|
if intPORT < 1024:
|
|
|
|
$mapSelected.text = "PORT CANNOT BE BELOW 1024"
|
|
|
|
else:
|
|
|
|
if SCENE:
|
|
|
|
print("Player chose map: ", SCENE)
|
|
|
|
if MAX_PLAYERS:
|
|
|
|
if intMAX < 1:
|
|
|
|
$mapSelected.text = "MAX PLAYERS CANNOT BE NEGATIVE"
|
|
|
|
elif intMAX > 4095:
|
|
|
|
$mapSelected.text = "MAX PLAYERS CANNOT BE ABOVE 4095"
|
|
|
|
else:
|
2023-03-09 13:26:09 -07:00
|
|
|
if Global.playerName == "":
|
|
|
|
$mapSelected.text = "PLAYER NAME CAN'T BE BLANK"
|
|
|
|
else:
|
|
|
|
print("Player chose player limit: ", intMAX)
|
2023-05-04 11:29:32 -06:00
|
|
|
Global.playerPleaseRespawn = true
|
2023-03-09 13:26:09 -07:00
|
|
|
Networking.create_server(intPORT, intMAX)
|
|
|
|
Networking.load_map(SCENE)
|
|
|
|
Networking.add_player_node(1)
|
|
|
|
Global.connectedPlayers += [Global.playerName]
|
|
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
|
|
|
if $normalRespawn.button_pressed == true:
|
|
|
|
Global.respawnTimeModifier = 1.0
|
|
|
|
elif $shortRespawn.button_pressed == true:
|
|
|
|
Global.respawnTimeModifier = 2
|
|
|
|
elif $longRespawn.button_pressed == true:
|
|
|
|
Global.respawnTimeModifier = 0.5
|
2023-02-14 11:40:02 -07:00
|
|
|
else:
|
2023-02-23 10:19:37 -07:00
|
|
|
$mapSelected.text = "NO MAX PLAYERS SELECTED"
|
2023-02-14 11:40:02 -07:00
|
|
|
else:
|
2023-02-23 10:19:37 -07:00
|
|
|
$mapSelected.text = "NO MAP SELECTED"
|
2023-02-09 13:10:25 -07:00
|
|
|
else:
|
|
|
|
$mapSelected.text = "NO PORT SPECIFIED"
|
|
|
|
|
2023-02-15 23:41:14 -07:00
|
|
|
|
2023-02-24 23:49:49 -07:00
|
|
|
func _on_join_button_pressed():
|
|
|
|
var scene_trs =load("res://scenes/multiplayer.tscn")
|
|
|
|
var scene=scene_trs.instantiate()
|
|
|
|
get_parent().add_child(scene)
|
|
|
|
self.queue_free()
|
2023-02-25 15:21:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
func _on_player_name_box_text_changed(new_text):
|
2023-03-01 20:21:34 -07:00
|
|
|
Global.playerName = $playerNameBox.text
|
2023-03-17 00:20:54 -06:00
|
|
|
Global.save_data()
|
2023-03-05 20:39:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
func _on_short_respawn_button_down():
|
|
|
|
$normalRespawn.button_pressed = false
|
|
|
|
$longRespawn.button_pressed = false
|
|
|
|
|
|
|
|
|
|
|
|
func _on_normal_respawn_button_down():
|
|
|
|
$shortRespawn.button_pressed = false
|
|
|
|
$longRespawn.button_pressed = false
|
|
|
|
|
|
|
|
|
|
|
|
func _on_long_respawn_button_down():
|
|
|
|
$shortRespawn.button_pressed = false
|
|
|
|
$normalRespawn.button_pressed = false
|
2023-03-16 13:37:17 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _on_gamemode_deathmatch_button_down():
|
|
|
|
$GamemodeRunner.button_pressed = false
|
2023-03-28 22:32:49 -06:00
|
|
|
$GamemodeTTT.button_pressed = false
|
2023-03-16 13:37:17 -06:00
|
|
|
Global.gamemode = "Deathmatch"
|
|
|
|
|
|
|
|
|
|
|
|
func _on_gamemode_runner_button_down():
|
|
|
|
$GamemodeDeathmatch.button_pressed = false
|
2023-03-28 22:32:49 -06:00
|
|
|
$GamemodeTTT.button_pressed = false
|
2023-03-16 13:37:17 -06:00
|
|
|
Global.gamemode = "Runner"
|
2023-03-19 15:06:11 -06:00
|
|
|
|
|
|
|
|
2023-03-28 22:32:49 -06:00
|
|
|
func _on_gamemode_ttt_button_down():
|
|
|
|
$GamemodeRunner.button_pressed = false
|
|
|
|
$GamemodeDeathmatch.button_pressed = false
|
|
|
|
Global.gamemode = "TTT"
|
|
|
|
|
|
|
|
|
2023-03-19 15:06:11 -06:00
|
|
|
func _on_round_timer_text_changed(new_text):
|
2023-05-05 13:26:24 -06:00
|
|
|
var minutes = int(new_text)
|
|
|
|
var seconds = minutes * 60
|
|
|
|
Global.roundTimer = int(seconds)
|
2023-05-04 11:29:32 -06:00
|
|
|
|
|
|
|
|
2023-05-11 11:09:33 -06:00
|
|
|
func toggle_map_render(map):
|
|
|
|
$Toyland.visible = false
|
|
|
|
$Islands.visible = false
|
|
|
|
$Forest.visible = false
|
|
|
|
$Toyfactory.visible = false
|
|
|
|
if map == "toyland":
|
|
|
|
$Toyland.visible = true
|
|
|
|
elif map == "islands":
|
|
|
|
$Islands.visible = true
|
|
|
|
elif map == "forest":
|
|
|
|
$Forest.visible = true
|
|
|
|
elif map == "toyfactory":
|
|
|
|
$Toyfactory.visible = true
|