예제 #1
0
    public BaseCardComponent PopTopCard()
    {
        BaseCardComponent cardObject;
        SpriteRenderer    spriteRenderer;

        if (cards.Count <= 0)
        {
            return(null);
        }

        BaseCard card = cards[0];

        cards.RemoveAt(0);

        cardObject     = new GameObject("card" + count).AddComponent <BaseCardComponent> ();
        spriteRenderer = cardObject.gameObject.AddComponent <SpriteRenderer> ();
        cardObject.SetBaseCard(card);
        cardObject.SetSpriteRenderer(spriteRenderer);
        cardObject.SetBackSprite(sprite.sprite);
        cardObject.SetFrontSprite(card.GetSprite());
        cardObject.transform.position = new Vector3(transform.position.x, transform.position.y, 0);
        cardObject.transform.rotation = Quaternion.Euler(0, 180, 0);
        cardObject.gameObject.layer   = 8;      //Hand Layer

        if (cards.Count <= 0)
        {
            sprite.enabled = false;
        }

        count++;
        Debug.Log("Deck/PopTopCard : " + card.ToString());
        return(cardObject);
    }