public void UpdateDeck() { gridField.QueueFreeChildren(); int index = 0; foreach (CardId id in GameData.Instance.Deck) { CardVisual visual = CardVisual.Instance(); gridField.AddChild(visual); visual.Connect(nameof(CardVisual.OnClick), this, nameof(OpenCard)); visual.ShowCard(id.Data()); index++; } }
public void ShowDeck() { CloseCard(); GameData.Instance.Deck = GameData.Instance.Deck.OrderBy(card => (int)card).ToList(); gridField.QueueFreeChildren(); int index = 0; foreach (CardId id in GameData.Instance.Deck) { CardVisual visual = CardVisual.Instance(); gridField.AddChild(visual); visual.Connect(nameof(CardVisual.OnClick), this, nameof(OpenCard)); visual.ShowCard(id.Data()); index++; } }
public override void _Ready() { leftCard = GetNode <CardVisual>(leftCardPath); middleCard = GetNode <CardVisual>(middleCardPath); rightCard = GetNode <CardVisual>(rightCardPath); foodField = GetNode <FoodVisual>(foodPath); bubbleText = GetNode <RichTextLabel>(bubblePath); buyButton = GetNode <Button>(buyButtonPath); buyButtonText = GetNode <RichTextLabel>(buyButtonPath + "/Text"); leftCard.Connect(nameof(CardVisual.OnClick), this, nameof(OpenCard), 0.InArray()); middleCard.Connect(nameof(CardVisual.OnClick), this, nameof(OpenCard), 1.InArray()); rightCard.Connect(nameof(CardVisual.OnClick), this, nameof(OpenCard), 2.InArray()); foodField.Connect(nameof(FoodVisual.OnClick), this, nameof(OpenFood)); buyButton.Connect("pressed", this, nameof(Buy)); CallDeferred(nameof(Init)); }