public void CheckWin() { int pTotal = GetHandTotal(playerHand); int dTotal = GetHandTotal(dealerHand); if (pTotal > 21) { payout = winCondition.Bust; } else if (pTotal <= 21 && playerHand.Length == 5) { payout = winCondition.FiveCardCharlie; } else if (pTotal == 21) { payout = winCondition.BlackJack; } else if (dTotal < pTotal || pTotal < dTotal && dTotal > 21) { payout = winCondition.Win; } else if (dTotal > pTotal && dTotal <= 21) { payout = winCondition.Loss; } else if (dTotal == pTotal) { payout = winCondition.None; } }
private void Awake() { choice = ""; spr = GetComponent <SpriteRenderer>(); gameController = GameObject.FindWithTag("GameController").GetComponent <GameController>(); win = GameObject.FindWithTag("GameController").GetComponent <winCondition>(); aiScript = GameObject.FindWithTag("GameController").GetComponent <AI>(); }
public winCondition handleWincondition(int Num, int Suit, ref bool FullHouse, ref int Pairs, int inOrder) { winCondition condition = winCondition.None; if (Num == 2) { Pairs++; condition = winCondition.Pair; } if (Num == 2 && Pairs > 2) { return(winCondition.TwoPair); } if (Num == 3) { FullHouse = true; condition = winCondition.ThreeOfAKind; } if (inOrder == 5) { condition = winCondition.Straight; } if (Suit == 5) { int high = 0; foreach (var card in hand) { if (card.value > high) { high = card.value; } } if (high > 10) { condition = winCondition.RoyalFlush; } else { condition = winCondition.Flush; } } if ((FullHouse && Num == 2)) { condition = winCondition.FullHouse; } if (Num == 4) { condition = winCondition.FourOfAKind; } if (condition == winCondition.Straight && Suit == 5) { condition = winCondition.StraightFlush; } return(condition); }
public void OnHit() { if (playerCards < 6) { playerHand[playerCards] = deck.Draw(); playerButtons[playerCards].gameObject.SetActive(true); playerCards++; if (GetHandTotal(playerHand) > 21) { payout = winCondition.Bust; } Debug.Log(payout.ToString()); } }
public void CheckPayout() { payout = winCondition.None; bool fullHousePoss = false; int numOfPairs = 0; int cSameNum = -1; int cSameSuit = 0; int inOrder = 1; int x = 0; int val = hand[x].value; for (int j = 0; j < hand.Length; j++) { if (hand[j].value == val + 1 || hand[j].value == 1 && val + 1 == 14) { val = hand[j].value; inOrder++; j = 0; } if (inOrder == 5) { j = hand.Length; } } for (int i = 0; i < hand.Length - 1; i++) { for (int j = 0; j < hand.Length; j++) { if (j != i) { if (hand[i].value == hand[j].value) { cSameNum++; } if (hand[i].suit == hand[j].suit) { cSameSuit++; } } } winCondition poss = handleWincondition(cSameNum, cSameSuit, ref fullHousePoss, ref numOfPairs, inOrder); if (poss < payout) { payout = poss; } } }
// called when one of the players has won or if a tie has been reached public void GameOver(winCondition cond) { switch (cond) { case winCondition.P1_WIN: Debug.Log("PLayer 1 has won!"); SceneTransition.Instance.LoadScene("P1 Win"); break; case (winCondition.P2_WIN): Debug.Log("Player 2 has won!"); SceneTransition.Instance.LoadScene("P2 Win"); break; } // display the win scene }
private void chooseWinCondition() { System.Random rand = new System.Random(DateTime.Now.Millisecond); int conditionIndex = rand.Next(0, 2); condition = (winCondition)conditionIndex; switch (condition) { case winCondition.Items: _uiManager.updateWinConditionText("Items Left: " + itemsToCollect); break; case winCondition.Time: _uiManager.updateWinConditionText("Time Left: " + clockTime); break; } }
private void Awake() { win = GameObject.FindWithTag("GameController").GetComponent <winCondition>(); gameController = GameObject.FindWithTag("GameController").GetComponent <GameController>(); countAI = 0; }
public WinCondition(string newDescription, winCondition newFunction) { description = newDescription; function = newFunction; }