Пример #1
0
 void Start()
 {
     cs         = GameObject.FindObjectOfType <cardScript>();
     gsScript   = GameObject.FindObjectOfType <gameSystem>();
     points     = diceChecker.thrownPoints;
     diceIsDone = rollingDice.isFinished;
 }
Пример #2
0
    //Called when either the dealer or the player has a Natural Blackjack.
    //Flips the dealer's second card, then simply compares the hands to determine
    //who has the Blackjack.
    private IEnumerator Blackjack()
    {
        cardScript script = hand[1].GetComponent <cardScript>();

        yield return(StartCoroutine(script.LiftAndFlip(5)));

        if (options.GetShowOnUIToggle())
        {
            UI.SetDealerHandValueText(GetHandValue());
        }
        yield return(new WaitForSeconds(0.5f));

        if (player.GetHandValue() > GetHandValue())
        {
            StartCoroutine(React(blackjackUIScript.Result.PlayerBlackjack));
        }
        else if (GetHandValue() > player.GetHandValue())
        {
            StartCoroutine(React(blackjackUIScript.Result.DealerBlackjack));
        }
        else
        {
            StartCoroutine(React(blackjackUIScript.Result.BothHaveBlackjack));
        }
    }
Пример #3
0
 public void PrintHand()
 {
     foreach (GameObject g in hand)
     {
         cardScript script = g.GetComponent <cardScript>();
         Debug.Log(script.GetFace() + " of " + script.GetSuit() + "(" + script.GetValue() + ")");
     }
 }
Пример #4
0
    //Pulls a card from the deck and moves it to the dealer's hand
    //both physically and in the backend, without flipping it over.
    private IEnumerator DealCardToSelfFaceDown()
    {
        GameObject card   = deck.DealCard();
        cardScript script = card.GetComponent <cardScript>();

        anim.Play("godBossDealToSelfAnimation");
        Vector3 cardPos = dealerHandPosition;

        cardPos.z -= hand.Count * cardSpacing;
        cardPos.y += hand.Count * 0.1f;
        yield return(StartCoroutine(script.MoveCard(cardPos)));

        AddCardToHand(card);
    }
Пример #5
0
    //Dealer behaves according to standard Blackjack rules.
    //The second card is flipped over. The dealer draws until his hand is above soft 17.
    public IEnumerator Stand()
    {
        cardScript script = hand[1].GetComponent <cardScript>();

        yield return(StartCoroutine(script.LiftAndFlip(5)));

        if (GetHandValue() > 21)
        {
            CheckAces();
        }
        if (options.GetShowOnUIToggle())
        {
            UI.SetDealerHandValueText(GetHandValue());
        }
        while (GetHandValue() < 17 && (GetHandSize() < 5 || options.GetFiveCardCharlieToggleDisabled()))
        {
            yield return(StartCoroutine(DealCardToSelf()));

            yield return(new WaitForSeconds(0.25f));

            if (GetHandValue() > 21)
            {
                CheckAces();
            }
        }
        if (GetHandValue() == 17 && hand.FirstOrDefault(i => i.GetComponent <cardScript>().GetValue() == 11) != null)
        {
            do
            {
                yield return(StartCoroutine(DealCardToSelf()));

                if (GetHandValue() > 21)
                {
                    CheckAces();
                }
                yield return(new WaitForSeconds(0.25f));
            }while (GetHandValue() < 17 && (GetHandSize() < 5 || options.GetFiveCardCharlieToggleDisabled()));
        }
        if (GetHandValue() > 21 && !CheckAces())
        {
            StartCoroutine(React(blackjackUIScript.Result.DealerBust));
        }
        else
        {
            StartCoroutine(EvaluateHands());
        }
    }
Пример #6
0
    void OnTriggerEnter(Collider col)
    {
        string layerName = LayerMask.LayerToName(col.gameObject.layer);

        if (layerName == "Cards")
        {
            cardScript currentCard = col.gameObject.GetComponentInParent <cardScript> ();
            if (currentCard == null)
            {
                return;
            }
            if (currentCard.EvaluateDistance(transform.position, senseDistance, pickupDistance))
            {
                Debug.Log("PICK UP!");
                currentCard.transform.parent        = transform;
                currentCard.transform.localPosition = Vector3.zero;
            }
        }
    }
Пример #7
0
    //Pulls a card from the deck and moves it to the dealer's hand
    //both physically and in the backend.
    private IEnumerator DealCardToSelf()
    {
        GameObject card   = deck.DealCard();
        cardScript script = card.GetComponent <cardScript>();

        anim.CrossFade("godBossDealToSelfAnimation");
        StartCoroutine(script.Flip());
        Vector3 cardPos = dealerHandPosition;

        cardPos.z -= hand.Count * cardSpacing;
        cardPos.y += hand.Count * 0.1f;// + 4.0f;
        yield return(StartCoroutine(script.MoveCard(cardPos)));

        AddCardToHand(card);
        if (options.GetShowOnUIToggle())
        {
            UI.SetDealerHandValueText(GetHandValue());
        }
    }
Пример #8
0
    //Pulls a card from the deck and moves it to the player's hand
    //both physically and in the backend.
    public IEnumerator DealCardToPlayer()
    {
        GameObject card   = deck.DealCard();
        cardScript script = card.GetComponent <cardScript>();

        anim.CrossFade("godBossDealToPlayerAnimation");
        Vector3 cardPos = playerHandPosition;

        cardPos.z -= player.GetHandSize() * cardSpacing;
        cardPos.y += player.GetHandSize() * 0.1f;
        StartCoroutine(script.Flip());
        yield return(StartCoroutine(script.MoveCard(cardPos)));

        player.addToHand(card);
        if (options.GetShowOnUIToggle())
        {
            UI.SetPlayerHandValueText(player.GetHandValue());
        }
    }
Пример #9
0
    //After insurance is taken or not, the dealer flips his second card if it's a 10.
    //If not, the hand continues as normal, the player's money wasted if they
    //took insurance that turn.
    public void Insurance(bool tookInsurance)
    {
        player.SetInsurance(tookInsurance);
        cardScript script = hand[1].GetComponent <cardScript>();

        if (script.GetValue() == 10 || player.GetHandValue() == 21)
        {
            UI.SetHitAndStand(false);
            UI.SetDoubleDown(false);
            StartCoroutine(Blackjack());
        }
        else
        {
            UI.SetHitAndStand(true);
            if (UI.GetFunds() > player.GetBetAmount())
            {
                UI.SetDoubleDown(true);
            }
        }
    }