Beispiel #1
0
    public void Show(bool isOutCardOrTouchCard, Battle battle)
    {
        IsOutCardOrTouchCard = isOutCardOrTouchCard;
        OneSide mySide = battle.Sides.FirstOrDefault(c => c.AccountID == BattleRoomCtr.Instance.SendCommand.UserID);

        if (IsOutCardOrTouchCard)
        {
            BtnPeng.gameObject.SetActive(false);
            List <WinCardModel> winCardModels = WinALG.Win(mySide.Cards, true);
            if (winCardModels.Count > 0)
            {
                BtnHu.gameObject.SetActive(true);
                BtnHu.transform.localScale = Vector3.zero;
                BtnHu.transform.DOScale(1, 0.3f);
            }
            BtnGuo.gameObject.SetActive(false);
        }
        else
        {
            //当前是碰牌指令,检测释放可以胡牌(杠牌胡)
            List <Card> cardList = new List <Card>(mySide.Cards);
            cardList.Add(battle.CurrentSide.TakeOutCard);
            List <WinCardModel> winCardModels = WinALG.Win(cardList, false);
            if (winCardModels.Count > 0)
            {
                BtnHu.gameObject.SetActive(true);
                BtnHu.transform.localScale = Vector3.zero;
                BtnHu.transform.DOScale(1, 0.3f);
            }
            else
            {
                BtnPeng.gameObject.SetActive(true);
                BtnPeng.transform.localScale = Vector3.zero;
                BtnPeng.transform.DOScale(1, 0.3f);
            }
            BtnGuo.gameObject.SetActive(true);
            BtnGuo.transform.localScale = Vector3.zero;
            BtnGuo.transform.DOScale(1, 0.3f);
        }
    }
Beispiel #2
0
 public void HandOutCard(Battle battle)
 {
     SynchronousData(battle);
     if (BattleAIClient.SendServerCommand.UserID != battle.CurrentSide.AccountID)
     {
         return;
     }
     LogHelper.DebugLog("随机时间回调:" + BattleAIClient.SendServerCommand.UserID);
     Task.Factory.StartNew(() =>
     {
         Sleep();
         OneSide oneSide = battle.Sides.FirstOrDefault(c => c.AccountID == BattleAIClient.SendServerCommand.UserID);
         List <WinCardModel> winCardModels = WinALG.Win(oneSide.Cards, true);
         if (winCardModels.Count > 0)
         {
             BattleAIClient.SendServerCommand.HandOutCardBack(false, CardType.Tiao, 0, 0);
         }
         else
         {
             Card card = ChessHelper.GetRecommendOutCard(oneSide.Cards);
             BattleAIClient.SendServerCommand.HandOutCardBack(true, card.Type, card.Num, card.ID);
         }
     });
 }
Beispiel #3
0
        private bool IsWin(OneSide oneSide, bool isZiMo, Card touchCard)
        {
            List <Card> cards = new List <Card>(oneSide.Cards);

            if (touchCard != null)
            {
                cards.Add(touchCard);
            }
            List <WinCardModel> winCardModelList    = WinALG.Win(cards, isZiMo);
            WinCardModel        maxTrunWinCardModel = null;
            int maxTrun = 0;

            foreach (var m in winCardModelList)
            {
                if (touchCard != null)
                {
                    if (m.IsDaDui() == 0)
                    {
                        continue;
                    }
                }
                if (maxTrunWinCardModel == null)
                {
                    maxTrunWinCardModel = m;
                    maxTrun             = m.GetTurnNum();
                }
                else
                {
                    int mTrun = m.GetTurnNum();
                    if (mTrun > maxTrun)
                    {
                        maxTrunWinCardModel = m;
                        maxTrun             = mTrun;
                    }
                }
            }
            if (maxTrunWinCardModel == null)
            {
                return(false);
            }
            Battle.WinCardModel = maxTrunWinCardModel.CardSectionList;
            Battle.WinTrun      = maxTrun;
            if (oneSide.OutCards.Count == 0)//起手抓14张牌就胡牌
            {
                Battle.WinTrun = 4;
            }
            //分数计算
            int score = (int)Math.Pow(2, Battle.WinTrun);
            //包炮
            bool oneBaoThree = false;

            if (!isZiMo && oneSide != Battle.CurrentSide)
            {
                if (CardLibrary.Count <= 8)
                {
                    oneBaoThree = true;
                }
            }

            oneSide.GetScore = score * 3;
            if (oneBaoThree)
            {
                foreach (var s in Battle.Sides)
                {
                    if (s == Battle.CurrentSide)
                    {
                        s.GetScore = -score * 3;
                    }
                }
            }
            else
            {
                foreach (var s in Battle.Sides)
                {
                    if (s != oneSide)
                    {
                        s.GetScore = -score;
                    }
                }
            }

            return(true);
        }