31 lines
915 B
GDScript
31 lines
915 B
GDScript
extends Panel
|
|
|
|
@export var player: NodePath
|
|
@export var world: NodePath
|
|
|
|
var dash_card_scene = preload("res://Cards/DashCard.tscn")
|
|
var active_card_index = 0
|
|
|
|
func _ready() -> void:
|
|
var actual_dash_card = dash_card_scene.instantiate()
|
|
$MarginContainer/HBoxContainer.add_child(actual_dash_card)
|
|
|
|
func _process(delta):
|
|
if Input.is_action_pressed("play_card"):
|
|
play_card()
|
|
if Input.is_action_just_pressed("cycle_card_left"):
|
|
#player.action_state = ActionState.Cycling;
|
|
active_card_index += -1
|
|
elif Input.is_action_just_pressed("cycle_card_right"):
|
|
#player.action_state = ActionState.Cycling;
|
|
#player.cycle_card(1);
|
|
active_card_index += 1
|
|
|
|
|
|
func play_card():
|
|
var cards = $MarginContainer/HBoxContainer.get_children();
|
|
if active_card_index >= 0 and active_card_index < cards.size():
|
|
var card = cards[active_card_index]
|
|
card.activate(get_node(world), get_node(player));
|
|
print(active_card_index)
|