コード例 #1
0
        public static void HandleServerData(ushort protocol, byte[] data)
        {
            switch (protocol)
            {
            case NetMsg.MSG_TALK_GOODS:
            {
                var msg   = Net.S2CPackBase.DeserializePack <Net.S2CTalkGoods>(data);
                var goods = GoodsFactory.Create(msg.goods.gid, msg.goods);
                if (goods == null)
                {
                    return;
                }

                string luaScript = GoodsHelper.GetGoodsLuaScriptByGoodsId(goods.type_idx);
                if (!string.IsNullOrEmpty(luaScript))
                {
                    return;
                }

                goods.id          = msg.goods.oid;
                goods.num         = msg.goods.num;
                goods.bind        = msg.goods.bind;
                goods.expire_time = msg.goods.expire_time;

                Net.PkgStrengthInfo pkgStrengthInfo = null;
                if (msg.strengths != null && msg.strengths.Count > 0)
                {
                    pkgStrengthInfo = msg.strengths[0];
                }

                Net.PkgBaptizeInfo pkgBaptizeInfo = null;
                if (msg.baptizes != null && msg.baptizes.Count > 0)
                {
                    pkgBaptizeInfo = msg.baptizes[0];
                }

                GoodsHelper.ShowGoodsTips(goods, pkgStrengthInfo, pkgBaptizeInfo);

                break;;
            }
            }
        }
コード例 #2
0
ファイル: Goods.cs プロジェクト: wuhuolong/MaxBooks
        public static Goods Create(uint mainType, uint typeId, Net.PkgGoodsInfo info)
        {
            Goods goods = null;

            switch (mainType)
            {
            case GameConst.GIVE_TYPE_EQUIP:
            {
                goods = new GoodsEquip(typeId, info);
                break;
            }

            case GameConst.GIVE_TYPE_SOUL:
            {
                goods = new GoodsSoul(typeId, info);
                break;
            }

            case GameConst.GIVE_TYPE_DECORATE:
            {
                goods = new GoodsDecorate(typeId, info);
                break;
            }

            case GameConst.GIVE_TYPE_GOD_EQUIP:
            {
                goods = new GoodsGodEquip(typeId, info);
                break;
            }

            case GameConst.GIVE_TYPE_RIDE_EQUIP:
            {
                goods = new GoodsMountEquip(typeId, info);
                break;
            }

            case GameConst.GIVE_TYPE_LIGHT_SOUL:
            {
                if (info != null)
                {
                    goods = new GoodsLightWeaponSoul(info);
                    break;
                }
                goods = new GoodsLightWeaponSoul(typeId);
                break;
            }

            case GameConst.GIVE_TYPE_MAGIC_EQUIP:
            {
                goods = new GoodsMagicEquip(typeId, info);
                break;
            }

            case GameConst.GIVE_TYPE_ARCHIVE:
            {
                if (info != null)
                {
                    goods = new GoodsItem(info)
                    {
                        bag_type = GameConst.BAG_TYPE_ARCHIVE
                    };
                }
                else
                {
                    goods = new GoodsItem(typeId)
                    {
                        bag_type = GameConst.BAG_TYPE_ARCHIVE
                    };
                }
                break;
            }

            default:
            {
                var goods_info = GoodsHelper.GetGoodsInfo(typeId);
                if (goods_info != null)
                {
                    string luaScript = GoodsHelper.GetGoodsLuaScriptByGoodsId(typeId);
                    if (!string.IsNullOrEmpty(luaScript))
                    {
                        if (LuaScriptMgr.Instance == null)
                        {
                            goods = new GoodsItem(typeId);
                        }
                        if (LuaScriptMgr.Instance.IsLuaScriptExist(luaScript))
                        {
                            goods = new GoodsLuaEx(typeId, luaScript);
                        }
                        else
                        {
                            Debug.LogWarning(string.Format("{0}未找到名字为的组件", luaScript));
                            goods = null;
                        }
                    }
                    else
                    {
                        if (info != null)
                        {
                            goods = new GoodsItem(info);
                            break;
                        }
                        goods = new GoodsItem(typeId);
                    }
                }
                break;
            }
            }
            if (goods == null)
            {//无法正常创建物品
                goods = GetDefaultGoods(typeId);
            }
            return(goods);
        }