Exemplo n.º 1
0
 public void ClearAll()
 {
     Debug.Log("ClearAll");
     gameState = GameState.Standby;
     layout.slotDefs.Clear();
     foreach (Card c in deck.cards)
     {
         Destroy(c.gameObject);
     }
     foreach (PokerPlayer p in _players)
     {
         if (p.cards.Count > 0)
         {
             foreach (CardPokerFace cpf in p.cards)
             {
                 Destroy(cpf.gameObject);
             }
         }
         p.cards.Clear();
         p.command = null;
         if (p is AIPokerPlayer)
         {
             AIPokerPlayer a = p as AIPokerPlayer;
             if (a.totalAmount <= 50)
             {
                 a.totalAmount = 5000;
             }
         }
     }
     foreach (CardButton cb in UIManager.S.cardButtons)
     {
         if (cb.GetUICard())
         {
             Destroy(cb.GetUICard().gameObject);
             cb.SetUICard(null);
             cb.SetPlayerCard(null);
         }
     }
     activePlayers.Clear();
     winners.Clear();
     _activePlayersHands.Clear();
     table.Clear();
     pot           = 0;
     amountToBet   = 0;
     localPlayer   = _players[0];
     dealer        = null;
     currentPlayer = null;
 }
Exemplo n.º 2
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.º 3
0
    //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
        }
    }
Exemplo n.º 4
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
            }
        }
    }