/** Create a new card, set its attributes, and return its transform */ public CardVisual CreateCard(CardData cardData, int cardID, bool faceUp) { if (m_cardPrefab == null) { Debug.LogError("Card Visual prefab not set"); } // Create the new card GameObject newCard = GameObject.Instantiate(m_cardPrefab); if (faceUp) { newCard.transform.localEulerAngles = new Vector3(0, 0, 0); } else { newCard.transform.localEulerAngles = new Vector3(0, 180, 0); } CardVisual cv = newCard.GetComponent <CardVisual>(); // cardData is null if the card is hidden (e.g. a card in the opponent's hand) if (cardData != null) { cv.SetCardData(cardData, cardID); } // Add the new card to the list by its ID m_cards.Add(cardID, cv); return(cv); }
/** Define the data of a blank card */ public CardVisual DefineCard(CardVisual card, CardData data, int cardID) { card.SetCardData(data, cardID); m_cards.Add(cardID, card); return(card); }