public void SetCards(List <Card> cards) { // TODO: frosty optimization: reuse existing cards foreach (Card card in cards) { CardButton cardButton = Instantiate(cardButtonPrefab, cardDisplay); cardButton.SetCard(card); currCardButtons.Add(cardButton); } }
/// <summary> /// Creates the card on the actual scene. /// </summary> public CardButton CreateCardButton(ICard card, Player player) { // Creates a new card asset from the prefab. GameObject newCard = Instantiate(cardPrefab, player.handTransform); // Sets the card info. newCard.transform.GetChild(0).GetComponent <Text>().text = card.GetCardName(); newCard.transform.GetChild(1).GetComponent <Text>().text = card.GetCardTooltip(); newCard.transform.GetChild(2).GetComponent <Image>().sprite = card.GetCardSprite(); newCard.transform.GetChild(3).GetComponentInChildren <Text>().text = card.ReturnHealth().ToString(); newCard.transform.GetChild(4).GetComponentInChildren <Text>().text = card.ReturnAttack().ToString(); // Associates the button with the card. CardButton newCardButton = newCard.GetComponent <CardButton>(); newCardButton.SetCard(card, player); return(newCardButton); }
public override void Exit() { base.Exit(); selectedCard.SetCard(null); }