public void Awake() { startGame.interactable = false; cardController = FindObjectOfType(typeof(CardController)) as CardController; playerController = FindObjectOfType(typeof(PlayerController)) as PlayerController; dealerController = FindObjectOfType(typeof(DealerController)) as DealerController; DealButtonState(false); NextRoundState(false); NewGameButtonState(false); //shuffles the deck 4 times for (int i = 0; i < 5; i++) { cardController.CardShuffle(); } }
//Start Next Game public void NextRound() { //Clear all counters cardTracker = 0; playerTurnIndex = 0; bettingTurnIndex = 0; //Check for remaining players if (CheckRemainingPlayers()) { nextRound.GetComponentInChildren <Text>().text = "GAME OVER"; nextRound.interactable = false; NewGameButtonState(true); //Destroy all cards on the table allCards = GameObject.FindGameObjectsWithTag("Card"); foreach (GameObject allTheCard in allCards) { Destroy(allTheCard); } } //Clear player counters for (int i = 0; i < numberOfPlayers; i++) { if (playerLocations[i] != null) { playerLocations[i].GetComponent <PlayerController>().ClearPlayerCounters(); } else { continue; } } //Clear dealer counters dealerController.ClearDealerCounters(); dealerController.ShowDealerStatus("clear"); //Clear all betting fields for (int i = 0; i < numberOfPlayers; i++) { if (playerLocations[i] != null) { playerLocations[i].GetComponent <PlayerController>().BetFieldState("reset"); playerLocations[i].GetComponent <PlayerController>().BetFieldState("clear"); } else { continue; } } //Restart Betting order BettingTurn(); for (int j = 0; j < numberOfPlayers; j++) { if (playerLocations[j] != null) { //Clear all Player's current bet values playerLocations[j].GetComponent <PlayerController>().playerCurrentBet = 0; //Clear player status field playerLocations[j].GetComponent <PlayerController>().ShowPlayerStatusState("clear"); } else { continue; } } if (playerLocations[0] != null) { playerLocations[0].GetComponent <PlayerController>().ShowPlayerStatusState("bet"); } //Destroy all cards on the table allCards = GameObject.FindGameObjectsWithTag("Card"); foreach (GameObject allTheCard in allCards) { Destroy(allTheCard); } //Reshuffle the deck three times for (int i = 0; i < 4; i++) { cardController.CardShuffle(); } //Disable Next Round button NextRoundState(false); for (int i = 0; i < numberOfPlayers; i++) { if (playerLocations[i] != null) { //Adjust all player's funds playerLocations[i].GetComponent <PlayerController>().AdjustPlayerFunds(); //Clears all the player's hand for (int j = 0; j < 10; j++) { playerLocations[i].GetComponent <PlayerController>().playerCards[j] = null; } } else { continue; } } //Clear all the dealer's cards for (int j = 0; j < 10; j++) { dealerController.dealerCards[j] = null; } }