Beispiel #1
0
    private IEnumerator DealerPhase()
    {
        phase = TablePhase.Dealer;
        foreach (Card card in dealerHand.GetComponentsInChildren <Card>())
        {
            card.up = true;
        }
        dealerCounter.SetVisible(true);
        yield return(new WaitForSeconds(0.5f));

        while (dealerCounter.count < 17)
        {
            DeckCard   drawn = deck.Pop();
            GameObject go    = Instantiate <GameObject>(cardPrefab, dealerHand);
            Card       card  = go.GetComponent <Card>();
            card.suit   = drawn.suit;
            card.number = drawn.number;
            dealerCounter.Count();
            yield return(new WaitForSeconds(0.5f));
        }
        StartCoroutine(DrawPhase(4, 2.5f));
    }
Beispiel #2
0
    private IEnumerator DrawPhase(int cards, float delay)
    {
        yield return(new WaitForSeconds(delay));

        phase = TablePhase.Draw;
        ClearTable();
        cardsToBeDealt = cards;
        dealerCounter.SetVisible(false);
        busted = false;
        while (cardsToBeDealt > 0)
        {
            yield return(new WaitForSeconds(0.5f));

            DeckCard   drawn = deck.Pop();
            Transform  hand  = (cardsToBeDealt % 2 > 0) ? dealerHand : playerHand;
            GameObject go    = Instantiate <GameObject>(cardPrefab, hand);
            Card       card  = go.GetComponent <Card>();
            card.suit   = drawn.suit;
            card.number = drawn.number;
            card.up     = (cardsToBeDealt != 1);
            cardsToBeDealt--;
        }
        phase = TablePhase.Player;
    }