public BaseCard GetNewCard(string id) { if (!_cards.ContainsKey(id)) { return(null); } BaseCard card = ScriptableObject.Instantiate(_cards[id]); card.Initialize(); return(card); }
static void LoadCards() { CardDatabase cardDatabase = new CardDatabase(); foreach (var cardGeneric in Resources.LoadAll(CARDS_RESOURCE_PATH, typeof(BaseCard))) { BaseCard card = cardGeneric as BaseCard; card.Initialize(); cardDatabase.AddCard(card); } DI.Set <CardDatabase>(cardDatabase); Debug.Log("=== Finished LoadCards"); }
public void Initialize(CardData cardData) { if (_previewDoughnut != null) { return; // Already initialized. } _baseCard = GetComponent <BaseCard>(); _baseCard.Initialize(cardData); _previewDoughnut = Instantiate(_previewDoughnutPref); _previewDoughnut.sprite = _baseCard.CardData.sprite; _previewDoughnut.gameObject.SetActive(false); _rectTransform = GetComponent <RectTransform>(); _initialAnchorPosition = _rectTransform.anchoredPosition; StartCoroutine(Recharge()); }