Exemplo n.º 1
0
    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
            }
        }
    }
Exemplo n.º 2
0
    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
            }
        }
    }