Beispiel #1
0
        protected virtual void AddCpg(CpgData data, int index = MiscUtility.DefInt)
        {
            if (null == data)
            {
                return;
            }
            var fromInt = data.GetFromChair();

            index = fromInt == -1 ? index : fromInt;
            MahjongCpg cpg = MahjongUtility.CreateCpg(data, index);

            CpgList.Add(cpg);
            cpg.transform.ExSetParent(transform);
        }
Beispiel #2
0
            public void SetData(ISFSObject data)
            {
                var db = GameCenter.DataCenter;

                db.CurrOpSeat = data.TryGetInt(RequestKey.KeySeat);
                GangBao       = data.ContainsKey("bao");
                CurrOpChair   = db.CurrOpChair;
                OldOpChair    = db.OldOpChair;
                CpgData       = MahjongUtility.CreateCpg(data);
                CpgData.Laizi = db.Game.LaiziCard; //cpg中有赖子牌,标记Icon
                CpgType       = CpgData.Type;
                db.Players[db.CurrOpChair].IsTuiDan = data.ContainsKey("tuidan");
                if (CpgType != EnGroupType.ZhuaGang && IsNotXjfdType(CpgType))
                {
                    //将cpg信息添加到玩家数据中
                    GameCenter.DataCenter.Players[CurrOpChair].CpgDatas.Add(CpgData);
                }

                CpgModel = new CpgModel(data);
            }
Beispiel #3
0
 protected virtual void SetZhuaGang(CpgData data)
 {
     if (null == data)
     {
         return;
     }
     for (int i = 0; i < CpgList.Count; i++)
     {
         MahjongCpg cpgPeng = CpgList[i];
         if (cpgPeng.Data.Type == EnGroupType.Peng && cpgPeng.Data.Card == data.Card)
         {
             //保存碰的位子
             Vector3 pengPos = cpgPeng.transform.localPosition;
             cpgPeng.OnReset();
             MahjongCpg cpgZhuaGang = MahjongUtility.CreateCpg(data, cpgPeng.AcrossIndex);
             cpgZhuaGang.transform.SetParent(transform);
             cpgZhuaGang.transform.localScale    = Vector3.one;
             cpgZhuaGang.transform.localPosition = pengPos;
             cpgZhuaGang.transform.localRotation = Quaternion.Euler(Vector3.zero);
             CpgList[i] = cpgZhuaGang;
             break;
         }
     }
 }
Beispiel #4
0
        public override void Parse(ISFSObject userData)
        {
            base.Parse(userData);
            IsReady = userData.GetBool(RequestKey.KeyState);
            IsAuto  = userData.TryGetBool(ProtocolKey.KeyTing);
            int num = userData.TryGetInt(ProtocolKey.KeyHardNum);

            //分数
            if (userData.ContainsKey(RequestKey.KeyGold))
            {
                CoinA += userData.GetLong(RequestKey.KeyGold);
            }
            //手牌
            UserHardCardNum = num > 0 ? num : 0;
            if (userData.ContainsKey(ProtocolKey.KeyHandCards))
            {
                int[] values = userData.GetIntArray(ProtocolKey.KeyHandCards);
                HardCards.Clear();
                HardCards.AddRange(values);
            }
            else
            {
                HardCards.Clear();
                HardCards.AddRange(new int[UserHardCardNum]);
            }
            //Cpg
            if (userData.ContainsKey(ProtocolKey.KeyMjGroup))
            {
                ISFSArray Groups = userData.GetSFSArray(ProtocolKey.KeyMjGroup);
                CpgDatas.Clear();
                for (int j = 0; j < Groups.Count; j++)
                {
                    var cpg = MahjongUtility.CreateCpg(Groups.GetSFSObject(j));
                    CpgDatas.Add(cpg);
                }
            }
            //出牌
            if (userData.ContainsKey(ProtocolKey.KeyOutCard))
            {
                int[] values = userData.GetIntArray(ProtocolKey.KeyOutCard);
                OutCards.Clear();
                OutCards.AddRange(values);
            }
            //补张
            if (userData.ContainsKey("buHua"))
            {
                BuzhangCards = userData.GetIntArray("buHua");
            }
            //听牌
            if (userData.ContainsKey("tingout"))
            {
                SetTinglist(userData.GetIntArray("tingout"));
            }
            //不带听玩法时候 tinglist
            if (userData.ContainsKey("tingoutlist"))
            {
                SetTinglist(userData.TryGetIntArray("tingoutlist"));
            }
            //Op
            if (userData.ContainsKey(ProtocolKey.KeyOp) && Chair == 0)
            {
                GameCenter.DataCenter.OperateMenu = userData.GetInt(ProtocolKey.KeyOp);
            }
            IsTuiDan = userData.ContainsKey("tuidan");
            //听
            IsAuto = userData.TryGetBool("hasTing");
            //vip权限
            VipUser = userData.TryGetBool("vipuser");
            //下注
            ScoreDouble = userData.TryGetInt("piao");
            //设置扩展类数据
            var extDatas = GameCenter.DataCenter.GetExtDataMap;

            if (extDatas.ContainsKey(RuntimeDataType.Players))
            {
                Type type = extDatas[RuntimeDataType.Players].GetType();
                ExtData = Activator.CreateInstance(type) as AbsDataExtension;
                if (null != ExtData)
                {
                    ExtData.SetData(userData, this);
                }
            }
            if (Chair == 0)
            {
                //根据server数据 指定杠牌
                var array = userData.TryGetIntArray("gangcard");
                if (array != null)
                {
                    GameCenter.DataCenter.GangCard.AddRange(array);
                }
            }
        }
        public void OnReconnect_Ccmj(ISFSObject data)
        {
            OnReconnect(data);
            MahjongUserInfo      userInfo;
            MahjongGroupsManager group   = Game.MahjongGroups;
            ISFSObject           cpgData = new SFSObject();

            for (int i = 0; i < DataCenter.MaxPlayerCount; i++)
            {
                userInfo = DataCenter.Players[i];
                var userData = userInfo.ExtData.Get <VarIsfsobject>("userdata");
                var user     = userData.GetValue <ISFSObject>();

                if (!user.ContainsKey("danlist"))
                {
                    continue;
                }
                var danList = user.GetSFSArray("danlist");
                for (int j = 0; j < danList.Count; j++)
                {
                    var   obj   = danList.GetSFSObject(j);
                    int[] cards = obj.GetIntArray("cards");
                    if (obj.ContainsKey("addDan"))
                    {
                        int[] add  = obj.GetIntArray("addDan");
                        int[] temp = new int[cards.Length + add.Length];
                        for (int k = 0; k < cards.Length; k++)
                        {
                            temp[k] = cards[k];
                        }
                        for (int k = 0; k < add.Length; k++)
                        {
                            temp[k + cards.Length] = add[k];
                        }
                        cards = temp;
                    }
                    int type = (int)EnGroupType.XiaoJi;
                    for (int k = 0; k < cards.Length; k++)
                    {
                        int card      = cards[k];
                        int checkType = CheckCardType(card);
                        if (checkType == (int)EnGroupType.XiaoJi)
                        {
                            if (k == cards.Length - 1)
                            {
                                type = (int)EnGroupType.YaoDan;
                            }
                            continue;
                        }
                        type = checkType;
                        break;
                    }
                    cpgData.PutInt(ProtocolKey.KeyTType, type);
                    cpgData.PutInt(RequestKey.KeySeat, userInfo.Seat);
                    cpgData.PutIntArray(RequestKey.KeyCards, cards);
                    group.PopMahFromCurrWall(cards.Length);
                    var xjfd = MahjongUtility.CreateCpg(cpgData);
                    userInfo.CpgDatas.Add(xjfd);
                    group.MahjongCpgs[userInfo.Chair].SetCpg(xjfd);
                }
            }
        }
Beispiel #6
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");
        }