IEnumerator RevealAIPlayersCards(int cardAmount, float delay) { yield return(new WaitForSeconds(delay)); //flip the AI players cards foreach (PokerPlayer p in _players) { AIPokerPlayer aip = p as AIPokerPlayer; List <CardPokerFace> cardsToReveal = new List <CardPokerFace>(); if (aip) { foreach (CardPokerFace cpf in aip.cards) { if (!cpf.faceUp && !cpf.selected) { cardsToReveal.Add(cpf); } } for (int i = 0; i < 2; i++) { Randomize: int rand = Random.Range(0, cardsToReveal.Count); if (!cardsToReveal[rand].selected) { aip.SelectCard(cardsToReveal[rand]); cardsToReveal[rand].selected = true; } else { goto Randomize; } } aip.SetCommand(new RevealCardsCommand()); //ai players need to select 2 cards to reveal aip.Action(); //ai players need to reveal selected cards //play reveal cards animation } } }
//Called every player's turn public IEnumerator PlayGame() { //Debug.Log("PlayGame"); yield return(new WaitForEndOfFrame()); //set the timer in the correct position //Debug.Log("currentPlayer: " + currentPlayer); maxTime = 25f; timer = maxTime; UIManager.S.ToggleSpark(true); UIManager.S.PlayPlayerImageEffect(currentPlayer.id); UIManager.S.SetTimerPosition(currentPlayer); if (currentPlayer is AIPokerPlayer) { float delay = Random.Range(1f, 7f); //delay yield return(new WaitForSeconds(delay)); AIPokerPlayer aip = currentPlayer as AIPokerPlayer; if (aip) { aip.CalculateMove(); //calculate move aip.Action(); //action } //Debug.Log(aip.name + " " + aip.command); //play relevant animation InitPlay(); } else { //run play timer UIManager.S.TogglePlayPanel(true); //show play panel UIManager.S.ToggleRaisePanel(false); //local player needs to select wanted command -- done via UI //action -- done via UI //play relevant animation } }
public void RevealAIPlayersCards(int cardAmount) { //flip the AI players cards foreach (PokerPlayer p in _players) { AIPokerPlayer aip = p as AIPokerPlayer; List <CardPokerFace> cardsToReveal = new List <CardPokerFace>(); if (aip) { foreach (CardPokerFace cpf in aip.cards) { if (!cpf.faceUp && !cpf.selected) { cardsToReveal.Add(cpf); } } for (int i = 0; i < cardAmount; i++) { Randomize: int rand = Random.Range(0, cardsToReveal.Count); if (!cardsToReveal[rand].selected) { aip.SelectCard(cardsToReveal[rand]); cardsToReveal[rand].selected = true; } else { goto Randomize; } } aip.SetCommand(new RevealCardsCommand()); //ai players need to select 2 cards to reveal aip.Action(); //ai players need to reveal selected cards } } }