Exemplo n.º 1
0
    public void EasyAISystem()  // 簡單電腦
    {
        List <Card> PassCard = new List <Card>();

        if (Judgment.CheckAllPlayerPass())
        {
            // Random看要出什麼牌型
            PassCard = PassRandomCards();

            if (PassCard.Count == 0)
            {
                EasyAISystem(); // 重新呼叫, 不可過水, 第一位不可以亂出
                return;
            }
        }
        else
        {
            //獲得可以出的牌
            PassCard = GetCanPassCard();
        }

        // 把牌塞入
        foreach (var card in PassCard)
        {
            for (int i = 0; i < deck.transform.childCount; i++)
            {
                var handCard = deck.transform.GetChild(i).transform.GetComponent <Card>();

                if (card.value == handCard.value &&
                    card.symbol == handCard.symbol)
                {
                    handCard.SetCardSelect();
                }
            }
        }

        // 檢查如果前三家都pass, 並且不通過時,則必須重來
        if (Judgment.CheckAllPlayerPass() && !Judgment.CheckCanPassCard(deck))
        {
            for (int i = 0; i < deck.transform.childCount; i++)
            {
                Transform card = deck.transform.GetChild(i);
                if (card != null)
                {
                    card.GetComponent <Card>().SetCardCancel();
                }
            }
            EasyAISystem();
        }
        else
        {
            // 在這邊執行最後的出牌
            if (PassCard.Count != 0)
            {
                PassCards();
            }
            else
            {
                PassThisRank();
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>檢查是否可以出牌</summary>
    public bool CheckCanPassCard()
    {
        GameObject deck = gameObject.transform.parent.gameObject;

        return(Judgment.CheckCanPassCard(deck));
    }
Exemplo n.º 3
0
    // 牌型選擇ui監聽事件實作
    private void SenderFunction(string senderName)
    {
        List <List <Card> > decks = new List <List <Card> >();
        Player      player        = GameView.transform.GetComponent <GameView>().m_player[0];
        List <Card> cards         = player.GetCardList();

        // 將牌先全部放下
        for (int i = 0; i < player.deck.transform.childCount; i++)
        {
            player.deck.transform.GetChild(i).transform.GetComponent <Card>().SetCardCancel();
        }

        // 如果是同顆按鈕則尋找下一個位置
        if (tempButton == senderName)
        {
            tempButtonindex++;
        }
        else
        {
            tempButton      = senderName;
            tempButtonindex = 0;
        }

        switch (senderName)
        {
        case "btn_findpair":
            decks = CardTypeCheckMgr.FindPair(cards);
            break;

        case "btn_findthree":
            decks = CardTypeCheckMgr.FindThreeOfKinds(cards);
            break;

        case "btn_findStraight":
            decks = CardTypeCheckMgr.FindStraight(cards);
            break;

        case "btn_findFullHouse":
            decks = CardTypeCheckMgr.FindFullHouse(cards);
            break;

        case "btn_findFour":
            decks = CardTypeCheckMgr.FindFourOfKinds(cards);
            break;

        case "btn_findStraightFlush":
            decks = CardTypeCheckMgr.FindStraightFlush(cards);
            break;
        }

        // 找牌,並選起
        for (int i = 0; i < player.deck.transform.childCount; i++)
        {
            Card card      = player.deck.transform.GetChild(i).transform.GetComponent <Card>();
            var  tempdecks = decks[tempButtonindex % decks.Count];
            for (int j = 0; j < tempdecks.Count; j++)
            {
                if (card.value == tempdecks[j].value &&
                    card.symbol == tempdecks[j].symbol)
                {
                    card.SetCardSelect();
                }
            }
        }

        // 去檢查是否可以出牌
        if (Judgment.CheckCanPassCard(player.deck))
        {
            btn_PassCards.interactable = true;
        }
        else
        {
            btn_PassCards.interactable = false;
        }
    }