19 lines
498 B
GDScript
19 lines
498 B
GDScript
class_name CardStack
|
|||
|
|
extends Node3D
|
||
|
|
|
||
|
|
var _card_height: float = 0.06
|
||
|
|
|
||
|
|
func add_card(card: PlayingCard) -> void:
|
||
|
|
var height = self.get_child_count() * _card_height
|
||
|
|
self.add_child(card)
|
||
|
|
card.translate(Vector3(0, height, 0))
|
||
|
|
|
||
|
|
func add_card_by_id(card_id: int) -> void:
|
||
|
|
var playing_card: PlayingCard = PlayingCard.new()
|
||
|
|
playing_card.setup_card_details(card_id)
|
||
|
|
add_card(playing_card)
|
||
|
|
|
||
|
|
func purge_cards() -> void:
|
||
|
|
while get_child_count() > 0:
|
||
|
|
remove_child(get_children()[get_child_count() - 1])
|