Exemplo n.º 1
0
            public Dictionary <uint, List <GoodsItem> > CostGoodsList;                    // 锻造消耗GoodsItem

            /// <summary>
            /// 根据部位返回锻造消耗
            /// </summary>
            /// <param name="pos"></param>
            /// <returns></returns>
            public List <GoodsItem> GetCostGoods(uint pos)
            {
                if (CostGoodsList.ContainsKey(pos) == true)
                {
                    return(CostGoodsList[pos]);
                }
                else if (CostGoodsIdList.ContainsKey(pos) == true)
                {
                    List <KeyValuePair <uint, uint> > costGoodsIds = CostGoodsIdList[pos];
                    List <GoodsItem> goodsList = new List <GoodsItem>();
                    goodsList.Clear();
                    foreach (KeyValuePair <uint, uint> costGoodsId in costGoodsIds)
                    {
                        uint      goodsId = costGoodsId.Key;
                        uint      num     = costGoodsId.Value;
                        GoodsItem goods   = new GoodsItem(goodsId);
                        goods.num = num;
                        goodsList.Add(goods);
                    }

                    CostGoodsList.Add(pos, goodsList);
                    return(goodsList);
                }

                return(null);
            }
Exemplo n.º 2
0
        public static GoodsItem GetDefaultGoods(uint typeId)
        {
            GameDebug.LogError("return default goods! typeId = " + typeId);
            GoodsItem goods = new GoodsItem(DefaultGoodsId);

            goods.isDefaultGoods = true;
            goods.unknownGoodsId = typeId;
            return(goods);
        }
Exemplo n.º 3
0
 public Goods Clone()
 {
     if (pkgGoodsInfo != null)
     {
         return(new GoodsItem(pkgGoodsInfo));
     }
     else
     {
         var goods = new GoodsItem(type_idx);
         goods.id          = id;
         goods.bind        = bind;
         goods.num         = num;
         goods.expire_time = expire_time;
         return(goods);
     }
 }
Exemplo n.º 4
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);
        }