184 lines
4.4 KiB
GDScript
184 lines
4.4 KiB
GDScript
extends Node
|
|
|
|
var SCENE
|
|
@onready var mapSelection = $mapSelectionButton
|
|
|
|
func _ready():
|
|
$playerNameBox.text = Global.playerName
|
|
add_mapSelection_options()
|
|
|
|
func add_mapSelection_options():
|
|
mapSelection.add_item("Alexi Village", 0)
|
|
mapSelection.add_item("Forest", 1)
|
|
mapSelection.add_item("Islands", 2)
|
|
mapSelection.add_item("Toy Factory", 3)
|
|
mapSelection.add_item("Toyland", 4)
|
|
mapSelection.select(4)
|
|
toyland()
|
|
|
|
func _process(delta):
|
|
pass
|
|
|
|
|
|
func _on_close_pressed():
|
|
self.queue_free()
|
|
|
|
|
|
func toyland():
|
|
$mapSelected.text = "Toyland"
|
|
Global.mapName = "Toyland"
|
|
SCENE = "res://scenes/toyland.tscn"
|
|
toggle_map_render("toyland")
|
|
|
|
func islands():
|
|
$mapSelected.text = "Islands"
|
|
Global.mapName = "Islands"
|
|
SCENE = "res://scenes/islands.tscn"
|
|
$Islands.visible = true
|
|
$Toyland.visible = false
|
|
toggle_map_render("islands")
|
|
|
|
func forest():
|
|
$mapSelected.text = "Forest"
|
|
Global.mapName = "Forrest"
|
|
SCENE = "res://scenes/forrest.tscn"
|
|
toggle_map_render("forest")
|
|
|
|
func toy_factory():
|
|
$mapSelected.text = "Toy Factory"
|
|
Global.mapName = "toyfactory"
|
|
SCENE = "res://scenes/toyfactory.tscn"
|
|
toggle_map_render("toyfactory")
|
|
|
|
func alexi_village():
|
|
$mapSelected.text = "Alexi Village"
|
|
Global.mapName = "alexi-village"
|
|
SCENE = "res://scenes/alexi-village.tscn"
|
|
toggle_map_render("alexi-village")
|
|
|
|
func _on_start_button_pressed():
|
|
var PORT = $portBox.text
|
|
var MAX_PLAYERS = $playerBox.text
|
|
var intPORT = int(PORT)
|
|
var intMAX = int(MAX_PLAYERS) - 1
|
|
if PORT:
|
|
prints("Player chose port:", intPORT)
|
|
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:
|
|
if Global.playerName == "":
|
|
$mapSelected.text = "PLAYER NAME CAN'T BE BLANK"
|
|
else:
|
|
print("Player chose player limit: ", intMAX)
|
|
Global.playerPleaseRespawn = true
|
|
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
|
|
else:
|
|
$mapSelected.text = "NO MAX PLAYERS SELECTED"
|
|
else:
|
|
$mapSelected.text = "NO MAP SELECTED"
|
|
else:
|
|
$mapSelected.text = "NO PORT SPECIFIED"
|
|
|
|
|
|
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()
|
|
|
|
|
|
func _on_player_name_box_text_changed(new_text):
|
|
Global.playerName = $playerNameBox.text
|
|
Global.save_data()
|
|
|
|
|
|
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
|
|
|
|
|
|
func _on_gamemode_deathmatch_button_down():
|
|
$GamemodeRunner.button_pressed = false
|
|
$GamemodeTTT.button_pressed = false
|
|
Global.gamemode = "Deathmatch"
|
|
|
|
|
|
func _on_gamemode_runner_button_down():
|
|
$GamemodeDeathmatch.button_pressed = false
|
|
$GamemodeTTT.button_pressed = false
|
|
Global.gamemode = "Runner"
|
|
|
|
|
|
func _on_gamemode_ttt_button_down():
|
|
$GamemodeRunner.button_pressed = false
|
|
$GamemodeDeathmatch.button_pressed = false
|
|
Global.gamemode = "TTT"
|
|
|
|
|
|
func _on_round_timer_text_changed(new_text):
|
|
var minutes = int(new_text)
|
|
var seconds = minutes * 60
|
|
Global.roundTimer = int(seconds)
|
|
|
|
|
|
func toggle_map_render(map):
|
|
$Toyland.visible = false
|
|
$Islands.visible = false
|
|
$Forest.visible = false
|
|
$Toyfactory.visible = false
|
|
$"Alexi-village".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
|
|
elif map == "alexi-village":
|
|
$"Alexi-village".visible = true
|
|
|
|
|
|
|
|
func _on_map_selection_button_item_selected(index):
|
|
match index:
|
|
0:
|
|
alexi_village()
|
|
1:
|
|
forest()
|
|
2:
|
|
islands()
|
|
3:
|
|
toy_factory()
|
|
4:
|
|
toyland()
|
|
_:
|
|
toyland()
|