Beispiel #1
0
        public void ShowDetail(MahjongResult result, int index)
        {
            gameObject.SetActive(true);
            for (int i = 0; i < mItems.Count; i++)
            {
                mItems[i].gameObject.SetActive(false);
            }

            Score.text      = result.Gold.ToString();
            PlayerName.text = result.Name;

            var list = result.Deatils;

            for (int i = 0; i < list.Count; i++)
            {
                var item = GetDetailItem(i);
                item.SetData(list[i]);
            }

            SetOffset(index);
        }
Beispiel #2
0
        /// <summary>
        /// 解析数据
        /// </summary>
        private void ParseData(ISFSObject data)
        {
            MahjongResult result;
            var           huSeats        = new List <int>();
            var           mahjongResults = new List <MahjongResult>();
            var           playersData    = data.GetSFSArray(RequestKey.KeyPlayerList);

            var players = DataCenter.Players;

            for (int i = 0; i < playersData.Count; i++)
            {
                result = new MahjongResult(i);
                var player = playersData.GetSFSObject(i);
                if (player.ContainsKey(RequestKey.KeyCardType))
                {
                    int type = player.GetInt(RequestKey.KeyCardType);
                    if (type >= 1)
                    {
                        result.HuFlag = true;
                        result.HuSeat = i;
                        huSeats.Add(i);
                    }
                    result.UserHuType = type;
                }
                result.PuGlod    = player.GetInt("pu");
                result.CType     = player.TryGetInt("ctype");
                result.HuCard    = player.TryGetInt("hucard");
                result.TotalGold = player.GetLong("ttgold");
                result.HuInfo    = player.TryGetString("hname");
                result.Gold      = player.TryGetInt(RequestKey.KeyGold);
                result.NiaoGold  = player.GetInt(ProtocolKey.KeyNiao);
                result.PiaoGlod  = player.GetInt(ProtocolKey.KeyPiao);
                result.GangGlod  = player.GetInt(ProtocolKey.KeyGGang);
                result.HuGold    = player.GetInt(ProtocolKey.KeyGHu) + player.TryGetInt(ProtocolKey.KeyGHua);
                mahjongResults.Add(result);
                //添加cpg数据
                ISFSArray Groups = player.TryGetSFSArray(ProtocolKey.KeyMjGroup);
                if (Groups != null)
                {
                    var playerData = players[result.Chair];
                    playerData.ClearCpgData();
                    for (int j = 0; j < Groups.Count; j++)
                    {
                        var cpg = MahjongUtility.CreateCpg(Groups.GetSFSObject(j));
                        playerData.AddCpgData(cpg);
                    }
                }
                //获取胡牌明细信息
                result.SetDeatil(player);
            }
            //更新手牌
            var cards = data.GetSFSArray(RequestKey.KeyCardsArr);

            for (int i = 0; i < cards.Count; i++)
            {
                var chair = MahjongUtility.GetChair(i);
                players[chair].HardCards = new List <int>(cards.GetIntArray(i));
                MahjongUtility.SortMahjong(players[chair].HardCards);
            }
            mArgs = new SingleResultArgs()
            {
                HuSeats = huSeats,
                Result  = mahjongResults,
                Bao     = data.TryGetInt("bao"),
                HuCard  = data.TryGetInt("huCard"),
                HuType  = data.TryGetInt(RequestKey.KeyType),
                PiaoHu  = data.ContainsKey(ProtocolKey.KeyPiaoHu),
                ZhongMa = data.TryGetIntArray(ProtocolKey.KeyZhongma),
                ZhaMa   = data.TryGetIntArray(ProtocolKey.KeyZhaNiao),
                ChBao   = data.TryGetInt(ProtocolKey.KeyChBao) == 1,
                MoBao   = data.TryGetInt(ProtocolKey.KeyMoBao) == 1,
            };
            //解析胡牌顺序
            if (data.ContainsKey("hushunxu"))
            {
                ISFSArray array = data.GetSFSArray("hushunxu");
                if (array != null)
                {
                    var huSort = new Dictionary <int, int>();
                    for (int i = 0; i < array.Count; i++)
                    {
                        int[] sfs = array.GetIntArray(i);
                        for (int j = 0; j < sfs.Length; j++)
                        {
                            int chair = MahjongUtility.GetChair(sfs[j]);
                            if (!huSort.ContainsKey(chair))
                            {
                                huSort.Add(chair, i);
                            }
                        }
                    }
                    mArgs.HuSort = huSort;
                }
            }
            mArgs.ResultType = mResultType;
            GameCenter.DataCenter.Game.BaoCard = mArgs.Bao;
            DataCenter.Room.NextBaner          = data.TryGetInt(ProtocolKey.KeyNextBanker);
            //清理麻将听标记
            GameCenter.Shortcuts.MahjongQuery.Do(p => p.ShowQueryTip(null));

            DataCenter.Game.Laozhuang = data.TryGetInt("lzcnt");
        }