extends CanvasLayer @onready var insect_icons: HBoxContainer = $PanelContainer/VBoxContainer/InsectIcons @onready var lobby_code: Label = $PanelContainer/VBoxContainer/LobbyCode const INSECT_BUTTON = preload("res://UI/insect_button.tscn") const insect_resources = [ preload("res://Tile/Prefabs/Ant.tres"), preload("res://Tile/Prefabs/Bee.tres"), preload("res://Tile/Prefabs/Beetle.tres"), preload("res://Tile/Prefabs/Grasshopper.tres"), preload("res://Tile/Prefabs/Ladybug.tres"), preload("res://Tile/Prefabs/Mosquito.tres"), preload("res://Tile/Prefabs/Pillbug.tres"), preload("res://Tile/Prefabs/Spider.tres") ] var insect_data = { } func prepare_insect_data() -> void: var c: int = 65 for i in insect_resources: for k in 2: insect_data[String.chr(c)] = {"resource": i, "is_black": k%2 != 0} c = c + 1 @onready var start_game_button = $PanelContainer/VBoxContainer/StartGameButton func _on_connect() -> void: lobby_code.text = "Waiting for the host to start the game..." # Called when the node enters the scene tree for the first time. func _ready(): multiplayer.connected_to_server.connect(_on_connect) if not multiplayer.is_server(): return insect_icons.visible = true start_game_button.visible = true lobby_code.text = GameData.lobby_code prepare_insect_data() for c in GameData.lobby_code: var b = INSECT_BUTTON.instantiate() b.deactivated = true b.disabled = true b.disable_amount_display = true var data = insect_data[c] b.is_black = data.is_black b.insect_resource = data.resource insect_icons.add_child(b) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): pass func _on_button_pressed(): WSClient.stop() get_tree().change_scene_to_file("res://main_menu.tscn")