added PlayCardButton; influences card selection
This commit is contained in:
@@ -16,7 +16,6 @@ func _ready() -> void:
|
||||
set_front_texture(CardManager.get_card_texture(-1))
|
||||
|
||||
func move_to(new_x_position: float) -> void:
|
||||
#self.position.x = new_x_position
|
||||
_get_new_tween().tween_property(self, "position:x", new_x_position, move_duration)
|
||||
|
||||
func select() -> void:
|
||||
|
||||
+20
-2
@@ -11,18 +11,22 @@ extends Node3D
|
||||
|
||||
## How many test cards to add
|
||||
@export_range(0, 20) var test_card_count: int = 0
|
||||
|
||||
@export var card_scene: PackedScene
|
||||
|
||||
@export_range(0, 20, 0.1, "radians_as_degrees") var card_angle: float
|
||||
|
||||
var _selected_card: PlayingCard = null
|
||||
|
||||
signal card_selected(card_id: int)
|
||||
signal card_played(card_id: int)
|
||||
|
||||
func _ready() -> void:
|
||||
_arrange_cards()
|
||||
for i in test_card_count:
|
||||
var card: PlayingCard = card_scene.instantiate()
|
||||
card.card_clicked.connect(_on_card_clicked)
|
||||
var test_details: Card = Card.new()
|
||||
test_details.card_id = 2
|
||||
card.card_details = test_details
|
||||
add_card(card)
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
|
||||
@@ -58,3 +62,17 @@ func _on_card_clicked(playing_card: PlayingCard) -> void:
|
||||
else:
|
||||
_selected_card = playing_card
|
||||
playing_card.select()
|
||||
|
||||
if _selected_card:
|
||||
card_selected.emit(_selected_card.card_details.card_id)
|
||||
else:
|
||||
card_selected.emit(-1)
|
||||
|
||||
func _on_play_card_button_pressed() -> void:
|
||||
if not _selected_card:
|
||||
return
|
||||
|
||||
card_played.emit(_selected_card.card_details.card_id)
|
||||
_selected_card.unselect()
|
||||
_selected_card = null
|
||||
card_selected.emit(-1)
|
||||
|
||||
@@ -26,7 +26,6 @@ script = ExtResource("1_feb5d")
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = -1591.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
@@ -142,13 +141,14 @@ size_flags_horizontal = 3
|
||||
layout_mode = 2
|
||||
text = "Send"
|
||||
|
||||
[node name="GameUI" type="Control" parent="HBoxContainer" node_paths=PackedStringArray("web_client", "start_game_button")]
|
||||
visible = false
|
||||
[node name="GameUI" type="Control" parent="HBoxContainer" node_paths=PackedStringArray("web_client", "start_game_button", "play_card_button")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_filter = 2
|
||||
script = ExtResource("3_feb5d")
|
||||
web_client = NodePath("../../WebClientTCP")
|
||||
start_game_button = NodePath("StartGameButton")
|
||||
play_card_button = NodePath("PlayCardButton")
|
||||
|
||||
[node name="StartGameButton" type="Button" parent="HBoxContainer/GameUI"]
|
||||
visible = false
|
||||
@@ -166,6 +166,21 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "Start Game!"
|
||||
|
||||
[node name="PlayCardButton" type="Button" parent="HBoxContainer/GameUI"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -4.0
|
||||
offset_top = -8.0
|
||||
offset_right = 4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
disabled = true
|
||||
text = "Play Card"
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="."]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="Node3D"]
|
||||
@@ -207,3 +222,5 @@ mesh = SubResource("BoxMesh_fc0e3")
|
||||
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ServerInputs/LeaveLobbyButton" to="HBoxContainer/ClientInterface" method="_on_disconnect_lobby_button_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/ClientInterface/MarginContainer/VBoxContainer/ChatContainer/SendMessageButton" to="HBoxContainer/ClientInterface" method="_on_send_message_button_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/GameUI/StartGameButton" to="HBoxContainer/GameUI" method="_on_start_game_button_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/GameUI/PlayCardButton" to="Node3D/PlayerHand" method="_on_play_card_button_pressed"]
|
||||
[connection signal="card_selected" from="Node3D/PlayerHand" to="HBoxContainer/GameUI" method="_on_player_hand_card_selected"]
|
||||
|
||||
@@ -3,6 +3,7 @@ extends Node
|
||||
|
||||
@export var web_client: WebClientTCP
|
||||
@export var start_game_button: Button
|
||||
@export var play_card_button: Button
|
||||
|
||||
var _is_host: bool = false
|
||||
var _current_player_count: int = 0
|
||||
@@ -50,3 +51,6 @@ func _on_web_client_tcp_client_joined_lobby(client_name: String, connected_clien
|
||||
|
||||
func _on_web_client_tcp_client_left_lobby(client_name: String, connected_client_names: Array[String]) -> void:
|
||||
_update_player_count(connected_client_names.size())
|
||||
|
||||
func _on_player_hand_card_selected(card_id: int) -> void:
|
||||
play_card_button.disabled = card_id == -1
|
||||
|
||||
Reference in New Issue
Block a user