コード例 #1
0
    public BaseCard GetNewCard(string id)
    {
        if (!_cards.ContainsKey(id))
        {
            return(null);
        }
        BaseCard card = ScriptableObject.Instantiate(_cards[id]);

        card.Initialize();
        return(card);
    }
コード例 #2
0
    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");
    }
コード例 #3
0
    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());
    }