extends CanvasLayer const DICE_SELECTION_SCENE := preload("res://stage/dice_selection/dice_selection.tscn") const DICE_THROW_SCENE := preload("res://stage/dice_throw/dice_throw.tscn") @onready var grid_selector: GridSelector = get_tree().get_first_node_in_group("grid_selector") func _ready() -> void: visible = false Network.current_player_changed.connect(func(): set_current_player() ) func _input(event: InputEvent) -> void: if not visible: return if event.is_action_pressed("left_click"): for button: Button in $PanelContainer/VBoxContainer.get_children(): if button.has_focus(): button.pressed.emit() break if event.is_action_pressed("menu") or event.is_action_pressed("right_click"): visible = false grid_selector.process_mode = Node.PROCESS_MODE_INHERIT func enable(): $PanelContainer2/VBoxContainer/move.text = "Move: " + str(Network.local_player.current_move_points) $PanelContainer2/VBoxContainer/attack.text = "Atk: " + str(Network.local_player.current_attack_points) $PanelContainer2/VBoxContainer/defend.text = "Def: " + str(Network.local_player.current_defend_points) $PanelContainer2/VBoxContainer/ability.text = "Ablty: " + str(Network.local_player.current_ability_points) set_current_player() if Network.is_my_turn(): $PanelContainer/VBoxContainer/Button.visible = true $PanelContainer/VBoxContainer/Button2.visible = true else: $PanelContainer/VBoxContainer/Button.visible = false $PanelContainer/VBoxContainer/Button2.visible = false visible = true $PanelContainer/VBoxContainer/Button.grab_focus() func set_current_player() -> void: if Network.is_my_turn(): $PanelContainer3/CurrentTurn.text = "Current Turn: Me" else: $PanelContainer3/CurrentTurn.text = "Current Turn: " + str(Network.current_player.id) func _on_button_pressed() -> void: visible = false var dice_selection := DICE_SELECTION_SCENE.instantiate() Game.overlay.add_child(dice_selection) dice_selection.dice_selected.connect(func(selected_dice: Array[DiceConfiguration]): dice_selection.queue_free() if selected_dice.size() > 0: var dice_throw := DICE_THROW_SCENE.instantiate() dice_throw.dice_configurations = selected_dice Game.overlay.add_child(dice_throw) dice_throw.throw_finished.connect(func(): dice_throw.queue_free() get_tree().current_scene.process_mode = PROCESS_MODE_INHERIT grid_selector.process_mode = PROCESS_MODE_INHERIT grid_selector.current_state = grid_selector.state_cube_placement ) else: get_tree().current_scene.process_mode = PROCESS_MODE_INHERIT grid_selector.process_mode = PROCESS_MODE_INHERIT ) get_tree().current_scene.process_mode = PROCESS_MODE_DISABLED func _on_button_2_pressed() -> void: visible = false Network.set_current_player(Network.player_order[ (Network.player_order.find(Network.current_player.id) + 1) % Network.player_order.size() ]) grid_selector.process_mode = Node.PROCESS_MODE_INHERIT