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
magician/cards/playing_card.gd
T

39 lines
1.2 KiB
GDScript
Raw 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-08 11:32:52 +02:00
func _ready() -> 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.36, move_duration)
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:
card_mesh.get_surface_override_material(0).albedo_texture = front_texture
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)