fixed that turn rotation bug, added spectator cam, started work on new client mechanics

This commit is contained in:
Lexi Quinn 2023-06-13 00:59:02 +10:00
parent 8bc39d9d74
commit b7d709d726
17 changed files with 364 additions and 10 deletions

BIN
Assets/bad_pip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

34
Assets/bad_pip.png.import Normal file
View File

@ -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

BIN
Assets/good_pip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

View File

@ -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

BIN
Assets/medium_pip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -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

View File

@ -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")

View File

@ -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"]

View File

@ -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")

View File

@ -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:

View File

@ -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")

View File

@ -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

View File

@ -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:

View File

@ -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:

View File

@ -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():