Inheritance: xc.GoodsItem
Example #1
0
 public Goods Copy(GoodsLuaEx cp)
 {
     (this as GoodsItem).Copy(cp);
     mLuaTable = cp.mLuaTable;
     foreach(var item in cp.ExData)
     {
         ExData[item.Key] = item.Value;
     }
     if(LuaMethods == null)
         LuaMethods = new Dictionary<string, LuaFunction>();
     foreach (var item in cp.LuaMethods)
     {
         LuaMethods[item.Key] = item.Value;
     }
     return this;
 }
Example #2
0
        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);
        }