Refactored to allow hotseat and multiplayer. TODO: Create interface class for webrtc/enet multiplayer

This commit is contained in:
Sch1nken 2024-03-22 01:37:05 +01:00
parent d688eaf9c6
commit 5fe8f22ccb
27 changed files with 798 additions and 135 deletions

View file

@ -1,33 +1,6 @@
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
@ -41,23 +14,9 @@ func _ready():
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)
lobby_code.text = GameData.lobby_code
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):