2024-03-30 01:43:38 +01:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
@onready var host_color_option = $PanelContainer/VBoxContainer/HBoxContainer/HostColorOption
|
|
|
|
|
@onready var ladybug_checkbutton = $PanelContainer/VBoxContainer/HBoxContainer2/LadybugCheckbutton
|
|
|
|
|
@onready var mosquito_checkbutton = $PanelContainer/VBoxContainer/HBoxContainer3/MosquitoCheckbutton
|
|
|
|
|
@onready var pillbug_checkbutton = $PanelContainer/VBoxContainer/HBoxContainer4/PillbugCheckbutton
|
|
|
|
|
@onready var start_game_button = $PanelContainer/VBoxContainer/StartGameButton
|
|
|
|
|
|
2024-03-30 01:52:04 +01:00
|
|
|
@onready var h_box_container = $PanelContainer/VBoxContainer/HBoxContainer
|
|
|
|
|
|
|
|
|
|
|
2024-03-30 01:43:38 +01:00
|
|
|
func _ready() -> void:
|
2024-03-30 01:52:04 +01:00
|
|
|
if GameData.is_hot_seat:
|
|
|
|
|
h_box_container.visible = false
|
|
|
|
|
|
2024-03-30 01:43:38 +01:00
|
|
|
if not multiplayer.is_server():
|
|
|
|
|
host_color_option.disabled = true
|
|
|
|
|
ladybug_checkbutton.disabled = true
|
|
|
|
|
mosquito_checkbutton.disabled = true
|
|
|
|
|
pillbug_checkbutton.disabled = true
|
|
|
|
|
start_game_button.disabled = true
|
|
|
|
|
|
|
|
|
|
@rpc("any_peer", "call_local")
|
|
|
|
|
func start_game() -> void:
|
|
|
|
|
visible = false
|
|
|
|
|
GameEvents.game_started.emit()
|
|
|
|
|
|
|
|
|
|
func _on_start_game_button_pressed():
|
|
|
|
|
GameData.use_ladybug_extension = ladybug_checkbutton.button_pressed
|
|
|
|
|
GameData.use_mosquito_extension = mosquito_checkbutton.button_pressed
|
|
|
|
|
GameData.use_pillbug_extension = pillbug_checkbutton.button_pressed
|
|
|
|
|
|
|
|
|
|
match host_color_option.get_selected_id():
|
|
|
|
|
0: #white
|
|
|
|
|
GameData.is_host_black = false
|
|
|
|
|
1: #black
|
|
|
|
|
GameData.is_host_black = true
|
|
|
|
|
2: #random
|
|
|
|
|
if randi_range(0, 1) == 0:
|
|
|
|
|
GameData.is_host_black = false
|
|
|
|
|
else:
|
|
|
|
|
GameData.is_host_black = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start_game.rpc()
|
|
|
|
|
|
|
|
|
|
@rpc("any_peer")
|
|
|
|
|
func update_button_state(button: NodePath, is_checked: bool) -> void:
|
|
|
|
|
get_node(button).button_pressed = is_checked
|
|
|
|
|
|
|
|
|
|
@rpc("any_peer")
|
|
|
|
|
func update_host_color_option(index: int) -> void:
|
|
|
|
|
host_color_option.select(index)
|
|
|
|
|
|
|
|
|
|
func _on_host_color_option_item_selected(index):
|
|
|
|
|
if multiplayer.is_server():
|
|
|
|
|
update_host_color_option.rpc(index)
|
|
|
|
|
|
|
|
|
|
func _on_ladybug_checkbutton_toggled(toggled_on):
|
|
|
|
|
if multiplayer.is_server():
|
|
|
|
|
update_button_state.rpc(ladybug_checkbutton.get_path(), toggled_on)
|
|
|
|
|
|
|
|
|
|
func _on_mosquito_checkbutton_toggled(toggled_on):
|
|
|
|
|
if multiplayer.is_server():
|
|
|
|
|
update_button_state.rpc(mosquito_checkbutton.get_path(), toggled_on)
|
|
|
|
|
|
|
|
|
|
func _on_pillbug_checkbutton_toggled(toggled_on):
|
|
|
|
|
if multiplayer.is_server():
|
|
|
|
|
update_button_state.rpc(pillbug_checkbutton.get_path(), toggled_on)
|