예제 #1
0
    public Card DrawCardToHand()
    {
        GameObject cardNode = Deck.DrawCard();

        if (cardNode == null)
        {
            if (Discard.isEmpty())
            {
                Debug.Log("No cards in Game.");
            }
            else
            {
                while (!Discard.isEmpty())
                {
                    GameObject node = Discard.RemoveCard();
                    Deck.AddCardNode(node);
                }

                Deck.ShuffleDeck();
                cardNode = Deck.DrawCard();
            }
        }

        if (cardNode != null)
        {
            if (Hand.transform.childCount >= 10)
            {
                Debug.Log("Hand is full.");
                Discard.AddCardNode(cardNode);
            }
            else
            {
                Hand.GetComponent <Hand>().AddCardToHand(cardNode.GetComponent <CardNode>().card);
                Destroy(cardNode);
            }

            return(cardNode.GetComponent <CardNode>().card);
        }

        return(null);
    }