animate hands
This commit is contained in:
@@ -28,6 +28,7 @@ func _ready() -> void:
|
||||
drawpile.shuffle();
|
||||
for i in range(hand_size - get_held_cards().size()):
|
||||
draw_card()
|
||||
highlight_card(0)
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_pressed("play_card"):
|
||||
@@ -45,6 +46,7 @@ func play_card():
|
||||
# Auto-discard if out of ammo
|
||||
if card.get_ammo() <= 0:
|
||||
discard(false);
|
||||
var tween := create_tween()
|
||||
|
||||
|
||||
func discard(do_ability = true):
|
||||
@@ -54,11 +56,37 @@ func discard(do_ability = true):
|
||||
var card = cards[active_card_index]
|
||||
card.discard(get_node(world), get_node(player), do_ability)
|
||||
|
||||
discard_pile.append(card)
|
||||
card.get_parent().remove_child(card)
|
||||
if do_ability:
|
||||
var old_scale = card.scale
|
||||
var old_global_pos = card.global_position
|
||||
var old_modulate = card.modulate
|
||||
var tween = create_tween()
|
||||
tween.set_trans(Tween.TRANS_BOUNCE)
|
||||
tween.tween_property(card, "scale", Vector2(1.15, 1.15), 0.1)
|
||||
tween.tween_property(card, "global_position", Vector2(50.0, 50.0), 0.05).as_relative()
|
||||
tween.tween_property(card, "global_position", Vector2((1600)/2, (900)/2), 0.15)
|
||||
#tween.parallel()
|
||||
#tween.tween_property(card, "modulate", Color(1, 1, 1, 0) , 0.2)
|
||||
tween.tween_callback(Callable(card.get_parent(), "remove_child").bind(card))
|
||||
tween.parallel()
|
||||
tween.tween_callback(Callable(discard_pile.append).bind(card))
|
||||
tween.parallel()
|
||||
tween.tween_callback(draw_card)
|
||||
# This is why we create new objects instead of moving them around like this!! grr
|
||||
tween.parallel()
|
||||
tween.tween_property(card, "scale", old_scale, 0)
|
||||
tween.parallel()
|
||||
tween.tween_property(card, "global_position", old_global_pos, 0)
|
||||
tween.parallel()
|
||||
tween.tween_property(card, "modulate", old_modulate, 0)
|
||||
else:
|
||||
discard_pile.append(card)
|
||||
card.get_parent().remove_child(card)
|
||||
draw_card();
|
||||
|
||||
|
||||
#active_card_index = min(active_card_index, hand.size() - 1);
|
||||
draw_card();
|
||||
|
||||
|
||||
|
||||
func cycle_card(index_shift):
|
||||
@@ -119,8 +147,9 @@ func shuffle_deck():
|
||||
drawpile.append_array(discard_pile)
|
||||
discard_pile.clear();
|
||||
drawpile.shuffle();
|
||||
active_card_index = 0;
|
||||
# active_card_index = 0;
|
||||
get_node(player).shield_active = true;
|
||||
highlight_card(active_card_index)
|
||||
|
||||
func get_cards() -> Array:
|
||||
return get_card_container().get_children().map(func(c): return c.get_node_or_null("Card"))
|
||||
|
||||
Reference in New Issue
Block a user