public override void RefreshEquipUp() { is_equipUp = false; is_equipDown = false; if (LocalPlayerManager.Instance.LocalActorAttribute.Vocation != this.use_job && this.use_job != 0) { return; } if (this.IsInEnableTime() == false) {//物品过期 is_equipUp = false; is_equipDown = false; return; } GoodsEquip equip = EquipHelper.GetInstallEquipByPos(this.EquipPos); if (equip == null) { is_equipUp = true; is_equipDown = false; return; } int this_equipRank = this.EquipRank; int equip_rank = equip.EquipRank; if (this_equipRank > equip_rank) { is_equipUp = true; } else if (this_equipRank < equip_rank) { is_equipDown = true; } }
/// <summary> /// 检查所有物品并自动出售 /// </summary> void CheckAllGoodsAndSellGoods() { // 需要批量出售的装备列表 List <ulong> equipListToSell = new List <ulong>(); equipListToSell.Clear(); foreach (Goods goods in ItemManager.Instance.BagGoodsOids.Values) { if (CheckCanSellGoods(goods) == true) { GoodsEquip goodsEquip = goods as GoodsEquip; if (goodsEquip != null) { equipListToSell.Add(goods.id); } else { // 非装备物品一个一个地出售 ItemManager.Instance.SellGoods(goods.id, (uint)goods.num); } } } // 装备可以多种装备批量出售 if (equipListToSell.Count > 0) { ItemManager.Instance.RecycleGoods(equipListToSell, 0); } mIsSellingGoods = true; }
/// <summary> /// </summary> /// <param name="goods"></param> /// <returns></returns> public new GoodsEquip Clone() { GoodsEquip equip = new GoodsEquip(this.type_idx, this.NetEquip); equip.id = this.id; equip.BasicAttrs = this.BasicAttrs; equip.LegendAttrs = this.LegendAttrs; equip.StrenghtLv = this.StrenghtLv; equip.ExtraAttrs = this.ExtraAttrs; return(equip); }
/// <summary> /// 检查指定物品是否可以自动出售 /// </summary> /// <param name="goods"></param> bool CheckCanSellGoods(Goods goods) { if (goods == null) { return(false); } // 装备评分高于该部位已装备的评分则不出售 GoodsEquip goodsEquip = goods as GoodsEquip; if (goodsEquip != null) { List <GoodsEquip> installEquipList = xc.Equip.EquipHelper.GetInstallEquipListByPos(goodsEquip.EquipPos); if (installEquipList != null && installEquipList.Count > 0) { foreach (GoodsEquip installEquip in installEquipList) { if (goodsEquip.EquipRank >= installEquip.EquipRank) { return(false); } } } // 如果身上没有穿这个装备,则不出售 else { return(false); } } ulong oid = goods.id; uint goodsId = goods.type_idx; ulong num = goods.num; // 先判断是否是不需要出售的物品 foreach (HookGoodsSettingInfo hookGoodsSettingInfo in mDoNotAutoSellGoodsInfos.Values) { if (CheckMeetGoodsSettingInfoCondition(goodsId, hookGoodsSettingInfo, mDoNotAutoSellGoodsInfos, "do_not_auto_sell_goods") == true) { return(false); } } foreach (HookGoodsSettingInfo hookGoodsSettingInfo in mAutoSellGoodsInfos.Values) { if (CheckMeetGoodsSettingInfoCondition(goodsId, hookGoodsSettingInfo, mAutoSellGoodsInfos, "auto_sell_goods") == true) { return(true); } } return(false); }
/// <summary> /// 检查指定gid的物品是否可以自动出售,可以的话马上出售 /// </summary> void CheckAndSellGoods(Goods goods) { if (CheckCanSellGoods(goods) == true) { GoodsEquip goodsEquip = goods as GoodsEquip; // 如果是装备则发送回收协议 if (goodsEquip != null) { ItemManager.Instance.RecycleGoods(new List <ulong> { goods.id }, 0); } else { ItemManager.Instance.SellGoods(goods.id, (uint)goods.num); } mIsSellingGoods = true; } }
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); } } }
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); }