Esempio n. 1
0
        }                                                                   //奖励组

        public virtual void CreateGoodsByTypeId(uint _id)
        {
            this.type_idx = _id;
            var goods_info = GoodsHelper.GetGoodsInfo(_id);

            if (goods_info != null)
            {
                this.main_type = goods_info.type;
                this.SetIdFindData(_id);
            }
            else
            {
                GameDebug.LogWarning(string.Format("itme gid: {0} not exist", _id));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 根据TypeId返回默认Goods
        /// </summary>
        public virtual Goods SetIdFindData(uint _id)
        {
            this.type_idx = _id;

            var goods_info = GoodsHelper.GetGoodsInfo(_id);

            if (goods_info != null)
            {
                this.sub_type = goods_info.sub_type;
                this.effect   = goods_info.effect;
                this.mRawName = goods_info.name;
                this.name     = string.Format("{0}{1}</color>", GoodsHelper.GetGoodsColor(goods_info.color_type), goods_info.name);
                bool is_special_desc = false;
                if (goods_info.effect == "reward_group")//经验和金币类的礼包类的描述需要额外显示
                {
                    List <uint> reward_group_id_array = DBTextResource.ParseArrayUint(goods_info.arg);
                    if (reward_group_id_array != null)
                    {
                        DBRewardGroup db_reward_group = DBManager.Instance.GetDB <DBRewardGroup>();
                        for (int index = 0; index < reward_group_id_array.Count; ++index)
                        {
                            uint reward_group_id = reward_group_id_array[index];
                            DBRewardGroup.DBRewardGroupInfo group_info = db_reward_group.GetOneDBRewardGroupInfo(reward_group_id);
                            if (group_info != null &&
                                (group_info.IsCoinReward || group_info.IsExpReward))
                            {
                                m_group_info    = group_info;
                                is_special_desc = true;
                            }
                        }
                    }
                }
                else if (goods_info.effect == "add_lv_exp")//等级经验丹
                {
                    List <uint> arg_array = DBTextResource.ParseArrayUint(goods_info.arg, ",");
                    if (arg_array != null && arg_array.Count >= 2)
                    {
                        uint level     = arg_array[0]; //直接升级的等级
                        uint reward_id = arg_array[1]; //奖励ID
                        m_level_in_add_lv_exp = level;
                        DBRewardGroup.DBRewardGroupInfo group_info = new DBRewardGroup.DBRewardGroupInfo();
                        group_info.RewardId = reward_id;
                        if (group_info != null &&
                            (group_info.IsCoinReward || group_info.IsExpReward))
                        {
                            m_group_info    = group_info;
                            is_special_desc = true;
                        }
                    }
                }
                string des = goods_info.desc;
                this.src_description = goods_info.desc;
                if (des.CompareTo("") != 0 && is_special_desc == false)
                {
                    if (des[0] == '"')
                    {
                        this.description = des.Substring(1, des.Length - 2);
                    }
                    else
                    {
                        this.description = des;
                    }
                }

                this.arg          = goods_info.arg;
                this.use_lv       = goods_info.use_lv;
                this.use_job      = goods_info.use_job;
                this.use_transfer = goods_info.use_transfer;
                this.gain_text    = goods_info.gain_text;
                this.cd_id        = goods_info.cd_id;
                this.is_mutil_use = goods_info.is_mutil_use == 1 ? true : false;
                this.gain_from    = goods_info.gain_from;
                uint is_quick_int = goods_info.is_quick;
                if (is_quick_int == 0)
                {
                    this.is_quickuse = false;
                }
                else
                {
                    this.is_quickuse = true;
                }

                if (is_quick_int == 2)
                {
                    this.is_quickuse_autoUse = true;
                }
                else
                {
                    this.is_quickuse_autoUse = false;//是否快速使用(有倒计时)
                }
                if (is_quick_int == 3)
                {
                    this.is_quickuse_always = true;
                }
                else
                {
                    this.is_quickuse_always = false;
                }

                this.is_sell_confirmation = goods_info.is_confirmation == 1 ? true : false;
                this.client_use           = goods_info.client_use;
                //暂时没有子类型
                //this.sub_type = DBTextResource.ParseUI(data["sub_type"]);
                this.color_type    = goods_info.color_type;
                this.icon_id       = goods_info.icon_id;
                this.sort_id       = goods_info.sort_id;
                this.sort_top      = goods_info.sort_top;
                this.recycle_price = goods_info.sell_price;

                if (goods_info.is_show == 0)
                {
                    this.tips_show = false;
                }
                else
                {
                    this.tips_show = true;
                }

                this.price_recommend   = goods_info.price_recommend;
                this.price_lower_limit = goods_info.price_lower_limit;
                this.price_upper_limit = goods_info.price_upper_limit;
                this.mktype_1          = goods_info.mktype_1;
                this.mktype_2          = goods_info.mktype_2;
                this.daily_use_limit   = goods_info.daily_use_limit;
                this.guild_wpoint      = goods_info.guild_wpoint;
                this.max_stack         = goods_info.max_stack;
                this.is_display_goods  = goods_info.is_display_goods == 1;
                this.show_step         = goods_info.show_step;
                uint tmpl_is_bind = goods_info.bind;
                if (tmpl_is_bind == 1)
                {
                    mGoodsTmplIsBind = true;
                }
                this.bind                = tmpl_is_bind;
                this.wing_exp            = goods_info.wing_exp;
                this.expire_time_inTmpl  = goods_info.expire_time;
                this.is_precious         = goods_info.is_precious;
                this.discount            = goods_info.discount;
                this.overdue_notice_time = goods_info.overdue_notice_time;
            }
            return(this);
        }
Esempio n. 3
0
 public static void Update(Net.PkgGoodsInfo info, Goods goods)
 {
     if (info == null || goods == null)
     {
         return;
     }
     if (goods.type_idx != info.gid)
     {//更换了模型ID
         goods.type_idx = info.gid;
         var goods_info = GoodsHelper.GetGoodsInfo(info.gid);
         if (goods_info != null)
         {
             goods.main_type = goods_info.type;
             if (goods is GoodsItem)
             {
                 (goods as GoodsItem).SetIdFindData(info.gid);
             }
         }
     }
     goods.num         = info.num;
     goods.bind        = info.bind;
     goods.expire_time = info.expire_time;
     goods.create_time = info.create_time;
     if (info.equip != null) //代表它为装备
     {
         GoodsEquip equip = goods as GoodsEquip;
         if (equip != null)
         {
             equip.UpdateAttr(info.gid, info);
             equip.UpdateGem(info);
         }
     }
     else if (info.soul != null)
     {
         GoodsSoul soul = goods as GoodsSoul;
         if (soul != null)
         {
             soul.UpdateSoul(info.soul);
         }
     }
     else if (info.decorate != null)
     {
         GoodsDecorate decorate = goods as GoodsDecorate;
         if (decorate != null)
         {
             decorate.UpdateAttr(info.gid, info);
         }
     }
     else if (info.god_equip != null)
     {
         GoodsGodEquip godEquip = goods as GoodsGodEquip;
         if (godEquip != null)
         {
             godEquip.UpdateGodEquip(info.god_equip);
         }
     }
     else if (info.ride_equip != null)
     {
         //GoodsMountEquip mountEquip = goods as GoodsMountEquip;
         //if (mountEquip != null)
         //    mountEquip.UpdateMountEquip(info.ride_equip);
     }
     else if (info.magic_equip != null)
     {
         GoodsMagicEquip magicEquip = goods as GoodsMagicEquip;
         if (magicEquip != null)
         {
             magicEquip.UpdateMagicEquip(info.magic_equip);
         }
     }
 }
Esempio 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);
        }