public void ButtonEvt_ConfirmHeldCards() { if (_isGameOver) { UnloadGame(); Anim_Win(false); LoadGame(); Anim_WinType(0); _isGameOver = false; return; } foreach (var card in _pokerHand) { if (!_cardsToHold.Contains(card)) { var newCard = PokerDeckController.ReturnRandomCard(); card.LoadCardData(newCard); } } _cardsToHold.Clear(); var result = CheckForWinningHand(_pokerHand); Anim_Win(result != PokerScore.None); Anim_WinType((int)result); _score += (int)result; _isGameOver = true; }
/// <summary> /// Every new deal comes from a fresh deck of cards. /// </summary> private void LoadGame() { PokerDeckController.PrepareDeck(_deckData); for (int i = 0; i < _pokerHandSize; i++) { var cardData = PokerDeckController.ReturnRandomCard(); var card = Instantiate(_pokerCardPrefab, _pokerHandGroup); card.LoadCardData(cardData); card.ButtonComponent.onClick.AddListener(() => ButtonEvt_CardClicked(card)); _pokerHand.Add(card); } }