示例#1
0
        //是拍组是否同一花色
        public static bool isSameColor(PokerCard[] playerArray)
        {
            bool isRepeat = true;
            int[] array = new int[playerArray.Length];
            for (int i = 0; i < playerArray.Length; i++)
            {
                array[i] = int.Parse(playerArray[i].FrontSpriteName);
                if (array[i] == 52 || array[i] == 53)
                {
                    isRepeat = false;
                    return isRepeat;
                }
            }

            Array.Sort(array);

            if ((array[4] - array[0] <12) && (array[4] - (int)(array[4] % 13))== (array[1] - (int)(array[1] % 13)))
            {
                isRepeat = true;
                return isRepeat;
            }
            else
            {
                isRepeat = false;
                return isRepeat;
            }
        }
示例#2
0
 ////牌组是否有大小王
 public bool isHaveWangPoker(PokerCard []playerArray)
 {
     for (int i = 0; i < playerArray.Length; i++)
     {
         if (playerArray[i].FrontSpriteName.Equals("52")|| playerArray[i].FrontSpriteName.Equals("53"))
         {
             return true;
         }
     }
     return false;
 }
示例#3
0
        private void showPokerList(string cowPoints)
        {
            
            PokerCard[] p = new PokerCard[5];
            for (int i = 0; i < 5; i++)
            {
                p[i] = FourBullPlayerData.getInstance().playerPokerSet[3, i];
            }

            PokerStructInfo ps = FourBullLogic.getInstance().pokerPoints(p);
            if (ps.Points > 0)
            {
                int target = 1;
                for (int index = 0; index < 5; index++)
                {
                    if (index != ps.first && index != ps.second)
                    {
                        transform.FindChild("poker" + target).GetComponent<Image>().sprite = FourBull.PublicLoader.LoadCard(FourBullPlayerData.getInstance().playerPokerSet[3, index].FrontSpriteName);
                        target++;
                    }
                }
                transform.FindChild("poker" + 4).GetComponent<Image>().sprite = FourBull.PublicLoader.LoadCard(FourBullPlayerData.getInstance().playerPokerSet[3, ps.first].FrontSpriteName);
                transform.FindChild("poker" + 5).GetComponent<Image>().sprite = FourBull.PublicLoader.LoadCard(FourBullPlayerData.getInstance().playerPokerSet[3, ps.second].FrontSpriteName);
            }
            else
            {
                for (int index = 0; index < 5; index++)
                {
                    transform.FindChild("poker" + (index + 1)).GetComponent<Image>().sprite = FourBull.PublicLoader.LoadCard(FourBullPlayerData.getInstance().playerPokerSet[3, index].FrontSpriteName);
                }

            }

            //显示牛数
            Transform[] prefabSet = transform.FindChild("cowObject").GetComponentsInChildren<Transform>();
            for (int index = 0; index < prefabSet.Length; index++)
            {
                if (prefabSet[index].name.Equals(cowPoints))
                {
                    prefabSet[index].gameObject.SetActive(true);
                }
                else
                {
                    prefabSet[index].gameObject.SetActive(false);
                }
            }

            gameObject.SetActive(true);
        }
 public void showHandPoker()
 {
     //struct CMD_C_OxCard
     //{
     //    public byte bOX;                                //牛牛标志 
     //};
     PokerCard[,] pokerData = FourBullPlayerData.getInstance().playerPokerSet;
     PokerCard[] pokerArray = new PokerCard[5];
     for (int i = 0; i < 5; i++)
     {
         pokerArray[i] = pokerData[0, i];
     }
     PokerStructInfo result = FourBullLogic.getInstance().pokerPoints(pokerArray);
     CMD_C_OxCard cc = new CMD_C_OxCard();
     cc.bOX = (result.Points == -1) ? (byte)0 : (byte)1;
     FourBull.Messager.Broadcast(FourBullEvent.StopClock, 4);
     transform.FindChild("btnBluff").gameObject.SetActive(false);
     FourBullCommand.Instance.SendGamePacket<CMD_C_OxCard>((ushort)PROTOCOL_CLIENT.SUB_C_OPEN_CARD, cc);
 }
示例#5
0
        private void showPlayerCow(int serverPos)
        {
            PokerCard[,] pokerData = FourBullPlayerData.getInstance().playerPokerSet;
            PokerCard[] pokerArray = new PokerCard[5];
            for (int i = 0; i < 5; i++)
            {
                pokerArray[i] = pokerData[serverPos, i];
            }
            string cowPoints = FourBullLogic.getInstance().getPokerPoint(pokerArray);

            IPlayer down = FourBullCommand.Instance.GetPlayerByClientChairID((ushort)0);
            IPlayer right = FourBullCommand.Instance.GetPlayerByClientChairID((ushort)1);
            IPlayer top = FourBullCommand.Instance.GetPlayerByClientChairID((ushort)2);
            IPlayer left = FourBullCommand.Instance.GetPlayerByClientChairID((ushort)3);
            if (down != null &&  down.ChairID == serverPos)
            {
                //隐藏poker
                PlayerSet[0].gameObject.SetActive(false);
                //显示分组poker
                FourBull.Messager.Broadcast(FourBullEvent.showDownCow, cowPoints);
            }
            else if (right != null && right.ChairID == serverPos)
            {
                PlayerSet[1].gameObject.SetActive(false);
                FourBull.Messager.Broadcast(FourBullEvent.showRightCow, cowPoints);
            }
            else if (top != null && top.ChairID == serverPos)
            {
                PlayerSet[2].gameObject.SetActive(false);
                FourBull.Messager.Broadcast(FourBullEvent.showTopCow, cowPoints);
            }
            else if (left != null && left.ChairID == serverPos)
            {
                PlayerSet[3].gameObject.SetActive(false);
                FourBull.Messager.Broadcast(FourBullEvent.showLeftCow, cowPoints);
            }
        }
示例#6
0
        //牌组是否为炸弹
        public bool isBoom(PokerCard[] playerArray)
        {
            int[] array = new int[playerArray.Length];
            for (int i = 0; i < playerArray.Length; i++)
            {
                int num = int.Parse(playerArray[i].FrontSpriteName);
                if (num != 52 && num != 53)
                {
                    array[i] = (int)(num % 13) + 1;
                }
                else {
                    array[i] = num;
                }
            }

            Array.Sort(array);

            //有序数组,当arr[0] == arr[3] 或者 arr[1] == arr[4] 前四个数字或者后四个数字相等
            if (array[0] == array[3] || array[1] == array[4])
            {
                return true;
            }
            return false;
        }
示例#7
0
 //初始化数据
 public void initData(PokerCard[,]  playerData)
 {
     playerPokerSet = playerData;
 }
示例#8
0
        //是否为顺子
        public  bool isShunzi(PokerCard [] playerArray)
        {
            int[] array = new int[playerArray.Length];
            for (int i = 0; i < playerArray.Length; i++)
            {
                int num = int.Parse(playerArray[i].FrontSpriteName);
                if (num != 52 && num != 53)
                    array[i] = (int)(num % 13) + 1;
                else {
                    array[i] = num;
                }
            }
            //排序
            Array.Sort(array);
            //去重
            HashSet<string> ht = new HashSet<string>();
            for (int i = 0; i < 5; i++)
            {
                ht.Add(playerArray[i].FrontSpriteName);
            }

            if (Math.Abs(array[4] - array[0]) == 4 && ht.Count == 5)
            {
                return true;
            }
            return false;
        }
示例#9
0
 //得到拍组颜色
 public  string getPokerPoint(PokerCard[] playerArray)
 {
     int points = pokerPoints(playerArray).Points;
     // 当牌组中无大小王时
     if (!isHaveWangPoker(playerArray))
     {
         if (isBoom(playerArray) && points != -1)
         {
             return "niu_HuaZha"; // 花炸牛
         }
         else if (isSameColor(playerArray) && points != -1)
         {
             return "niu_Tonghua";//同花牛
         }
         else if (isShunzi(playerArray) && points != -1)
         {
             return "niu_Shunzi";//顺子牛
         }
         else
         {
             if (points == -1)
             {
                 return "niu_wu";//无牛
             }
             else
             {
                 if (points == 100)
                 {
                     return "niu_niu";//牛牛
                 }
                 else
                 {
                     return "niu_" + points.ToString();
                 }
             }
         }
     }
     else
     {
         if (isBoom(playerArray) && points != -1)
         {
             return "niu_HuaZha"; // 花炸牛
         }
         else
         {
             if (points == -1)
             {
                 return "niu_wu";//无牛
             }
             else
             {
                 if (points == 100)
                 {
                     return "niu_niu";//牛牛
                 }
                 else
                 {
                     return "niu_" + points.ToString();
                 }
             }
         }
     }
 }
示例#10
0
        //是否有牛
        internal PokerStructInfo pokerPoints(PokerCard [] playerArray)
        {
            PokerStructInfo ps = new PokerStructInfo();
            ps.Points = -1;
            ps.first = -1;
            ps.second = -1;
            //int Points;//算牛的点数
            //int first;//相应凑成牛点数的牌
            //int second;//
            int[] array = new int[playerArray.Length];
            for (int i = 0; i < playerArray.Length; i++)
            {
                int num = int.Parse(playerArray[i].FrontSpriteName);
                array[i] = (int)(num% 13)+1;
            }
            int totalPoints = 0;
            for (int i = 0; i < 5; i++)
            {
                //---------------------------------------------//
                if (array[i] > 10)
                {
                    array[i] = 10;
                }
                //---------------------------------------------//
                totalPoints = totalPoints + array[i];
            }

            for (int first = 0; first < 5; first++)
            {
                for (int second = 1; second < 5; second++)
                {
                    if (first != second)
                    {
                        int temp = totalPoints - array[first] - array[second];
                        if (temp % 10 == 0)
                        {
                            int points = array[first] + array[second];
                            if (points % 10 == 0)
                            {
                                ps.Points = 100;
                                ps.first = first;
                                ps.second = second;

                                return ps;
                            }
                            else
                            {
                                ps.Points = (array[first] + array[second]) % 10;
                                ps.first = first;
                                ps.second = second;
                                return ps;
                            }
                        }
                    }
                }
            }
            return ps;
        }
示例#11
0
        private void dealPoker(CMD_S_SendCard obj)
        {
            //CMD_S_SendCard
            //struct CMD_S_SendCard
            //{
            //    [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)PROTOCOL_PACKET.GAME_PLAYER)]
            //    public byte[][] cbCardData; //用户扑克 
            //    public ushort wPlayerCount;
            //};
            

            for (int i = 0; i < FourBullGlobalConst.pokerTotalCount; i++)
            {
                if (pokerPool != null && pokerPool[i] != null)
                {
                    pokerPool[i].SetActive(true);
                }
            }

            for (int i = 0; i < FourBullGlobalConst.pokerTotalCount; i++)
            {
                int tag = (int)(i % 5);
                int chairId = (int)FourBullCommand.Instance.SwitchViewChairID((ushort)(i/5));
                PokerCard pokerInfo = new PokerCard();
                pokerInfo.SetFront((int)(obj.cbCardData[i]));
                pokerInfoList[chairId,tag] = pokerInfo;
            }

            //将数据存储
            FourBullPlayerData.getInstance().initData(pokerInfoList);

            StartCoroutine(StartDealPoke());
            
        }