protected override void ShowValue()
    {
        if (hand.Count > 1)
        {
            if (!reveal)
            {
                handVals = hand[1].GetCardHighValue();

                total.text = "Dealer: " + handVals + " + ???";
            }
            else
            {
                handVals = GetHandValue();

                total.text = "Dealer: " + handVals;

                BlackJackManager manager = GameObject.Find("BlackJackManager").GetComponent <BlackJackManager>();

                if (handVals > 21)
                {
                    manager.DealerBusted();
                }
                else if (!DealStay(handVals))
                {
                    Invoke("HitMe", 1);
                }
                else
                {
                    BlackJackHand playerHand = GameObject.Find("Player Hand Value").GetComponent <BlackJackHand>();

                    if (handVals < playerHand.handVals)
                    {
                        manager.PlayerWin();
                    }
                    else
                    {
                        manager.PlayerLose();
                        //fartSound.Play(); //also no
                    }
                }
            }
        }
    }
Beispiel #2
0
    protected override void ShowValue(List <DeckOfCards.Card> currentHand, Transform handBase, Text currentTotal, int currentHandVal)
    {
        if (currentHand.Count > 1)
        {
            if (!reveal)
            {
                currentHandVal = currentHand[1].GetCardValue();

                currentTotal.text = "Dealer: " + currentHandVal + " + ???";
            }
            else
            {
                currentHandVal = GetHandValue(currentHand);

                currentTotal.text = "Dealer: " + currentHandVal;

                BlackJackManager manager = GameObject.Find("BlackJackManager").GetComponent <BlackJackManager>();

                if (currentHandVal > 21)
                {
                    manager.DealerBusted();
                }
                else if (!DealStay(currentHandVal))
                {
                    DealMeIn(currentHand, handBase, currentTotal, currentHandVal);
                }
                else
                {
                    BlackJackHand playerHand = GameObject.Find("PlayerHandValue1").GetComponent <BlackJackHand>();

                    if (currentHandVal < playerHand.handVal1 || currentHandVal < playerHand.handVal2)
                    {
                        manager.PlayerWin();
                    }
                    else
                    {
                        manager.PlayerLose();
                    }
                }
            }
        }
    }