Пример #1
0
    private Card GenerateCard(GameObject holder)
    {
        TurnManager tm = TurnManager.instance;

        Card randomCard = tm.RandomCard();

        if (randomCard.GetType() == typeof(UnitCard))
        {
            UnitCard randomCardComponent = (UnitCard)holder.AddComponent(randomCard.GetType());
            randomCardComponent.copyUnitCard((UnitCard)randomCard);
            return(randomCardComponent);
        }
        else if (randomCard.GetType() == typeof(SpellCard))
        {
            SpellCard randomCardComponent = (SpellCard)holder.AddComponent(randomCard.GetType());
            randomCardComponent.copySpellCard((SpellCard)randomCard);
            return(randomCardComponent);
        }
        else
        {
            Debug.LogError("Card type error! : " + randomCard.GetType().ToString());
        }

        return(new Card());
    }
Пример #2
0
    public void AddCard(Card card)
    {
        UnitCard  unitCopyCard  = null;
        SpellCard spellCopyCard = null;

        if (card is UnitCard)
        {
            unitCopyCard = new UnitCard();
            unitCopyCard.copyUnitCard((UnitCard)card);
            m_playerCards.Add(unitCopyCard);
        }
        else if (card is SpellCard)
        {
            spellCopyCard = new SpellCard();
            spellCopyCard.copySpellCard((SpellCard)card);
            m_playerCards.Add(spellCopyCard);
        }

        m_playerCards[m_playerCards.Count - 1].indexInHand = m_playerCards.Count - 1;
    }