BagManager = {} local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local equipSign = ConfigManager.GetConfig(ConfigName.EquipSign) local this = BagManager this.bagDatas = {} --地图临时背包数据 this.mapShotTimeItemData = {} --天赋材料消耗组 this.tianFuMaterial = {} this.needEndingTime = 0 function this.Initialize() this.isBagPanel = false end --初始化背包数据 function this.InitBagData(_msgItemList) for i = 1, #_msgItemList do this.UpdateBagData(_msgItemList[i], true) end end --更新背包数据 function this.UpdateBagData(_itemData, isNoSendNewItemEvent) isNoSendNewItemEvent = isNoSendNewItemEvent or false local itemdata = {} --Log("_itemData.itemId -=-=-=-=-=-=-=-=-=-=-=-=-=-=- ".._itemData.itemId.." ".._itemData.itemNum) local _itemCfgData = itemConfig[_itemData.itemId] if _itemCfgData ~= nil then itemdata.itembackData = _itemData itemdata.itemConfig = _itemCfgData itemdata.id = _itemCfgData.Id itemdata.property = {} if _itemCfgData.ResourceID and _itemCfgData.ResourceID > 0 then itemdata.icon = GetResourcePath(_itemCfgData.ResourceID) else itemdata.icon = GetResourcePath(10002) end itemdata.quality = _itemCfgData.Quantity itemdata.frame = GetQuantityImageByquality(_itemCfgData.Quantity) itemdata.type = _itemCfgData.ItemBaseType itemdata.itemType = _itemCfgData.ItemType itemdata.isBag = _itemCfgData.BackpackOrNot itemdata.num = _itemData.itemNum itemdata.endingTime = _itemData.endingTime itemdata.nextFlushTime = _itemData.nextFlushTime if (itemdata.id == 54) then this.needEndingTime = itemdata.endingTime end if this.bagDatas[itemdata.id] == nil then this.bagDatas[itemdata.id] = itemdata if not isNoSendNewItemEvent then Game.GlobalEvent:DispatchEvent(GameEvent.Bag.GetNewItem, itemdata.id) end else this.bagDatas[itemdata.id].num = itemdata.num this.bagDatas[itemdata.id].endingTime = itemdata.endingTime this.bagDatas[itemdata.id].nextFlushTime = itemdata.nextFlushTime end end end ---英雄副本独用刷新 function this.UpDataBagItemIdNumber(_itemData) this.UpdateBagData(_itemData) Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) end --后端刷新 function this.BackDataRefreshEnerny(msgItemInfo) if msgItemInfo and #msgItemInfo > 0 then for i = 1, #msgItemInfo do if this.bagDatas[msgItemInfo[i].templateId] then this.bagDatas[msgItemInfo[i].templateId].num = msgItemInfo[i].overlap this.bagDatas[msgItemInfo[i].templateId].nextFlushTime = msgItemInfo[i].nextRefreshTime end end Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) end end --通过物品ID返回下次刷新时间(幸运探宝用) function this.GetNextRefreshTime(_itemId) if this.bagDatas[_itemId] then return this.bagDatas[_itemId].nextFlushTime end end --通过物品id获取物品数量 function this.GetItemCountById(_itemId) local have = 0 if this.bagDatas[_itemId] then have = this.bagDatas[_itemId].num end return have end -- 通过物品ID获得临时背包物品 function this.GetTempBagCountById(_itemId) if this.mapShotTimeItemData[_itemId] then return this.mapShotTimeItemData[_itemId].itemNum end return 0 end --通过物品Id获得临时背包物品的恢复时间 function this.GetItemRecoveryTime(_itemId) if this.bagDatas[_itemId] then return (AdventureManager.callAlianInvasionCountDownTime - (PlayerManager.serverTime - this.needEndingTime)) end end --临时背包 function this.DeleteTempBagCountById(_itemId, deleteNum) --if this.mapShotTimeItemData[_itemId] then -- if this.mapShotTimeItemData[_itemId].itemNum >= deleteNum then -- this.mapShotTimeItemData[_itemId].itemNum = this.mapShotTimeItemData[_itemId].itemNum - deleteNum -- else -- this.mapShotTimeItemData[_itemId] = nil -- end --end --Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged) end --英雄升级专用通过物品id更新物品数量 0 时删除 function this.HeroLvUpUpdateItemsNum(_itemId, deleteNum) if this.bagDatas[_itemId] then this.bagDatas[_itemId].num = this.bagDatas[_itemId].num - deleteNum Log("扣东西啦" .. _itemId .. " " .. deleteNum) if this.bagDatas[_itemId].num < 0 then this.bagDatas[_itemId].num = 0 Log("东西扣多了啦" .. _itemId .. " " .. deleteNum) end Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) else Log("扣了不存在的item" .. _itemId .. " " .. deleteNum) end end --通过物品id更新物品数量 0 时删除 function this.UpdateItemsNum(_itemId, deleteNum) --if _itemId == 2 then -- PlayerManager.PromoteLevel(deleteNum) --end --改为后端刷新了 但是体力得从这减 --if this.bagDatas[_itemId] then -- this.bagDatas[_itemId].num = this.bagDatas[_itemId].num - deleteNum -- if _itemId == 2 then -- PlayerManager.PromoteLevel(deleteNum) -- end -- Log("扣东西啦" .. _itemId .. " " .. deleteNum) -- if this.bagDatas[_itemId].num < 0 then -- this.bagDatas[_itemId].num = 0 -- Log("东西扣多了啦" .. _itemId .. " " .. deleteNum) -- end -- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) --else -- Log("扣了不存在的item" .. _itemId .. " " .. deleteNum) --end end -- 消耗背包物品,先消耗临时背包,再消耗总背包 function this.SpendBagItem(itemId, deleteNum) -- 当前临时背包数据 --if this.mapShotTimeItemData[itemId] then -- local tempBagNum = this.mapShotTimeItemData[itemId].itemNum -- if tempBagNum >= deleteNum then -- -- 临时背包数据充足 -- tempBagNum = tempBagNum - deleteNum -- -- 道具刚好消耗完 -- if tempBagNum == 0 then -- this.mapShotTimeItemData[itemId] = nil -- else -- this.mapShotTimeItemData[itemId].itemNum = tempBagNum -- end -- else -- -- 临时背包数量不充足 -- local leftNeed = deleteNum - this.mapShotTimeItemData[itemId].itemNum -- this.mapShotTimeItemData[itemId] = nil -- this.UpdateItemsNum(itemId, leftNeed) -- end --else -- -- 临时背包无此道具 -- this.UpdateItemsNum(itemId, deleteNum) --end end -- 获得临时背包和外部背包的总数量 function this.GetTotalItemNum(itemId) local totalnum = 0 if this.GetTempBagCountById(itemId) and this.GetItemCountById(itemId) then totalnum = this.GetTempBagCountById(itemId) + this.GetItemCountById(itemId) else if not this.GetTempBagCountById(itemId) or this.GetTempBagCountById(itemId) == 0 then totalnum = this.GetItemCountById(itemId) end end return totalnum end --增加体力 function this.UpdateAddTiliNum(addNum) if this.bagDatas[2] then this.bagDatas[2].num = this.bagDatas[2].num + addNum else local itemData = {} itemData.itemId = 2 itemData.itemNum = addNum this.UpdateBagData(itemData) end Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) end --获取所有背包物品 function this.GetBagItemData() local _index = 1 local _bagItemData = {} for i, v in pairs(this.bagDatas) do if v.isBag and v.num > 0 then _bagItemData[_index] = v _index = _index + 1 end end return _bagItemData end --通过背包物品品质获得物品list function this.GetBagItemDataByItemQuality(_itemQuality) local _bagItemData = this.GetBagItemData() local items = {} local index = 1 for i, v in pairs(_bagItemData) do if v.quality == _itemQuality and v.num > 0 then items[index] = v index = index + 1 end end return items end --获得背包所有可携带入地图的物品list function this.GetBagItemDataByItemMapIsShow() local items = {} local index = 1 for i, v in pairs(this.bagDatas) do if v.itemConfig.IsShow then if v.itemConfig.IsShow == 1 then local itemdata = {} itemdata.itemType = 1 -- 物品道具 itemdata.backData = v.itembackData itemdata.configData = v.itemConfig itemdata.name = v.itemConfig.Name itemdata.frame = GetQuantityImageByquality(v.itemConfig.Quantity) itemdata.icon = GetResourcePath(v.itemConfig.ResourceID) itemdata.num = v.num items[index] = itemdata index = index + 1 end end end return items end --通过物品类型获得物品list function this.GetBagItemDataByItemType(_itemType) local items = {} local index = 1 --LogError("_itemType ".._itemType) for i, v in pairs(this.bagDatas) do --LogError(v.itemConfig.Name.." ".._itemType.." "..v.type.." "..v.num) if v.type == _itemType and v.num > 0 and v.itemConfig.BackpackOrNot then items[index] = v index = index + 1 end end return items end --工坊 通过装备品质获得该品质所有符文list function this.GetBagItemDataByQuDownAll(_itemType, fuwenQuality) local _bagItemData = BagManager.GetBagItemData() local items = {} local index = 1 for i, v in pairs(_bagItemData) do if v.itemType == _itemType then if v.quality == fuwenQuality then items[index] = v index = index + 1 end end end return items end --地图临时背包数据存储 function this.InitMapShotTimeBagData(_mapItem) local singleitemdata = {} local _itemCfgData = itemConfig[_mapItem.itemId] if _itemCfgData ~= nil then singleitemdata.backData = _mapItem singleitemdata.itemId = _mapItem.itemId singleitemdata.itemNum = _mapItem.itemNum singleitemdata.isSave = _itemCfgData.IsSave if this.mapShotTimeItemData[singleitemdata.itemId] == nil then this.mapShotTimeItemData[singleitemdata.itemId] = singleitemdata else this.mapShotTimeItemData[singleitemdata.itemId].itemNum = singleitemdata.itemNum-- this.mapShotTimeItemData[singleitemdata.itemId].itemNum + singleitemdata.itemNum end if _mapItem.itemId == 43 then -- 是炸弹 this.mapShotTimeItemData[singleitemdata.itemId].itemNum = this.mapShotTimeItemData[singleitemdata.itemId].itemNum >= 3 and 3 or this.mapShotTimeItemData[singleitemdata.itemId].itemNum end end Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnTempBagChanged) end --通过物品id获取地图临时背包物品数量 function this.GetMapBagItemCountById(_itemId) --Log(_itemId) if this.mapShotTimeItemData[_itemId] then return this.mapShotTimeItemData[_itemId].itemNum end return 0 end --把地图临时背包物品数量加成到背包中 function this.InBagGetMapBag() --for i, v in pairs(this.mapShotTimeItemData) do -- if v.isSave then -- if v.isSave == 1 then -- this.UpdateBagData(v) -- end -- end --end for i, v in pairs(EquipManager.mapShotTimeItemData) do EquipManager.UpdateEquipData(v) end for i, v in pairs(HeroManager.mapShotTimeItemData) do HeroManager.UpdateHeroDatas(v) end for i, v in pairs(TalismanManager.mapShotTimeItemData) do TalismanManager.InitUpdateSingleTalismanData(v) end --SoulPrintManager.InitServerData(SoulPrintManager.mapShotTimeItemData) EquipTreasureManager.InitAllEquipTreasure(SoulPrintManager.mapShotTimeItemData) this.mapShotTimeItemData = {} EquipManager.mapShotTimeItemData = {} HeroManager.mapShotTimeItemData = {} TalismanManager.mapShotTimeItemData = {} SoulPrintManager.mapShotTimeItemData = {} Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) end function this.OnShowTipDropNumZero(drop) local addMaxNumItemNameList = "" if drop.itemlist ~= nil and #drop.itemlist > 0 then for i = 1, #drop.itemlist do if drop.itemlist[i].itemNum <= 0 then Log("后端穿数量为零 所以弹板提示 " .. itemConfig[drop.itemlist[i].itemId].Name) if addMaxNumItemNameList == "" then addMaxNumItemNameList = itemConfig[drop.itemlist[i].itemId].Name else addMaxNumItemNameList = addMaxNumItemNameList .. "、" .. itemConfig[drop.itemlist[i].itemId].Name end end end end if addMaxNumItemNameList and addMaxNumItemNameList ~= "" then MsgPanel.ShowOne("下列道具已达存储上限,额外获取的部分将无法获得:" .. addMaxNumItemNameList) end end --服务器掉落物品直接进背包 function this.GoIntoBackData(drop) if (#drop.itemlist > 0) then --BagManager.UpDataBagItemIdNumber(drop.itemlist) --Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) end if (#drop.equipId > 0) then for i = 1, #drop.equipId do EquipManager.UpdateEquipData(drop.equipId[i]) end --在关卡界面获得装备 刷新下btview成员红点 Game.GlobalEvent:DispatchEvent(GameEvent.Equip.EquipChange) end if (#drop.Hero > 0) then for i = 1, #drop.Hero do HeroManager.UpdateHeroDatas(drop.Hero[i]) end end -- if (#drop.especialEquipId > 0) then -- for i = 1, #drop.especialEquipId do -- TalismanManager.InitUpdateSingleTalismanData(drop.especialEquipId[i]) -- end -- end if (#drop.soulEquip > 0) then --SoulPrintManager.InitServerData(drop.soulEquip) EquipTreasureManager.InitAllEquipTreasure(drop.soulEquip) end end function this.GMCallBackData(drop) --for i = 1, #drop.itemlist do -- BagManager.UpdateBagData(drop.itemlist[i]) --end if drop.equipId and #drop.equipId > 0 then for i = 1, #drop.equipId do EquipManager.UpdateEquipData(drop.equipId[i]) end end if drop.Hero and #drop.Hero > 0 then for i = 1, #drop.Hero do HeroManager.UpdateHeroDatas(drop.Hero[i]) end end -- if drop.especialEquipId and #drop.especialEquipId > 0 then -- for i = 1, #drop.especialEquipId do -- TalismanManager.InitUpdateSingleTalismanData(drop.especialEquipId[i]) -- end -- end if (#drop.soulEquip > 0) then --SoulPrintManager.InitServerData(drop.soulEquip) EquipTreasureManager.InitAllEquipTreasure(drop.soulEquip) end end --将后端drop转为前端table function this.GetTableByBackDropData(drop) local itemDataList = {} if drop.itemlist ~= nil and #drop.itemlist > 0 then Log("drop.itemlist " .. #drop.itemlist) for i = 1, #drop.itemlist do local itemdata = {} itemdata.itemType = 1--item itemdata.sId = drop.itemlist[i].itemId itemdata.backData = drop.itemlist[i] itemdata.configData = itemConfig[drop.itemlist[i].itemId] itemdata.name = itemdata.configData.Name itemdata.frame = GetQuantityImageByquality(itemdata.configData.Quantity) itemdata.icon = GetResourcePath(itemdata.configData.ResourceID) itemdata.num = drop.itemlist[i].itemNum table.insert(itemDataList, itemdata) --BagManager.UpdateBagData(itemdata.backData) end end if drop.equipId ~= nil and #drop.equipId > 0 then Log("drop.equipId " .. #drop.equipId) for i = 1, #drop.equipId do local itemdata = {} itemdata.itemType = 2--装备 itemdata.sId = drop.equipId[i].equipId itemdata.backData = drop.equipId[i] itemdata.configData = itemConfig[drop.equipId[i].equipId] itemdata.name = itemdata.configData.Name itemdata.frame = GetQuantityImageByquality(itemdata.configData.Quantity) itemdata.icon = GetResourcePath(itemdata.configData.ResourceID) itemdata.num = 1 table.insert(itemDataList, itemdata) EquipManager.UpdateEquipData(itemdata.backData) end end if drop.Hero ~= nil and #drop.Hero > 0 then Log("drop.Hero " .. #drop.Hero) for i = 1, #drop.Hero do local itemdata = {} itemdata.itemType = 3--英雄 itemdata.sId = drop.Hero[i].heroId itemdata.backData = drop.Hero[i] itemdata.configData = ConfigManager.GetConfigData(ConfigName.HeroConfig, drop.Hero[i].heroId) itemdata.name = itemdata.configData.ReadingName itemdata.frame = GetHeroQuantityImageByquality(itemdata.configData.Quality) itemdata.icon = GetResourcePath(itemdata.configData.Icon) itemdata.num = 1 table.insert(itemDataList, itemdata) HeroManager.UpdateHeroDatas(itemdata.backData) end end -- if drop.especialEquipId ~= nil and #drop.especialEquipId > 0 then -- Log("drop.especialEquipId " .. #drop.especialEquipId) -- for i = 1, #drop.especialEquipId do -- local itemdata = {} -- itemdata.itemType = 4--法宝 -- itemdata.sId = drop.especialEquipId[i].equipId -- itemdata.backData = drop.especialEquipId[i] -- itemdata.configData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", drop.especialEquipId[i].equipId, "Level", drop.especialEquipId[i].rebuildLevel) -- itemdata.name = itemdata.configData.Name -- local itemConfig = itemConfig[drop.especialEquipId[i].equipId] -- itemdata.frame = GetHeroQuantityImageByquality(itemConfig.Quantity) -- itemdata.icon = GetResourcePath(itemConfig.ResourceID) -- itemdata.num = 1 -- table.insert(itemDataList, itemdata) -- TalismanManager.InitUpdateSingleTalismanData(itemdata.backData) -- end -- end if drop.soulEquip ~= nil and #drop.soulEquip > 0 then Log("drop.especialEquipId " .. #drop.soulEquip) for i = 1, #drop.soulEquip do local itemdata = {} itemdata.itemType = 5--魂印 itemdata.sId = drop.soulEquip[i].equipId itemdata.backData = drop.soulEquip[i] SoulPrintManager.UpSoulPrintLevel(drop.soulEquip[i].equipId, drop.soulEquip[i].exp) itemdata.level = SoulPrintManager.soulPrintLevel[drop.soulEquip[i].equipId] this.GetSoulPrintId(drop.soulEquip[i].equipId, itemdata.level) itemdata.configData = ConfigManager.GetConfigData(ConfigName.EquipSign, drop.soulEquip[i].id) itemdata.name = itemdata.configData.Name local itemConfig = itemConfig[drop.soulEquip[i].id] itemdata.frame = GetHeroQuantityImageByquality(itemConfig.Quantity) itemdata.icon = GetResourcePath(itemConfig.ResourceID) itemdata.num = 1 table.insert(itemDataList, itemdata) --SoulPrintManager.InitServerData(drop.soulEquip) EquipTreasureManager.InitAllEquipTreasure(drop.soulEquip) --TalismanManager.InitUpdateSingleTalismanData(itemdata.backData) end end Game.GlobalEvent:DispatchEvent(GameEvent.Bag.BagGold) return itemDataList end -- 将drop的数据解析存进临时背包, isSave 为true 为保存进临时背包 function this.GetItemListFromTempBag(drop, isSave) local itemDataList = {} if drop.itemlist ~= nil and #drop.itemlist > 0 then Log("掉落道具数量 " .. #drop.itemlist) for i = 1, #drop.itemlist do local itemdata = {} itemdata.itemType = 1--item itemdata.sId = drop.itemlist[i].itemId itemdata.backData = drop.itemlist[i] itemdata.configData = itemConfig[drop.itemlist[i].itemId] itemdata.name = itemdata.configData.Name itemdata.frame = GetQuantityImageByquality(itemdata.configData.Quantity) itemdata.icon = GetResourcePath(itemdata.configData.ResourceID) itemdata.num = drop.itemlist[i].itemNum table.insert(itemDataList, itemdata) end end if drop.equipId ~= nil and #drop.equipId > 0 then for i = 1, #drop.equipId do local itemdata = {} itemdata.itemType = 2--装备 itemdata.sId = drop.equipId[i].equipId itemdata.backData = drop.equipId[i] itemdata.configData = itemConfig[drop.equipId[i].equipId] Log("战斗结算掉落装备ID是 drop.equipId[i].equipId" .. drop.equipId[i].equipId) itemdata.name = itemdata.configData.Name itemdata.frame = GetQuantityImageByquality(itemdata.configData.Quantity) itemdata.icon = GetResourcePath(itemdata.configData.ResourceID) itemdata.num = 1 table.insert(itemDataList, itemdata) if isSave then EquipManager.InitMapShotTimeEquipBagData(itemdata.backData) end end end if drop.Hero ~= nil and #drop.Hero > 0 then for i = 1, #drop.Hero do local itemdata = {} itemdata.itemType = 3--英雄 itemdata.sId =drop.Hero[i].heroId itemdata.backData = drop.Hero[i] itemdata.configData = ConfigManager.GetConfigData(ConfigName.HeroConfig, drop.Hero[i].heroId) itemdata.name = itemdata.configData.ReadingName itemdata.frame = GetHeroQuantityImageByquality(itemdata.configData.Quality) itemdata.icon = GetResourcePath(itemdata.configData.Icon) itemdata.num = 1 table.insert(itemDataList, itemdata) if isSave then HeroManager.InitMapShotTimeHeroBagData(itemdata.backData) end end end -- if drop.especialEquipId ~= nil and #drop.especialEquipId > 0 then -- Log("drop.especialEquipId " .. #drop.especialEquipId) -- for i = 1, #drop.especialEquipId do -- local itemdata = {} -- itemdata.itemType = 4--法宝 -- itemdata.sId =drop.especialEquipId[i].equipId -- itemdata.backData = drop.especialEquipId[i] -- itemdata.configData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", drop.especialEquipId[i].equipId, "Level", drop.especialEquipId[i].rebuildLevel) -- itemdata.name = itemdata.configData.Name -- local itemConfig = itemConfig[drop.especialEquipId[i].equipId] -- itemdata.frame = GetHeroQuantityImageByquality(itemConfig.Quantity) -- itemdata.icon = GetResourcePath(itemConfig.ResourceID) -- itemdata.num = 1 -- table.insert(itemDataList, itemdata) -- if isSave then -- TalismanManager.InitUpdateSingleTalismanData(itemdata.backData) -- end -- end -- end if drop.soulEquip ~= nil and #drop.soulEquip > 0 then Log("drop.especialEquipId " .. #drop.soulEquip) for i = 1, #drop.soulEquip do local itemdata = {} itemdata.itemType = 5--魂印 itemdata.sId = drop.soulEquip[i].equipId itemdata.backData = drop.soulEquip[i] itemdata.data=drop.soulEquip itemdata.lv=drop.soulEquip[i].exp itemdata.refineLv=drop.soulEquip[i].rebuildLevel --SoulPrintManager.UpSoulPrintLevel(drop.soulEquip[i].equipId, drop.soulEquip[i].exp) --itemdata.level = SoulPrintManager.soulPrintLevel[drop.soulEquip[i].equipId] --local id = SoulPrintManager.GetSoulPrintId(drop.soulEquip[i].equipId, itemdata.level) itemdata.configData = ConfigManager.GetConfigData(ConfigName.ItemConfig,itemdata.sId)--ConfigManager.GetConfigData(ConfigName.EquipSign, id) itemdata.name = itemdata.configData.Name local itemConfig = itemConfig[drop.soulEquip[i].equipId] itemdata.itemConfig=itemConfig[drop.soulEquip[i].equipId] itemdata.frame = GetHeroQuantityImageByquality(itemConfig.Quantity) itemdata.icon = GetResourcePath(itemConfig.ResourceID) itemdata.num = 1 itemdata.id=drop.soulEquip[i].id table.insert(itemDataList, itemdata) if isSave then --SoulPrintManager.InitMapShotTimeSoulPrintBagData(itemdata.backData) end end end return itemDataList end -- 返回所有临时背包的数据 function this.GetAllTempBagData() local mapItemList = {} -- 临时背包所有显示用的道具 local itemList = BagManager.mapShotTimeItemData local equipList = EquipManager.mapShotTimeItemData local heroList = HeroManager.mapShotTimeItemData local talismanList = TalismanManager.mapShotTimeItemData local soulPrintList = SoulPrintManager.mapShotTimeItemData for i, v in pairs(itemList) do local itemdata = {} itemdata.itemType = 1 -- 物品道具 itemdata.sId = v.itemId itemdata.backData = v itemdata.configData = itemConfig[v.itemId] itemdata.name = itemdata.configData.Name itemdata.frame = GetQuantityImageByquality(itemdata.configData.Quantity) itemdata.Quantity = itemdata.configData.Quantity itemdata.icon = GetResourcePath(itemdata.configData.ResourceID) itemdata.num = v.itemNum Log("道具" .. v.itemNum) mapItemList[#mapItemList + 1] = itemdata end for i, v in pairs(equipList) do local itemdata = {} itemdata.itemType = 2--装备 itemdata.sId = v.equipId itemdata.backData = v itemdata.configData = itemConfig[v.equipId] itemdata.name = itemdata.configData.Name itemdata.frame = GetQuantityImageByquality(itemdata.configData.Quantity) itemdata.Quantity = itemdata.configData.Quantity itemdata.icon = GetResourcePath(itemdata.configData.ResourceID) itemdata.num = 1 mapItemList[#mapItemList + 1] = itemdata end for i, v in pairs(heroList) do local itemdata = {} itemdata.itemType = 3--英雄 itemdata.sId = v.heroId itemdata.backData = v itemdata.configData = ConfigManager.GetConfigData(ConfigName.HeroConfig, v.heroId) itemdata.name = itemdata.configData.Name itemdata.frame = GetHeroQuantityImageByquality(itemdata.configData.Quality) itemdata.Quantity = itemdata.configData.Star itemdata.icon = GetResourcePath(itemdata.configData.Icon) itemdata.num = 1 mapItemList[#mapItemList + 1] = itemdata end for i, v in pairs(talismanList) do local itemdata = {} itemdata.itemType = 4--法宝 itemdata.sId = v.equipId itemdata.backData = v itemdata.configData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", v.equipId, "Level", v.rebuildLevel) itemdata.name = itemdata.configData.ReadingName local itemConfig = itemConfig[v.equipId] itemdata.frame = GetHeroQuantityImageByquality(itemConfig.Quantity) itemdata.Quantity = itemConfig.Quantity itemdata.icon = GetResourcePath(itemConfig.ResourceID) itemdata.num = 1 mapItemList[#mapItemList + 1] = itemdata end for i, v in pairs(soulPrintList) do local itemdata = {} itemdata.itemType = 5--魂印 itemdata.sId = v.equipId itemdata.backData = v SoulPrintManager.UpSoulPrintLevel(v.equipId, v.exp) itemdata.level = SoulPrintManager.soulPrintLevel[v.equipId] local id = SoulPrintManager.GetSoulPrintId(v.equipId, itemdata.level) itemdata.configData = ConfigManager.GetConfigData(ConfigName.EquipSign, id) itemdata.name = itemdata.configData.Name local itemConfig = itemConfig[v.equipId] itemdata.frame = GetHeroQuantityImageByquality(itemConfig.Quantity) itemdata.Quantity = itemConfig.Quantity itemdata.icon = GetResourcePath(itemConfig.ResourceID) itemdata.num = 1 mapItemList[#mapItemList + 1] = itemdata --SoulPrintManager.InitServerData(soulPrintList.soulEquip) --TalismanManager.InitUpdateSingleTalismanData(itemdata.backData) end -- 先类型后品质 if #mapItemList > 1 then table.sort(mapItemList, function (a, b) if a.itemType == b.itemType then return a.Quantity > b.Quantity else return a.itemType < b.itemType end end) end return mapItemList end --设置背包物品红点 function this.SetItemNewRewPooint() for i, v in pairs(this.bagDatas) do if v.isNewRewPoint then v.isNewRewPoint = false RedPointManager.PlayerPrefsSetStrItemId(v.id, 1) end end end --是否有可合成碎片 function this.GetBagRedPointIsCanCompoundDebris() for i, v in pairs(this.bagDatas) do if v.itemType == ItemType.HeroDebris then local curExpVal = BagManager.GetItemCountById(v.id) / v.itemConfig.UsePerCount if curExpVal >= 1 then return true end end end return false end --是否有宝箱 和 可使用蓝图 function this.GetBagRedPointIsCanOpenBoxAndBlueprint() for i, v in pairs(this.bagDatas) do if v.itemType == ItemType.Box and v.num > 0 and v.itemConfig.BackpackOrNot then --宝箱 return true end if v.itemType == ItemType.Blueprint then --蓝图 local lanTuData = WorkShopManager.GetLanTuIsOpenLock(v.id) if lanTuData and v.num > 0 and lanTuData[1] == false then return true end end end return false end --获取该类型的所有背包数据 function this.GetBagAllDataByItemType(ItemType) local thisItemTypeAllDatas = {} for i, v in pairs(this.bagDatas) do if v.itemType == ItemType then table.insert(thisItemTypeAllDatas,v) end end return thisItemTypeAllDatas end return this