示例#1
0
    private void RoundOver()
    {
        bool playerBust = playerScript.handValue > 21;
        bool dealerBust = dealerScript.handValue > 21;
        bool player21   = playerScript.handValue == 21;
        bool dealer21   = dealerScript.handValue == 21;

        if (standClicked < 2 && !playerBust && !dealerBust && !player21 && !dealer21)
        {
            return;
        }
        bool roundOver = true;

        if (playerBust && dealerBust)
        {
            mainText.text = "All bust: Bets returned";
            playerScript.AdjustMoney(money / 2);
        }
        else if (playerBust || (!dealerBust && dealerScript.handValue > playerScript.handValue))
        {
            mainText.text = "Dealer Wins!";
        }
        else if (dealerBust || playerScript.handValue > dealerScript.handValue)
        {
            mainText.text = "You Win!";
            playerScript.AdjustMoney(money);
        }
        else if (playerScript.handValue == dealerScript.handValue)
        {
            mainText.text = "Push: Bets Returned";
            playerScript.AdjustMoney(money / 2);
        }
        else
        {
            roundOver = false;
        }

        if (roundOver)
        {
            hit.gameObject.SetActive(false);
            stand.gameObject.SetActive(false);
            deal.gameObject.SetActive(true);
            mainText.gameObject.SetActive(true);
            dealerScoreText.gameObject.SetActive(true);
            hideCard.GetComponent <Renderer>().enabled = false;
            betsText.text = "0";

            foreach (GameObject go in playerCards)
            {
                go.GetComponent <Image>().enabled = false;
            }
            hitCards = 0;

            foreach (GameObject dc in dealerCards)
            {
                dc.GetComponent <Image>().enabled = false;
            }
            dealCards = 0;
            //cashText.text = "$" + playerScript.GetMoney().ToString();
            standClicked = 0;
        }
    }