/// <summary> /// First deal of the game. /// </summary> public void DealGame() { ResetGame(); canBet = false; //betSlider.interactable = false; betButton.gameObject.SetActive(false); redoBetButton.gameObject.SetActive(false); //lastBet = (int)betSlider.value; betChips.Clear(); foreach (Transform chip in BetArea.transform) { betChips.Add(allChips.FindChipByName(chip.gameObject.name)); } lastBet = currentBet; player.PlaceBet(currentBet); standButton.gameObject.SetActive(true); hitButton.gameObject.SetActive(true); if (player.GetBets()[0] <= player.Credit) { doubleButton.gameObject.SetActive(true); } deck.BuildDeck(); deck.ShuffleDeck(); insuranceText.text = "Do you want insurance?"; insuranceBlackjack = false; for (int index = 0; index < handResultsText.Count; index++) { Destroy(handResultsText[index].gameObject); } handResultsText.Clear(); for (int index = 0; index <= 3; index++) { Card newCard = deck.Deal(); int temp = index % 2; if (index % 2 == 0) { player.AddToHand(newCard); } else { dealer.AddToHand(newCard); } } if (dealer.GetHand()[0].GetFaceValue() == 11) { if (player.Credit >= (lastBet / 2)) { insuranceText.transform.gameObject.SetActive(true); insuranceYesButton.gameObject.SetActive(true); insuranceNoButton.gameObject.SetActive(true); doubleButton.gameObject.SetActive(false); splitButton.gameObject.SetActive(false); standButton.gameObject.SetActive(false); hitButton.gameObject.SetActive(false); } else { InsuranceNo(); } } else if (player.Splitable() && !insuranceBlackjack && player.GetBets()[0] <= player.Credit) { splitButton.gameObject.SetActive(true); } else { splitButton.gameObject.SetActive(false); } UpdateCardValues(); }