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")
|
||||
|
@ -73,7 +73,7 @@ func load_deck():
|
||||
for x in value.slice(1, value.size()):
|
||||
bonuses.append(int(x))
|
||||
card_instance.setup(key, int(value[0]), bonuses)
|
||||
card_instance.position = Vector2(-713, -17)
|
||||
card_instance.position = Vector2(-896, -274)
|
||||
card_instance.scale = Vector2(1.45, 1.45)
|
||||
card_array.append(card_instance)
|
||||
card_count += 1
|
||||
@ -224,7 +224,7 @@ func generate_card_from_buttons():
|
||||
return
|
||||
var card_instance = card_scene.instantiate()
|
||||
card_instance.setup(str($name_box.text), card[0], card.slice(1, card.size()))
|
||||
card_instance.position = Vector2(-713, -17)
|
||||
card_instance.position = Vector2(-896, -274)
|
||||
card_instance.scale = Vector2(1.45, 1.45)
|
||||
card_array.append(card_instance)
|
||||
card_count += 1
|
||||
|
@ -6,12 +6,30 @@ signal time_slots_selected
|
||||
enum difficulties {EASY, MEDIUM, HARD}
|
||||
|
||||
var icon_prefab = preload("res://Scenes/bonus_icon.tscn")
|
||||
var bad_pip_sprite = preload("res://Assets/bad_pip.png")
|
||||
var medium_pip_sprite = preload("res://Assets/medium_pip.png")
|
||||
var good_pip_sprite = preload("res://Assets/good_pip.png")
|
||||
var title = "New Task"
|
||||
var difficulty = difficulties.EASY
|
||||
var initial_stress = 0
|
||||
var turns_left = 4
|
||||
var time_slots = [true, true, false, true]
|
||||
var icon_list = []
|
||||
var medium_threshold := 5
|
||||
var good_threshold := 8
|
||||
var satisfaction := 1
|
||||
@export var pip_sprites: Array[TextureRect] = []
|
||||
|
||||
|
||||
func _ready():
|
||||
pip_sprites.append($front/pip2)
|
||||
pip_sprites.append($front/pip3)
|
||||
pip_sprites.append($front/pip4)
|
||||
pip_sprites.append($front/pip5)
|
||||
pip_sprites.append($front/pip6)
|
||||
pip_sprites.append($front/pip7)
|
||||
pip_sprites.append($front/pip8)
|
||||
pip_sprites.append($front/pip9)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
@ -19,11 +37,22 @@ func _process(delta):
|
||||
slide(delta)
|
||||
|
||||
|
||||
func setup(_title, _initial_stress, _time_slots, _services):
|
||||
func setup(_title, _initial_stress, _time_slots, _services, _medium, _good):
|
||||
if _title != "":
|
||||
title = _title
|
||||
initial_stress = _initial_stress
|
||||
time_slots = _time_slots
|
||||
medium_threshold = _medium
|
||||
good_threshold = _good
|
||||
for x in pip_sprites.size():
|
||||
if x < 2:
|
||||
continue
|
||||
if x >= good_threshold:
|
||||
pip_sprites[x - 2].texture = good_pip_sprite
|
||||
if x < good_threshold:
|
||||
pip_sprites[x - 2].texture = medium_pip_sprite
|
||||
if x < medium_threshold:
|
||||
pip_sprites[x - 2].texture = bad_pip_sprite
|
||||
if time_slots[0] == true:
|
||||
$"Control/1turn".visible = true
|
||||
if time_slots[1] == true:
|
||||
|
@ -31,6 +31,7 @@ func _ready():
|
||||
symbol_count_labels.append($"starcount")
|
||||
symbol_count_labels.append($"chaincount")
|
||||
symbol_count_labels.append($"gustcount")
|
||||
$Control/Card.turn_front()
|
||||
|
||||
load_deck()
|
||||
|
||||
@ -75,6 +76,7 @@ func load_deck():
|
||||
card_instance.setup(key, int(value[0]), bool_array, int_array)
|
||||
card_instance.position = Vector2(-927, -176)
|
||||
card_instance.scale = Vector2(1.288, 1.288)
|
||||
card_instance.turn_front()
|
||||
card_array.append(card_instance)
|
||||
card_count += 1
|
||||
if card_array.size() > 1:
|
||||
@ -177,6 +179,7 @@ func generate_card_from_buttons():
|
||||
card_instance.setup(str($Control/LineEdit.text), card[0], card.slice(1, 5), card.slice(5, card.size()))
|
||||
card_instance.position = Vector2(-926, -176)
|
||||
card_instance.scale = Vector2(1.288, 1.288)
|
||||
card_instance.turn_front()
|
||||
card_array.append(card_instance)
|
||||
card_count += 1
|
||||
if card_array.size() > 1:
|
||||
|
@ -120,6 +120,7 @@ func add_player(id: int, username: String, type: PlayerType) -> void:
|
||||
board.slots[1].clicked.connect(controller.select_workspace)
|
||||
board.slots[2].clicked.connect(controller.select_workspace)
|
||||
board.slots[3].clicked.connect(controller.select_workspace)
|
||||
board.poor_deck.clicked.connect(controller.on_poor_discard_deck_clicked)
|
||||
board.name = "board " + str(player_boards.size())
|
||||
player_boards.append(board)
|
||||
players.append(controller)
|
||||
@ -146,6 +147,8 @@ func ready_player(id):
|
||||
if round_number == 0:
|
||||
rpc("start_game")
|
||||
else:
|
||||
for player in players:
|
||||
player.ready_button_pressed.disconnect(ready_player)
|
||||
rpc("start_round")
|
||||
|
||||
|
||||
@ -183,6 +186,8 @@ func start_turn():
|
||||
turn_number += 1
|
||||
for x in players.size():
|
||||
#players[x].rpc("start_turn")
|
||||
for other_player in players:
|
||||
other_player.spectate_player(players[x].get_path())
|
||||
players[x].start_turn()
|
||||
await players[x].turn_finished
|
||||
if is_multiplayer_authority():
|
||||
|
Reference in New Issue
Block a user