Ejemplo n.º 1
0
    void dealCard()
    {
        if (layout_DealCardHolder.childCount > 0)
        {
            Image[] childImageArr = layout_DealCardHolder.GetComponentsInChildren <Image> ();
            for (int i = 0; i < childImageArr.Length; i++)
            {
                if (childImageArr [i] != null)
                {
                    DestroyImmediate(childImageArr [i].gameObject);
                }
            }
        }
        thisPlayerRoundCardList = new List <CardHolder> ();
        for (int i = 0; i < cardCountPerRound; i++)
        {
            GameObject newCardGObj = Instantiate(cardPrefab.gameObject);
            newCardGObj.transform.SetParent(layout_DealCardHolder, false);
            CardHolder newCardHolder = newCardGObj.GetComponent <CardHolder> ();
            newCardHolder.SetCard(thisPlayerGenerateCardArr [i], i);
            thisPlayerRoundCardList.Add(newCardHolder);

            if (newCardHolder.Card.cardType == CardType.Bullet || newCardHolder.Card.cardType == CardType.UselessBullet)
            {
                continue;
            }

            newCardGObj.GetComponent <Button> ().onClick.AddListener(delegate {
                onCardClick(newCardHolder);
            });

            newCardHolder.Btn_PlayCard.onClick.AddListener(delegate {
                onCardPlay(newCardHolder);
            });
        }
    }