fixed that turn rotation bug, added spectator cam, started work on new client mechanics
This commit is contained in:
@ -8,7 +8,14 @@ signal chat_message_submitted(String)
|
||||
@onready var ready_label = $CanvasLayer/UI/HBoxContainer/LobbyReadyLabel
|
||||
@onready var canvas = $CanvasLayer
|
||||
@onready var chat_box = $CanvasLayer/UI/VBoxContainer/RichTextLabel
|
||||
var game_started = false
|
||||
@onready var cam_top = $CanvasLayer/UI/top_line
|
||||
@onready var cam_bottom = $CanvasLayer/UI/bottom_line
|
||||
@onready var cam_left = $CanvasLayer/UI/left_line
|
||||
@onready var cam_right = $CanvasLayer/UI/right_line
|
||||
@onready var cam_name = $CanvasLayer/UI/top_line/Label
|
||||
#So this is fucked but basically starting the first round requires hitting
|
||||
#the ready_self function exactly twice.
|
||||
var game_started = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@ -18,6 +25,22 @@ func _ready() -> void:
|
||||
$Camera2D.make_current()
|
||||
|
||||
|
||||
func spectate_player(player_path):
|
||||
var player = get_node(player_path) as PlayerController
|
||||
if player.player_info["username"] == player_info["username"]:
|
||||
cam_top.visible = false
|
||||
cam_left.visible = false
|
||||
cam_right.visible = false
|
||||
cam_bottom.visible = false
|
||||
else:
|
||||
cam_top.visible = true
|
||||
cam_left.visible = true
|
||||
cam_right.visible = true
|
||||
cam_bottom.visible = true
|
||||
cam_name.text = player.player_info["username"]
|
||||
player.player_cam.make_current()
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func ready_self():
|
||||
ready_button_pressed.emit(player_info["id"])
|
||||
@ -31,9 +54,17 @@ func update_ready_label(readied_players, total_players):
|
||||
|
||||
|
||||
func _on_lobby_ready_button_pressed() -> void:
|
||||
rpc("ready_self")
|
||||
ready_button.visible = false
|
||||
rpc("end_turn")
|
||||
if game_started < 2:
|
||||
rpc("ready_self")
|
||||
game_started += 1
|
||||
else:
|
||||
rpc("end_turn")
|
||||
|
||||
|
||||
func on_poor_discard_deck_clicked():
|
||||
super()
|
||||
ready_button.visible = true
|
||||
|
||||
|
||||
func add_chat_line(line: String) -> void:
|
||||
|
@ -9,6 +9,7 @@ signal round_finished
|
||||
var player_info
|
||||
@export var hand_position: Node2D
|
||||
@export var client_position: Vector2
|
||||
@export var player_cam: Camera2D
|
||||
var hand = []
|
||||
var draft_picked = []
|
||||
var draft_pick_amount = 0
|
||||
@ -30,20 +31,52 @@ func draft(cards, pick):
|
||||
|
||||
|
||||
func select_card(card):
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
if not draft_picked.has(card) and draft_picked.size() < draft_pick_amount:
|
||||
draft_picked.append(card)
|
||||
rpc("networked_select_card", true, card.get_path())
|
||||
card.slide_to_position(card.position.x, card.position.y - 50.0, 0.0, 0.1)
|
||||
elif draft_picked.has(card):
|
||||
draft_picked.remove_at(draft_picked.find(card))
|
||||
rpc("networked_select_card", false, card.get_path())
|
||||
card.slide_to_position(card.position.x, card.position.y + 50.0, 0.0, 0.1)
|
||||
|
||||
|
||||
@rpc("reliable")
|
||||
func networked_select_card(add, card_path):
|
||||
if add:
|
||||
draft_picked.append(get_node(card_path))
|
||||
else:
|
||||
draft_picked.remove_at(draft_picked.find(get_node(card_path)))
|
||||
|
||||
|
||||
func select_workspace(workspace):
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
if current_client == null:
|
||||
return
|
||||
workspace.add_client(current_client)
|
||||
rpc("networked_select_workspace", workspace.get_path(), current_client.get_path())
|
||||
#workspace.add_client(current_client)
|
||||
current_client = null
|
||||
rpc("end_turn")
|
||||
#rpc("end_turn")
|
||||
|
||||
|
||||
func on_poor_discard_deck_clicked():
|
||||
if not is_multiplayer_authority():
|
||||
return
|
||||
rpc("turn_away_client")
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func turn_away_client():
|
||||
board.poor_deck.place(current_client)
|
||||
current_client = null
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
func networked_select_workspace(workspace_path, current_client_path):
|
||||
get_node(workspace_path).add_client(get_node(current_client_path))
|
||||
|
||||
|
||||
@rpc("call_local", "reliable")
|
||||
|
Reference in New Issue
Block a user