예제 #1
0
    public void Populate(MatchDesc matchDesc)
    {
        ClearGameList();

        NetworkID  networkID = matchDesc.networkId;
        GameObject grid      = pool.GetUnit();

        grid.SetActive(true);
        grid.transform.SetParent(container);
        grid.transform.localScale = new Vector3(1, 1, 1);
        grid.GetComponent <MatchGrid>().SetMatchDescription(matchDesc);

        if (matchDesc.currentSize < matchDesc.maxSize)
        {
            var button = grid.GetComponent <Button>();
            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() => { JoinMatch(networkID); });
        }
    }
예제 #2
0
파일: Deck.cs 프로젝트: manboygames/capsa
    IEnumerator InitCards()
    {
        while (cardPool.Units == null || cardPool.Units.Count == 0)
        {
            yield return(null);
        }

        deckCardsList = new List <Card>();
        cardsBackup   = new List <Card>();

        var suits = (int[])Enum.GetValues(typeof(Card.Suit));
        var ranks = (int[])Enum.GetValues(typeof(Card.Rank));

        for (int i = 0; i < suits.Length; i++)
        {
            for (int j = 0; j < ranks.Length; j++)
            {
                var card = cardPool.GetUnit().GetComponent <Card>();
                card.gameObject.SetActive(true);
                card.SetCard((Card.Suit)suits[i], (Card.Rank)ranks[j]);
                deckCardsList.Add(card);
                cardsDict.Add(card.name, card);
            }
        }

        cardsBackup = new List <Card>(deckCardsList);

        yield return(new WaitForEndOfFrame());

        int length = deckCardsList.Count;

        for (int i = 0; i < length; i++)
        {
            deckCardsList[i].gameObject.SetActive(false);
            //cardPool.ReturnUnit(cards[i]);
        }

        isReady = true;
    }