client: added player hand and animation for added cards
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
extends Node
|
||||
|
||||
@export var full_deck: Dictionary[int, Card]
|
||||
@export var card_textures: Dictionary[int, Texture]
|
||||
@export var card_fallback_texture: Texture
|
||||
|
||||
func get_shuffled_cards(client_ids: Array[String], cards_to_pick: int) -> Dictionary: # Dictionary[String, Array[int]]
|
||||
var dict: Dictionary = {}
|
||||
@@ -21,3 +23,9 @@ func get_shuffled_cards(client_ids: Array[String], cards_to_pick: int) -> Dictio
|
||||
dict["trump"] = deck[card_index]
|
||||
|
||||
return dict
|
||||
|
||||
func get_card_texture(card_id: int) -> Texture:
|
||||
if card_textures.has(card_id):
|
||||
return card_textures[card_id]
|
||||
|
||||
return card_fallback_texture
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=63 format=3 uid="uid://hr727kw8y2hb"]
|
||||
[gd_scene load_steps=64 format=3 uid="uid://hr727kw8y2hb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c5yx2hpj6lifp" path="res://cards/card_manager.gd" id="1_de166"]
|
||||
[ext_resource type="Script" uid="uid://dx4cl2rk0a8a0" path="res://cards/card.gd" id="2_vmpa3"]
|
||||
[ext_resource type="Texture2D" uid="uid://i0wpcxpk7g2c" path="res://cards/textures/front_test.webp" id="3_hq606"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_hq606"]
|
||||
script = ExtResource("2_vmpa3")
|
||||
@@ -548,3 +549,4 @@ full_deck = Dictionary[int, ExtResource("2_vmpa3")]({
|
||||
58: SubResource("Resource_slqcy"),
|
||||
59: SubResource("Resource_rxi2e")
|
||||
})
|
||||
card_fallback_texture = ExtResource("3_hq606")
|
||||
|
||||
+21
-2
@@ -1,12 +1,31 @@
|
||||
class_name PlayingCard
|
||||
extends StaticBody3D
|
||||
extends Area3D
|
||||
|
||||
@export var card_mesh: MeshInstance3D
|
||||
@export var front_texture: Texture
|
||||
@export var move_duration: float = 0.2
|
||||
|
||||
var card_details: Card
|
||||
|
||||
signal card_clicked(playing_card: PlayingCard)
|
||||
|
||||
func _ready() -> void:
|
||||
set_front_texture(front_texture)
|
||||
if card_details:
|
||||
set_front_texture(CardManager.get_card_texture(card_details.card_id))
|
||||
else:
|
||||
set_front_texture(CardManager.get_card_texture(-1))
|
||||
|
||||
func move_to(new_x_position: float) -> void:
|
||||
#self.position.x = new_x_position
|
||||
var tween = create_tween()
|
||||
tween.set_trans(Tween.TRANS_BACK)
|
||||
tween.set_ease(Tween.EASE_OUT)
|
||||
tween.tween_property(self, "position:x", new_x_position, move_duration)
|
||||
|
||||
func set_front_texture(texture: Texture) -> void:
|
||||
card_mesh.get_surface_override_material(0).albedo_texture = front_texture
|
||||
|
||||
func _on_input_event(camera: Node, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) -> void:
|
||||
if event.is_action_pressed("left_mouse_button"):
|
||||
print("yahaha!")
|
||||
card_clicked.emit(self)
|
||||
|
||||
+16
-6
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://b55xpcxk7g5ph"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://b55xpcxk7g5ph"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c2odugkbbppxn" path="res://cards/playing_card.gd" id="1_t6o5d"]
|
||||
[ext_resource type="PackedScene" uid="uid://dxiv47be5dsll" path="res://cards/playing_card.glb" id="2_enav7"]
|
||||
@@ -14,17 +14,27 @@ albedo_color = Color(0, 0, 0, 1)
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_auvip"]
|
||||
albedo_texture = ExtResource("4_exvuq")
|
||||
|
||||
[node name="PlayingCard" type="StaticBody3D" node_paths=PackedStringArray("card_mesh")]
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_t6o5d"]
|
||||
size = Vector3(2.38, 3.7, 0.05)
|
||||
|
||||
[node name="PlayingCard" type="Area3D" node_paths=PackedStringArray("card_mesh")]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0)
|
||||
collision_layer = 8
|
||||
collision_mask = 0
|
||||
script = ExtResource("1_t6o5d")
|
||||
card_mesh = NodePath("PlayingCard/Cube")
|
||||
card_mesh = NodePath("Model/Cube")
|
||||
front_texture = ExtResource("3_jeoeb")
|
||||
|
||||
[node name="PlayingCard" parent="." instance=ExtResource("2_enav7")]
|
||||
[node name="Model" parent="." instance=ExtResource("2_enav7")]
|
||||
|
||||
[node name="Cube" parent="PlayingCard" index="0"]
|
||||
[node name="Cube" parent="Model" index="0"]
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_nwj5s")
|
||||
surface_material_override/1 = SubResource("StandardMaterial3D_hel13")
|
||||
surface_material_override/2 = SubResource("StandardMaterial3D_auvip")
|
||||
|
||||
[editable path="PlayingCard"]
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("BoxShape3D_t6o5d")
|
||||
|
||||
[connection signal="input_event" from="." to="." method="_on_input_event"]
|
||||
|
||||
[editable path="Model"]
|
||||
|
||||
Reference in New Issue
Block a user