This repository has been archived on 2026-05-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files

42 lines
1.3 KiB
GDScript
Raw Permalink Normal View History

2025-07-08 11:32:52 +02:00
class_name PlayingCard
extends Area3D
2025-07-08 11:32:52 +02:00
@export var card_mesh: MeshInstance3D
@export var front_texture: Texture
@export var move_duration: float = 0.2
2025-07-08 11:32:52 +02:00
var card_details: Card
signal card_clicked(playing_card: PlayingCard)
2025-07-14 22:00:59 +02:00
func _enter_tree() -> void:
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:
2025-07-08 16:48:41 +02:00
_get_new_tween().tween_property(self, "position:x", new_x_position, move_duration)
func select() -> void:
_get_new_tween().tween_property(self, "position:y", 0.13, move_duration)
2025-07-08 16:48:41 +02:00
func unselect() -> void:
_get_new_tween().tween_property(self, "position:y", 0.0, move_duration)
2025-07-08 11:32:52 +02:00
func set_front_texture(texture: Texture) -> void:
2025-07-14 22:00:59 +02:00
card_mesh.get_surface_override_material(0).albedo_texture = texture
func setup_card_details(card_id: int) -> void:
self.card_details = CardManager.full_deck[card_id]
2025-07-08 16:48:41 +02:00
func _get_new_tween() -> Tween:
var tween = create_tween()
tween.set_trans(Tween.TRANS_BACK)
tween.set_ease(Tween.EASE_OUT)
return tween
func _on_input_event(camera: Node, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) -> void:
2025-07-08 16:48:41 +02:00
if event.is_action_released("left_mouse_button"):
card_clicked.emit(self)