Beispiel #1
0
        public override void OnLoadAssembly(Type type)
        {
            var atts = type.GetCustomAttributes(typeof(GameRuntimeDataAttribute), false);

            if (null == atts || atts.Length == 0)
            {
                return;
            }
            var dataAttri = atts[0] as GameRuntimeDataAttribute;
            var temp      = Activator.CreateInstance(type);

            if (temp is IRuntimeData)
            {
                IRuntimeData data = temp as IRuntimeData;
                mDataMap.Add(dataAttri.DataType, data);
            }
            for (int j = 0; j < atts.Length; j++)
            {
                dataAttri = atts[j] as GameRuntimeDataAttribute;
                if (temp is AbsDataExtension && dataAttri.GameKey.Equals(MahjongUtility.GameKey))
                {
                    AbsDataExtension data = temp as AbsDataExtension;
                    mExtDataMap.Add(dataAttri.DataType, data);
                }
            }
        }
Beispiel #2
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);
                }
            }
        }