diff --git a/Assets/bad_pip.png b/Assets/bad_pip.png new file mode 100644 index 0000000..12b494b Binary files /dev/null and b/Assets/bad_pip.png differ diff --git a/Assets/bad_pip.png.import b/Assets/bad_pip.png.import new file mode 100644 index 0000000..c874d9f --- /dev/null +++ b/Assets/bad_pip.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qhoam0u12smd" +path="res://.godot/imported/bad_pip.png-0a3c6e3f6c987e617516e5f1a412bb79.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/bad_pip.png" +dest_files=["res://.godot/imported/bad_pip.png-0a3c6e3f6c987e617516e5f1a412bb79.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Assets/good_pip.png b/Assets/good_pip.png new file mode 100644 index 0000000..51f3b10 Binary files /dev/null and b/Assets/good_pip.png differ diff --git a/Assets/good_pip.png.import b/Assets/good_pip.png.import new file mode 100644 index 0000000..ea5800f --- /dev/null +++ b/Assets/good_pip.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bo6ohnvl8b64o" +path="res://.godot/imported/good_pip.png-08b22d0d1089e699e9f8dbaf4bff5a23.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/good_pip.png" +dest_files=["res://.godot/imported/good_pip.png-08b22d0d1089e699e9f8dbaf4bff5a23.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Assets/medium_pip.png b/Assets/medium_pip.png new file mode 100644 index 0000000..d916022 Binary files /dev/null and b/Assets/medium_pip.png differ diff --git a/Assets/medium_pip.png.import b/Assets/medium_pip.png.import new file mode 100644 index 0000000..ad3ebe8 --- /dev/null +++ b/Assets/medium_pip.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dsqwv4h4oynxu" +path="res://.godot/imported/medium_pip.png-052d2eac20892030bedc015579b90a41.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/medium_pip.png" +dest_files=["res://.godot/imported/medium_pip.png-052d2eac20892030bedc015579b90a41.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Assets/task.png b/Assets/task.png index 2426391..2d7faa2 100644 Binary files a/Assets/task.png and b/Assets/task.png differ diff --git a/Scenes/client_card.tscn b/Scenes/client_card.tscn index d51ef8c..df4dcd7 100644 --- a/Scenes/client_card.tscn +++ b/Scenes/client_card.tscn @@ -1,11 +1,14 @@ -[gd_scene load_steps=10 format=3 uid="uid://c7j6lwbwgbosr"] +[gd_scene load_steps=13 format=3 uid="uid://c7j6lwbwgbosr"] [ext_resource type="Script" path="res://Scripts/client.gd" id="1_bvmvn"] [ext_resource type="Texture2D" uid="uid://dpu7jjppeja2v" path="res://Assets/task.png" id="2_k2tqp"] [ext_resource type="Texture2D" uid="uid://de0gq6h0onwex" path="res://Assets/slice.png" id="3_pxlet"] [ext_resource type="Texture2D" uid="uid://b72amudxuxo8n" path="res://Assets/hard.png" id="4_8gylx"] +[ext_resource type="Texture2D" uid="uid://qhoam0u12smd" path="res://Assets/bad_pip.png" id="4_h1e7v"] [ext_resource type="Texture2D" uid="uid://bj07g3riacndc" path="res://Assets/back.png" id="4_tye4g"] +[ext_resource type="Texture2D" uid="uid://dsqwv4h4oynxu" path="res://Assets/medium_pip.png" id="5_2itu6"] [ext_resource type="Texture2D" uid="uid://ws1ghxt16a54" path="res://Assets/hardest.png" id="5_hl5js"] +[ext_resource type="Texture2D" uid="uid://bo6ohnvl8b64o" path="res://Assets/good_pip.png" id="6_6ba24"] [sub_resource type="LabelSettings" id="LabelSettings_xciys"] font_size = 25 @@ -96,6 +99,70 @@ offset_right = 394.0 offset_bottom = 26.0 text = "0" +[node name="pip2" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 149.0 +offset_top = 209.0 +offset_right = 169.0 +offset_bottom = 223.0 +texture = ExtResource("4_h1e7v") + +[node name="pip3" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 169.0 +offset_top = 209.0 +offset_right = 189.0 +offset_bottom = 223.0 +texture = ExtResource("4_h1e7v") + +[node name="pip4" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 189.0 +offset_top = 209.0 +offset_right = 209.0 +offset_bottom = 223.0 +texture = ExtResource("4_h1e7v") + +[node name="pip5" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 209.0 +offset_top = 209.0 +offset_right = 229.0 +offset_bottom = 223.0 +texture = ExtResource("5_2itu6") + +[node name="pip6" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 229.0 +offset_top = 209.0 +offset_right = 249.0 +offset_bottom = 223.0 +texture = ExtResource("5_2itu6") + +[node name="pip7" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 249.0 +offset_top = 209.0 +offset_right = 269.0 +offset_bottom = 223.0 +texture = ExtResource("5_2itu6") + +[node name="pip8" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 269.0 +offset_top = 209.0 +offset_right = 289.0 +offset_bottom = 223.0 +texture = ExtResource("6_6ba24") + +[node name="pip9" type="TextureRect" parent="front"] +layout_mode = 0 +offset_left = 289.0 +offset_top = 209.0 +offset_right = 309.0 +offset_bottom = 223.0 +texture = ExtResource("6_6ba24") + [node name="easy" type="Node2D" parent="."] visible = false diff --git a/Scenes/client_editor.tscn b/Scenes/client_editor.tscn index c54d468..bdc7fad 100644 --- a/Scenes/client_editor.tscn +++ b/Scenes/client_editor.tscn @@ -49,6 +49,7 @@ region = Rect2(288, 0, 32, 32) script = ExtResource("1_lgqnu") [node name="main_camera" type="Camera2D" parent="."] +zoom = Vector2(0.6, 0.6) [node name="background_image" type="Sprite2D" parent="."] texture = ExtResource("2_58m7y") diff --git a/Scenes/human_player.tscn b/Scenes/human_player.tscn index 498f07d..49f8d4a 100644 --- a/Scenes/human_player.tscn +++ b/Scenes/human_player.tscn @@ -3,9 +3,10 @@ [ext_resource type="Script" path="res://Scripts/PlayerStateMachine/human_controller.gd" id="1_4thxs"] [ext_resource type="Theme" uid="uid://d26ldkm1br1bo" path="res://UI_Theme.tres" id="2_ja0q8"] -[node name="HumanPlayer" type="Node2D" node_paths=PackedStringArray("hand_position")] +[node name="HumanPlayer" type="Node2D" node_paths=PackedStringArray("hand_position", "player_cam")] script = ExtResource("1_4thxs") hand_position = NodePath("Node2D") +player_cam = NodePath("Camera2D") [node name="Node2D" type="Node2D" parent="."] @@ -139,6 +140,87 @@ text = "$50" horizontal_alignment = 2 vertical_alignment = 1 +[node name="top_line" type="HBoxContainer" parent="CanvasLayer/UI"] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_right = 1.0 +offset_top = 30.0 +offset_bottom = 56.0 +grow_horizontal = 2 + +[node name="MarginContainer2" type="MarginContainer" parent="CanvasLayer/UI/top_line"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/margin_left = 30 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_bottom = 10 + +[node name="ColorRect2" type="ColorRect" parent="CanvasLayer/UI/top_line/MarginContainer2"] +layout_mode = 2 +size_flags_horizontal = 3 +color = Color(0.85098, 0, 1, 1) + +[node name="Label" type="Label" parent="CanvasLayer/UI/top_line"] +layout_mode = 2 +theme_override_colors/font_color = Color(0.94902, 0, 1, 1) +text = "sowelijanpona" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/UI/top_line"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 30 +theme_override_constants/margin_bottom = 10 + +[node name="ColorRect" type="ColorRect" parent="CanvasLayer/UI/top_line/MarginContainer"] +layout_mode = 2 +color = Color(0.85098, 0, 1, 1) + +[node name="left_line" type="ColorRect" parent="CanvasLayer/UI"] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_bottom = 1.0 +offset_left = 30.0 +offset_top = 40.0 +offset_right = 36.0 +offset_bottom = -40.0 +grow_vertical = 2 +color = Color(0.85098, 0, 1, 1) + +[node name="right_line" type="ColorRect" parent="CanvasLayer/UI"] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_left = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -36.0 +offset_top = 40.0 +offset_right = -30.0 +offset_bottom = -46.0 +grow_horizontal = 0 +grow_vertical = 2 +color = Color(0.85098, 0, 1, 1) + +[node name="bottom_line" type="ColorRect" parent="CanvasLayer/UI"] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 30.0 +offset_top = -46.0 +offset_right = -30.0 +offset_bottom = -40.0 +grow_horizontal = 2 +grow_vertical = 0 +color = Color(0.85098, 0, 1, 1) + [connection signal="pressed" from="CanvasLayer/UI/Confirm" to="." method="_on_confirm_pressed"] [connection signal="pressed" from="CanvasLayer/UI/HBoxContainer/LobbyReadyButton" to="." method="_on_lobby_ready_button_pressed"] [connection signal="text_submitted" from="CanvasLayer/UI/VBoxContainer/LineEdit" to="." method="_on_line_edit_text_submitted"] diff --git a/Scenes/worker_editor.tscn b/Scenes/worker_editor.tscn index 77903b1..c4d8bc0 100644 --- a/Scenes/worker_editor.tscn +++ b/Scenes/worker_editor.tscn @@ -8,6 +8,7 @@ script = ExtResource("1_vn0ae") [node name="main_camera" type="Camera2D" parent="."] +zoom = Vector2(0.6, 0.6) [node name="background_image" type="Sprite2D" parent="."] texture = ExtResource("2_1kq1c") diff --git a/Scripts/PlayerStateMachine/human_controller.gd b/Scripts/PlayerStateMachine/human_controller.gd index 03ab3c2..f8155da 100644 --- a/Scripts/PlayerStateMachine/human_controller.gd +++ b/Scripts/PlayerStateMachine/human_controller.gd @@ -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: diff --git a/Scripts/PlayerStateMachine/player_controller.gd b/Scripts/PlayerStateMachine/player_controller.gd index e6dd9d8..22f4af0 100644 --- a/Scripts/PlayerStateMachine/player_controller.gd +++ b/Scripts/PlayerStateMachine/player_controller.gd @@ -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") diff --git a/Scripts/card_crafter.gd b/Scripts/card_crafter.gd index f8790be..69069a7 100644 --- a/Scripts/card_crafter.gd +++ b/Scripts/card_crafter.gd @@ -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 diff --git a/Scripts/client.gd b/Scripts/client.gd index e6d03a4..ba4a598 100644 --- a/Scripts/client.gd +++ b/Scripts/client.gd @@ -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: diff --git a/Scripts/client_card_crafter.gd b/Scripts/client_card_crafter.gd index 8125eef..d9115d0 100644 --- a/Scripts/client_card_crafter.gd +++ b/Scripts/client_card_crafter.gd @@ -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: diff --git a/Scripts/game.gd b/Scripts/game.gd index 7740b5b..bb1d8ee 100644 --- a/Scripts/game.gd +++ b/Scripts/game.gd @@ -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():