require("Base/BasePanel") BagPanel = Inherit(BasePanel) local this = BagPanel local sortIndex = 0 local sortIndexBtnGo local tabs1 = {} local tabs1RedPoint = {} local itemData = {} this.isFristOpen = true local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig) local isFristOpenTime = Timer.New() local orginLayer=0--层级 local list={} local ImgList = { [ItemBaseType.Equip] = "r_chushou_zh", [ItemBaseType.SoulPrint] = "r_fenjie_zh", [ItemBaseType.EquipTreasure] = "r_fenjie_zh", [ItemBaseType.GodPrint] = "r_fenjie_zh", } --初始化组件(用于子类重写) function BagPanel:InitComponent() this.spLoader = SpriteLoader.New() this.BtnBack = Util.GetGameObject(self.transform, "rightUp/btnBack") this.tabBox = Util.GetGameObject(self.transform, "Grid/box") for i = 1, 11 do tabs1[i] = Util.GetGameObject(self.transform, "Grid/box/Btn" .. i) tabs1RedPoint[i] = Util.GetGameObject(self.transform, "Grid/box/Btn" .. i .. "/redPoint") tabs1[i]:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_xuanze_002") end if not this.playerInfoView then this.playerInfoView = SubUIManager.Open(SubUIConfig.PlayerInfoView, this.transform) end this.selectBtn1 = Util.GetGameObject(self.gameObject, "selectBtn") this.selectBtn1:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_xuanze_001") this.BtView = SubUIManager.Open(SubUIConfig.BtView, self.gameObject.transform) this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform) this.fenJieBtn = Util.GetGameObject(self.gameObject, "fenJieBtn") this.oneKey = Util.GetGameObject(self.gameObject, "onekey") this.itemNumText = Util.GetGameObject(self.gameObject, "itemNumText") this.ItemView = Util.GetGameObject(self.gameObject, "ItemView") this.ItemViewEffect = Util.GetGameObject(self.gameObject, "ItemView/GameObject/effects") this.item = Util.GetGameObject(self.gameObject, "Item") this.grid = Util.GetGameObject(self.gameObject, "scroll/grid") this.Scrollbar = Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar") this.isBagPanel = true this.EffectOrginLayer = 0 this.mask = Util.GetGameObject(self.gameObject, "mask") this.tabsBtn = Util.GetGameObject(self.gameObject, "tabsBtn") this.tabs = Util.GetGameObject(self.gameObject, "tabs") this.tabs.transform.anchoredPosition = Vector2.New(0,-130) this.tabs:SetActive(false) this.tabsList = {} this.selectImg = {} for i = 1, 5 do this.tabsList[i] = Util.GetGameObject(this.tabs, "btnHeroGrid/Btn"..i-1) this.selectImg[i] = Util.GetGameObject(this.tabsList[i], "selectBtn") this.selectImg[i]:SetActive(false) end this.selectImg[1]:SetActive(true) --无信息图片 this.noneImage=Util.GetGameObject(self.gameObject,"NoneImage") this.noneTxt=Util.GetGameObject(self.gameObject,"NoneImage/TextImage/Text"):GetComponent("Text") this.noneBtn=Util.GetGameObject(self.gameObject,"NoneImage/TextImage") end --绑定事件(用于子类重写) function BagPanel:BindEvent() Util.AddClick(this.BtnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) self:ClosePanel() end) for i = 1, 11 do Util.AddClick(tabs1[i], function() --设置tabs的琐碎----- this.tabs.transform.anchoredPosition = Vector2.New(0,-130) this.tabs:SetActive(false) this.isShowTabs = false for j = 1, 5 do this.selectImg[j]:SetActive(false) end this.selectImg[1]:SetActive(true) --====================== if this.isFristOpen == false then if i == sortIndex then return end sortIndex = i LogError("i==="..i) this.OnClickTabBtn(sortIndex, tabs1[sortIndex]) end end) end Util.AddClick(this.fenJieBtn, function() if sortIndex == ItemBaseType.Equip then local temp = BagManager.GetBagItemDataByItemType(ItemBaseType.Equip) if not temp or #temp < 1 then PopupTipPanel.ShowTip(Language[10170]) else UIManager.OpenPanel(UIName.EquipSellSelectPopup)--宝器 end elseif sortIndex == ItemBaseType.SoulPrint then local temp = BagManager.GetAllSoulPrintData() if not temp or #temp < 1 then PopupTipPanel.ShowTip(Language[10171]) else UIManager.OpenPanel(UIName.HeroAndEquipResolvePanel, 4)--魂印 end elseif sortIndex == ItemBaseType.EquipTreasure then--法宝 local temp = EquipTreasureManager.GetAllTreasures() if not temp or #temp < 1 then PopupTipPanel.ShowTip("无可分解宝物") else UIManager.OpenPanel(UIName.ResolvePanel, 2) end elseif sortIndex == ItemBaseType.GodPrint then local temp = BagManager.GetAllGodPrintData() if not temp or #temp < 1 then PopupTipPanel.ShowTip("无可分解神印") else UIManager.OpenPanel(UIName.GodPrintResolvePanel, 4)--魂印 end end end) Util.AddClick(this.tabsBtn, function() this:MoveTabs() end) Util.AddClick(this.oneKey, function() local list,num = GemManager.OneKeyConpound() -- LogGreen("====================金币:"..tostring(num).."=============") -- for key, value in pairs(list) do -- LogPink("key:"..tostring(key).." Value:"..tostring(value)) -- end if num <= 0 then PopupTipPanel.ShowTip("无可合成的命石或金币不足!") return end UIManager.OpenPanel(UIName.GeneralPopup, GENERAL_POPUP_TYPE.GemOneKey,list,num) end) Util.AddClick(this.noneBtn, function() if sortIndex==10 then local isActive = ShopManager.IsActive(SHOP_TYPE.GodPrint ) if not isActive then PopupTipPanel.ShowTip("商店尚未开启") return end UIManager.OpenPanel(UIName.MainShopPanel, SHOP_TYPE.GodPrint ) end end) for i = 1, 5 do Util.AddOnceClick(this.tabsList[i],function () for j = 1, 5 do this.selectImg[j]:SetActive(false) end this.selectImg[i]:SetActive(true) this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true,i-1) end) end BindRedPointObject(RedPointType.Bag_HeroDebris, tabs1RedPoint[ItemBaseType.HeroChip]) BindRedPointObject(RedPointType.Bag_BoxAndBlueprint, tabs1RedPoint[ItemBaseType.Special]) end function this:MoveTabs() this.tabsBtn:GetComponent("Button").enabled = false this.isShowTabs = not this.isShowTabs if this.isShowTabs then this.tabs:SetActive(true) this.tabs.transform:DOAnchorPosY(370, 0.5, false):OnComplete(function() this.tabsBtn:GetComponent("Button").enabled = true end) else this.tabs.transform:DOAnchorPosY(-130, 0.5, false):OnComplete(function() this.tabsBtn:GetComponent("Button").enabled = true this.tabs:SetActive(false) end) end end function this.JumpOnClickTabBtn(_sortIndex) sortIndex = _sortIndex this.OnClickTabBtn(sortIndex, tabs1[sortIndex], true) end function this:SetSelectBtn(_btn) if _btn then this.selectBtn1:SetActive(true) this.selectBtn1.transform:SetParent(_btn.transform) this.selectBtn1.transform.localPosition = Vector3.zero Util.GetGameObject(this.selectBtn1.transform, "Text"):GetComponent("Text").text = Util.GetGameObject(_btn.transform, "Text"):GetComponent("Text").text else this.selectBtn1:SetActive(false) end this.tabsBtn:SetActive(sortIndex == ItemBaseType.EquipTreasure) this.fenJieBtn:SetActive(sortIndex == ItemBaseType.SoulPrint or sortIndex == ItemBaseType.Equip or sortIndex == ItemBaseType.EquipTreasure or sortIndex == ItemBaseType.GodPrint)--装备 this.fenJieBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite(tostring(ImgList[sortIndex]))--装备 this.oneKey:SetActive(sortIndex == ItemBaseType.Gem) this.itemNumText:SetActive(sortIndex == ItemBaseType.Equip or sortIndex == ItemBaseType.SoulPrint or sortIndex == ItemBaseType.EquipTreasure)--装备 法宝 end -- --点击全部按钮 -- function this:OnClickAllBtn() -- sortIndex = 0 -- this:SetSelectBtn(tabs1[sortIndex]) -- sortIndexBtnGo = tabs1[sortIndex] -- itemData = {} -- itemData = this.GetBagItemData() -- local curAllEquipTreasure = EquipTreasureManager.GetAllTreasures() -- for i = 1, #curAllEquipTreasure do -- table.insert(itemData, curAllEquipTreasure[i]) -- end -- local soulPrintData = BagManager.GetAllSoulPrintData() -- for i,v in ipairs(soulPrintData) do -- table.insert(itemData, v) -- end -- this:SetItemData(itemData) -- this.noneImage:SetActive(#itemData==0) -- end function this.BagGoldChangeCallBackOnClickTabBtn() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) end function this.OnClickTabBtn(_index, _clickBtn, isTop,isNotAni,_tabIndex) sortIndexBtnGo = _clickBtn itemData = {} local itemNumText = this.itemNumText:GetComponent("Text") this:SetSelectBtn(_clickBtn) print("_index ".._index) if _index == ItemBaseType.Equip then local allEquipData = BagManager.GetBagItemDataByItemType(ItemBaseType.Equip) -- local allEquipNum = 0 for i, v in pairs(allEquipData) do table.insert(itemData, v) -- allEquipNum = allEquipNum + v.num end --"装备数量:" itemNumText.text = Language[12181] ..LengthOfTable(allEquipData).."/"..ConfigManager.GetConfigData(ConfigName.GameSetting,1).EquipNumlimit this:SetItemData(itemData, isTop,isNotAni) -- elseif _index == 0 then -- this:OnClickAllBtn() elseif (_index == ItemBaseType.SoulPrint) then itemData = BagManager.GetAllSoulPrintData() itemNumText.text = Language[10173]..#itemData.."/"..specialConfig[9].Value this:SetItemData(itemData, isTop,isNotAni) elseif (_index == ItemBaseType.EquipTreasure) then itemData = EquipTreasureManager.GetAllTreasures(_tabIndex) itemNumText.text = Language[10174]..LengthOfTable(itemData).."/"..specialConfig[10].Value this:SetItemData(itemData, isTop,isNotAni) elseif (_index == ItemBaseType.Special) then itemData = BagManager.GetBagItemDataByItemTypeV2(ItemBaseType.Special,ItemBaseType.Materials,ItemType.HeadFrame) this:SetItemData(itemData, isTop,isNotAni) elseif (_index == ItemBaseType.JuLing) then itemData = BagManager.GetItemDataByItemType(ItemBaseType.JuLing) this:SetItemData(itemData, isTop,isNotAni) elseif (_index == ItemBaseType.Gem) then itemData = BagManager.GetItemDataByItemType(ItemBaseType.Gem) this:SetItemData(itemData, isTop,isNotAni) elseif(_index == ItemBaseType.TurnsCard) then itemData = BagManager.GetItemDataByItemType(ItemBaseType.TurnsCard) this:SetItemData(itemData, isTop,isNotAni) elseif (_index == ItemBaseType.GodPrint) then itemData = BagManager.GetAllGodPrintData() this:SetItemData(itemData, isTop,isNotAni) else itemData = BagManager.GetBagItemDataByItemType(_index) this:SetItemData(itemData, isTop,isNotAni) end if _index == ItemBaseType.GodPrint then this.noneTxt.text="空空如也,神印可从挑战商店获取" else this.noneTxt.text="空空如也" end this.noneImage:SetActive(#itemData==0) end --当魂印升级消耗时刷新背包数据 function this.OnRefreshSoulPanelBagData() itemData = SoulPrintManager.soulPrintData this:SetItemData(itemData) end local orginLayer2 = 0 --设置背包列表数据 function this:SetItemData(_itemDatas, isTop,isNotAni) -- LogPink("IsTop = "..tostring(isTop)) -- LogPink("isNotAni = "..tostring(isNotAni)) list={} this.ItemsSortDataV2(_itemDatas) if not this.ScrollView then local v2 = Util.GetGameObject(self.gameObject, "scroll"):GetComponent("RectTransform").rect this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.transform, "scroll").transform, this.ItemView, this.Scrollbar, Vector2.New(-v2.x * 2, -v2.y * 2), 1, 5, Vector2.New(40, 11)) this.ScrollView.moveTween.MomentumAmount = 1 this.ScrollView.moveTween.Strength = 2 end this.ScrollView:SetData(_itemDatas, function(index, go) this.SingleItemDataShow(go, _itemDatas[index]) if _itemDatas[index].itemConfig.ItemType == ItemType.HunYin or _itemDatas[index].itemConfig.ItemType == ItemType.GodPrint then table.insert(list, go) end end, not isTop,isNotAni) this.ScrollView:SetIndex(1) --特效层级重设 for i=1,#list do Util.AddParticleSortLayer(list[i], this.sortingOrder- orginLayer2) end orginLayer2 = this.sortingOrder orginLayer = this.sortingOrder if this.isFristOpen then -- this.ScrollView:ForeachItemGO(function(index, go) -- Timer.New(function() -- go.gameObject:SetActive(true) -- PlayUIAnim(go.gameObject) -- end, 0.01 * (index - 1)):Start() -- end) if isFristOpenTime then isFristOpenTime:Stop() isFristOpenTime = nil end isFristOpenTime = Timer.New(function() this.isFristOpen = false this.mask:SetActive(false) end, 0.5):Start() end end --设置魂印循环滚动数据 function this:SetSoulPrintData(_go, _itemData) local openBtn = Util.GetGameObject(_go.gameObject, "openBtn") local quality = Util.GetGameObject(_go.gameObject, "itemShow/quality"):GetComponent("Image") local icon = Util.GetGameObject(_go.gameObject, "itemShow/icon"):GetComponent("Image") local name = Util.GetGameObject(_go.gameObject, "itemShow/Image/name"):GetComponent("Text") local level = Util.GetGameObject(_go.gameObject, "itemShow/level"):GetComponent("Text") local propertyText = Util.GetGameObject(_go.gameObject, "propertyText"):GetComponent("Text") local propertyText2 = Util.GetGameObject(_go.gameObject, "propertyText (1)"):GetComponent("Text") quality.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(_itemData.quality)) icon.sprite = this.spLoader:LoadSprite(_itemData.icon) name.text = _itemData.name num.gameObject.SetActive(false) level.text = "+" .. _itemData.level propertyText.text = "" propertyText2.text = "" local property = SoulPrintManager.GetShowPropertyData(_itemData.property[1][1], _itemData.property[1][2]) propertyText.text = property.name .. property.num if (#_itemData.property >= 2) then property = SoulPrintManager.GetShowPropertyData(_itemData.property[2][1], _itemData.property[2][2]) propertyText2.text = property.name .. property.num end Util.AddOnceClick(openBtn, function() UIManager.OpenPanel(UIName.SoulPrintPopUp, ShowType.showTip3, _itemData.did, nil, nil, nil) end) end function this.SingleItemDataShow(_go, _itemData) Util.GetGameObject(_go.gameObject, "GameObject/item"):SetActive(true) Util.GetGameObject(_go.gameObject, "GameObject/item/frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_itemData.frame) Util.GetGameObject(_go.gameObject, "GameObject/item/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(_itemData.icon) Util.GetGameObject(_go.gameObject, "GameObject/item/icon"):SetActive(true) Util.GetGameObject(_go.gameObject, "GameObject/item/circleFrameBg"):SetActive(false) local str="" if GetCurLanguage() == 0 and LengthString(GetLanguageStrById(_itemData.itemConfig.Name))>6 then str=SubString(GetLanguageStrById(_itemData.itemConfig.Name),5).."..." elseif GetCurLanguage() == 1 and LengthString(GetLanguageStrById(_itemData.itemConfig.Name))>8 then str=SubString(GetLanguageStrById(_itemData.itemConfig.Name),8).."..." elseif GetCurLanguage() == 2 and LengthString(GetLanguageStrById(_itemData.itemConfig.Name))>8 then str=SubString(GetLanguageStrById(_itemData.itemConfig.Name),8).."..." else str = GetLanguageStrById(_itemData.itemConfig.Name) end Util.GetGameObject(_go.gameObject, "GameObject/name"):GetComponent("Text").text = str local upHeroInage = Util.GetGameObject(_go.transform, "GameObject/item/upHeroInage") local UI_Effect_Kuang_HongSe = Util.GetGameObject(_go.transform, "GameObject/effects/UI_Effect_Kuang_HongSe") if UI_Effect_Kuang_HongSe then UI_Effect_Kuang_HongSe:SetActive(false) end local UI_effect_WuCai_Kuang = Util.GetGameObject(_go.transform, "GameObject/effects/UI_effect_WuCai_Kuang") if UI_effect_WuCai_Kuang then UI_effect_WuCai_Kuang:SetActive(false) end local UI_Effect_Kuang_JinSe = Util.GetGameObject(_go.transform, "GameObject/effects/UI_Effect_Kuang_JinSe") if UI_Effect_Kuang_JinSe then UI_Effect_Kuang_JinSe:SetActive(false) end upHeroInage:SetActive(false) local frameMask = Util.GetGameObject(_go.transform, "GameObject/item/frameMask") local frameMaskExp = Util.GetGameObject(_go.transform, "GameObject/item/frameMask/exp") local frameMaskExpMask = Util.GetGameObject(_go.transform, "GameObject/item/frameMask/mask") frameMask:SetActive(false) local num = Util.GetGameObject(_go.gameObject, "GameObject/item/num") local strongLv=Util.GetGameObject(_go.gameObject, "GameObject/item/lv"):GetComponent("Text") local refine=Util.GetGameObject(_go.gameObject, "GameObject/item/refine"):GetComponent("Text") local resetLv = Util.GetGameObject(_go.gameObject, "GameObject/item/resetLv") local talismanStar = Util.GetGameObject(_go.gameObject, "GameObject/item/talismanStar") local fragmentIcon = Util.GetGameObject(_go.transform, "GameObject/item/fragmentIcon"):GetComponent("Image") local time = Util.GetGameObject(_go.transform, "GameObject/item/time") local timeTxt = Util.GetGameObject(_go.transform, "GameObject/item/time/Text"):GetComponent("Text") num:SetActive(true) resetLv:SetActive(false) talismanStar:SetActive(false) strongLv.gameObject:SetActive(false) refine.gameObject:SetActive(false) time.gameObject:SetActive(false) if _itemData.itemConfig then Util.GetGameObject(_go.transform, "GameObject/item/innateImage"):SetActive(false) fragmentIcon.gameObject:SetActive(false) num:SetActive(true) num:GetComponent("Text").text = _itemData.num if _itemData.itemConfig.ItemType == ItemType.Equip then --装备 local equipConfig = ConfigManager.GetConfigData(ConfigName.EquipConfig,_itemData.itemConfig.Id) if equipConfig then local equipStarsConfig = ConfigManager.GetConfigData(ConfigName.EquipStarsConfig,equipConfig.Star) if equipStarsConfig then talismanStar:SetActive(true) SetHeroStars(this.spLoader, talismanStar, equipStarsConfig.Stars,1,Vector2.New(32.5,32.5),-15) end end elseif _itemData.itemConfig.ItemType == ItemType.likeabilityItem then fragmentIcon.gameObject:SetActive(true) if _itemData.itemConfig.PropertyName > 0 then fragmentIcon.gameObject:SetActive(true) fragmentIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(_itemData.itemConfig.PropertyName)) else fragmentIcon.gameObject:SetActive(false) end elseif _itemData.itemConfig.ItemType == ItemType.Pokemon then Util.GetGameObject(_go.gameObject, "GameObject/item/frame"):GetComponent("Image").sprite = this.spLoader:LoadSprite(YaoHunFrame[_itemData.quality]) num:SetActive(false) -- 法宝聚灵显示碎片边框 elseif _itemData.itemConfig.ItemType == ItemType.talismanSoulChip then frameMask:SetActive(true) frameMaskExp:SetActive(false) frameMaskExpMask:SetActive(false) frameMask:GetComponent("Image").sprite = this.spLoader:LoadSprite("f_fabaojuling_zijiemianfabaokuang1") elseif _itemData.itemConfig.ItemType == ItemType.HeroDebris then frameMask:SetActive(true) num:SetActive(false) frameMask:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroChipQuantityImageByquality(_itemData.itemConfig.Quantity)) Util.GetGameObject(_go.transform, "GameObject/item/frameMask/exp/Text"):GetComponent("Text").text = BagManager.GetItemCountById(_itemData.itemConfig.Id) .. "/" .. _itemData.itemConfig.UsePerCount local curExpVal = BagManager.GetItemCountById(_itemData.itemConfig.Id) / _itemData.itemConfig.UsePerCount local expValue = curExpVal >= 1 and 1 or curExpVal frameMaskExp:SetActive(true) frameMaskExp:GetComponent("Slider").value = expValue frameMaskExpMask:SetActive(expValue >= 1) local propertyName = itemConfig[_itemData.itemConfig.Id].PropertyName if (propertyName ~= 0) then fragmentIcon.gameObject:SetActive(true) fragmentIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(propertyName)) end elseif _itemData.itemConfig.ItemType == ItemType.TalentItem then --天赋材料 if _itemData.itemConfig.RingLevel > 0 then Util.GetGameObject(_go.transform, "GameObject/item/innateImage"):SetActive(true) Util.GetGameObject(_go.transform, "GameObject/item/innateImage/Text"):GetComponent("Text").text = "+" .. _itemData.itemConfig.RingLevel else Util.GetGameObject(_go.transform, "GameObject/item/innateImage"):SetActive(false) Util.GetGameObject(_go.transform, "GameObject/item/innateImage/Text"):GetComponent("Text").text = "" end elseif _itemData.itemConfig.ItemType == ItemType.Talisman then --法宝 talismanStar:SetActive(true) SetHeroStars(this.spLoader, talismanStar, _itemData.star,1,Vector2.New(32.5,32.5),-15) num:SetActive(false) elseif _itemData.itemConfig.ItemType == ItemType.EquipTreasure then --宝器 num:SetActive(false) if _itemData.lv>0 then strongLv.gameObject:SetActive(true) strongLv.text=_itemData.lv end if _itemData.refineLv>0 then refine.gameObject:SetActive(true) refine.text="+".._itemData.refineLv end fragmentIcon.gameObject:SetActive(true) fragmentIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(itemConfig[_itemData.itemConfig.Id].PropertyName)) elseif _itemData.itemConfig.ItemType == ItemType.HunYin or _itemData.itemConfig.ItemType == ItemType.GodPrint then SetSoulEffect(itemConfig[_itemData.itemConfig.Id].Quantity1,Util.GetGameObject(_go.transform, "GameObject/effects")) Util.GetGameObject(_go.transform, "GameObject/item/resetLv"):SetActive(false) Util.GetGameObject(_go.gameObject, "GameObject/item/icon"):SetActive(false) Util.GetGameObject(_go.gameObject, "GameObject/item/circleFrameBg"):SetActive(true) Util.GetGameObject(_go.gameObject,"GameObject/item/circleFrameBg"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[_itemData.itemConfig.Id].Quantity].circleBg2) Util.GetGameObject(_go.gameObject,"GameObject/item/circleFrameBg/Icon"):GetComponent("Image").sprite=this.spLoader:LoadSprite(_itemData.icon) Util.GetGameObject(_go.gameObject,"GameObject/item/circleFrameBg/circleFrame"):GetComponent("Image").sprite=this.spLoader:LoadSprite(SoulPrintSpriteByQuantity[itemConfig[_itemData.itemConfig.Id].Quantity].circle) num:SetActive(false) elseif _itemData.itemConfig.ItemType == ItemType.heroDogFood then num:SetActive(true) num:GetComponent("Text").text = _itemData.num frameMask:GetComponent("Image").sprite = this.spLoader:LoadSprite(GetHeroChipQuantityImageByquality(_itemData.itemConfig.Quantity)) local propertyName = itemConfig[_itemData.itemConfig.Id].PropertyName if (propertyName ~= 0) then fragmentIcon.gameObject:SetActive(true) fragmentIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(propertyName)) end talismanStar:SetActive(true) SetHeroStars(this.spLoader,talismanStar, _itemData.itemConfig.HeroStar[1],1,Vector2.New(32.5,32.5),-15) elseif _itemData.itemConfig.ItemType == ItemType.TimeIsGold then local useGain = itemConfig[_itemData.itemConfig.Id].UseGain if useGain and useGain[1] and useGain[1][2] then local mins = useGain[1][2] local hours = math.floor(mins/60) time.gameObject:SetActive(true) timeTxt.text= hours .. "小时" end end end local redPoint = Util.GetGameObject(_go.gameObject, "GameObject/redPoint") Util.AddOnceClick(Util.GetGameObject(_go.gameObject, "GameObject/item/frame"), function() if _itemData.itemConfig then LogError("_itemData.itemConfig.ItemBaseType==".._itemData.itemConfig.ItemBaseType) if _itemData.itemConfig.ItemBaseType == ItemBaseType.Equip then UIManager.OpenPanel(UIName.RewardEquipSingleShowPopup2,this, _itemData,1,true,true,nil,function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) end) elseif _itemData.itemConfig.ItemType == ItemType.SelfBox then--自选宝箱 UIManager.OpenPanel(UIName.RewardBoxPanel, _itemData, function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) UIManager.ClosePanel(UIName.RewardBoxPanel) end) -- body elseif _itemData.itemConfig.ItemBaseType == ItemBaseType.HeroChip then UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, _itemData.id, function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) UIManager.ClosePanel(UIName.RewardItemSingleShowPopup) end) elseif _itemData.itemConfig.ItemType == ItemType.Blueprint then --蓝图 local lanTuData = WorkShopManager.GetLanTuIsOpenLock(_itemData.itemConfig.Id) if lanTuData and lanTuData[1] == true then UIManager.OpenPanel(UIName. WorkShopArmorOnePanel, 2, 2, lanTuData[2], this, function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) end) elseif lanTuData and lanTuData[1] == false then UIManager.OpenPanel(UIName.WorkShopArmorOnePanel, 2, 1, lanTuData[2], this, function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) end) end elseif _itemData.itemConfig.ItemType == ItemType.HeroDebris then --角色碎片 if _itemData.num >= _itemData.itemConfig.UsePerCount then UIManager.OpenPanel(UIName.BagResolveAnCompoundPanel, 3, _itemData, function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) end) else UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, _itemData.id, function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) UIManager.ClosePanel(UIName.RewardItemSingleShowPopup) end) end elseif _itemData.itemConfig.ItemBaseType == ItemBaseType.EquipTreasure then --宝器 -- UIManager.OpenPanel(UIName.RewardTalismanSingleShowPopup, 0, _itemData.idDyn,_itemData.id, _itemData.lv,_itemData.refineLv, function() -- this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) -- end) UIManager.OpenPanel(UIName.RewardTalismanSingleShowPopup2,this,_itemData,1,true,true,nil,nil,nil,function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) end) elseif _itemData.itemConfig.ItemBaseType == ItemBaseType.SoulPrint then --魂印 if _itemData.itemConfig.ItemType==13 then UIManager.OpenPanel(UIName.SoulPrintPopUp, ShowType.showTip3, nil,_itemData.id) else UIManager.OpenPanel(UIName.GodPrintPopUp, 4, nil,_itemData.id) end elseif _itemData.itemConfig.ItemType == ItemType.Skin then --皮肤 UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, _itemData.id,function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) UIManager.ClosePanel(UIName.RewardItemSingleShowPopup) end) elseif _itemData.itemConfig.ItemType == ItemType.Gem then --命石 UIManager.OpenPanel(UIName.RewardGemSingleShowPopup, _itemData.id,1,function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) UIManager.ClosePanel(UIName.RewardGemSingleShowPopup) end) elseif _itemData.itemConfig.ItemType == ItemType.Ride then --坐骑 UIManager.OpenPanel(UIName.RewardRideShowPopup, _itemData.id,function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) end) elseif _itemData.itemConfig.ItemBaseType == ItemBaseType.GodPrint then UIManager.OpenPanel(UIName.GodPrintPopUp, 4, nil,_itemData.id) else UIManager.OpenPanel(UIName.RewardItemSingleShowPopup, _itemData.id, function() this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true) UIManager.ClosePanel(UIName.RewardItemSingleShowPopup) end) end end end) --显示红点 redPoint:SetActive(false) if _itemData.itemConfig.ItemType == ItemType.Equip then if _itemData.itemConfig.Quantity >= 4 then redPoint:SetActive(EquipManager.IsNewEquipFrame(_itemData.did)) end elseif _itemData.itemConfig.ItemType == ItemType.Blueprint then local lanTuData = WorkShopManager.GetLanTuIsOpenLock(_itemData.itemConfig.Id) if lanTuData and lanTuData[1] == false then redPoint:SetActive(true) end elseif _itemData.itemConfig.ItemType == ItemType.Box then redPoint:SetActive(true) end end --通过物品类型获取物品数据 function this:GetItemsByItemTpye(_itemType) local items = {} local index = 1 for i, v in pairs(BagManager.bagDatas) do if v.type == _itemType then items[index] = v index = index + 1 end end return items end --添加事件监听(用于子类重写) function BagPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Bag.OnTempBagChanged, this.BagGoldChangeCallBackOnClickTabBtn) Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.BagGoldChangeCallBackOnClickTabBtn) Game.GlobalEvent:AddEvent(GameEvent.Bag.OnRefreshSoulPanelData, this.OnRefreshSoulPanelBagData) Game.GlobalEvent:AddEvent(GameEvent.Bag.OnBagShowWarPowerChange, this.ShowWarPowerChange) end --移除事件监听(用于子类重写) function BagPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Bag.OnTempBagChanged, this.BagGoldChangeCallBackOnClickTabBtn) Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.BagGoldChangeCallBackOnClickTabBtn) Game.GlobalEvent:RemoveEvent(GameEvent.Bag.OnRefreshSoulPanelData, this.OnRefreshSoulPanelBagData) Game.GlobalEvent:RemoveEvent(GameEvent.Bag.OnBagShowWarPowerChange, this.ShowWarPowerChange) end --界面打开时调用(用于子类重写) function BagPanel:OnOpen(_sortIndex) sortIndex = 1--注释掉就是记录选择类型 if _sortIndex then sortIndex = _sortIndex end this.UpView:OnOpen({ showType = UpViewOpenType.ShowRight, panelType = PanelType.Main }) this.BtView:OnOpen(self, { sortOrder = self.sortingOrder, panelType = PanelTypeView.BagPanel }) end --界面打开时调用(用于子类重写) function BagPanel:OnShow() this.sortingOrder = self.sortingOrder this.isFristOpen = true this.mask:SetActive(true) --设置tabs的琐碎----- this.isShowTabs = false this.tabs.transform.anchoredPosition = Vector2.New(0,-130) this.tabs:SetActive(false) for j = 1, 5 do this.selectImg[j]:SetActive(false) end this.selectImg[1]:SetActive(true) --====================== if this.ScrollView then this.ScrollView:SetIndex(1) end if sortIndex > 0 then this.OnClickTabBtn(sortIndex, tabs1[sortIndex], true) -- else -- this:OnClickAllBtn() end SoundManager.PlayMusic(SoundConfig.BGM_Main) BagManager.isBagPanel = true this.SetBottomBarIsActive() -- 刷新一次编队战斗力 FormationManager.RefreshMainFormationPower() end --特殊的开启条件 function this.SetBottomBarIsActive() local ConfigData = ConfigManager.GetConfig(ConfigName.SpecialConfig) local num = 0 for i = 1, #tabs1 do --为宝物定开启规则 if i == 5 then local string = ConfigData[40].Value local num = string.split(string.split(string,"|")[1],"#")[2] tabs1[i]:SetActive(PlayerManager.level >= tonumber(num)) elseif i == 6 then--为魂印定开启规则 local string = ConfigData[37].Value local num = string.split(string,"#")[1] tabs1[i]:SetActive(PlayerManager.level >= tonumber(num)) elseif i == 8 then--为聚灵定开启规则 tabs1[i]:SetActive(ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.TailsmanSoul)) elseif i == 9 then--命格 tabs1[i]:SetActive(ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.Gem)) end if tabs1[i].activeInHierarchy then num = num + 1 end end this.tabBox:GetComponent("RectTransform").pivot = num > 5 and Vector2.New(0, 0.5) or Vector2.New(0.5, 0.5) end local orginLayer function BagPanel:OnSortingOrderChange() Util.AddParticleSortLayer(this.ItemViewEffect, self.sortingOrder - this.EffectOrginLayer) --特效层级重设 for i=1,#list do Util.AddParticleSortLayer(list[i], this.sortingOrder- orginLayer) end orginLayer = this.sortingOrder this.EffectOrginLayer = self.sortingOrder this.BtView:SetOrderStatus({ sortOrder = self.sortingOrder }) if this.playerInfoView then this.playerInfoView:SetLayer(self.sortingOrder) end end --界面关闭时调用(用于子类重写) function BagPanel:OnClose() this.noneImage:SetActive(false) BagManager.isBagPanel = false if isFristOpenTime then isFristOpenTime:Stop() isFristOpenTime = nil end end function this.DelePokemonItemData(_itemDatas) local curItemDatas = {} --背包特殊处理 sortType=1 sortIndex=5 时显示妖魂 其他页签不显示 for k, v in pairs(_itemDatas) do if sortIndex == ItemBaseType.DemonSoul then else if v.itemConfig.ItemType == ItemType.Pokemon then _itemDatas[k] = nil end end end for k, v in pairs(_itemDatas) do table.insert(curItemDatas, v) end return curItemDatas end function this.ItemsSortDataV2(_itemDatas) table.sort(_itemDatas, function(a, b) if a.itemConfig.Sort == b.itemConfig.Sort then return a.itemConfig.Id > b.itemConfig.Id else return a.itemConfig.Sort > b.itemConfig.Sort end end) end --弃用 function this.ItemsSortData(_itemDatas) --排序 table.sort(_itemDatas, function(a, b) if sortIndex == 0 then --0全部 1装备 2材料 3消耗 4特殊 5碎片 if a.itemConfig.ItemBaseType == b.itemConfig.ItemBaseType then if a.itemConfig.ItemType == a.itemConfig.ItemType then if a.itemConfig.ItemType == ItemType.Talisman and b.itemConfig.ItemType == ItemType.Talisman then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.star == b.star then return a.id < b.id else return a.star > b.star end else return a.itemConfig.Quantity > b.itemConfig.Quantity end end if a.itemConfig.ItemType == ItemType.HunYin and b.itemConfig.ItemType == ItemType.HunYin then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.quality == b.quality then return a.id > b.id else return a.quality > b.quality end else return a.itemConfig.Quantity > b.itemConfig.Quantity end end if a.itemConfig.ItemType == ItemType.GodPrint and b.itemConfig.ItemType == ItemType.GodPrint then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.quality == b.quality then return a.id > b.id else return a.quality > b.quality end else return a.itemConfig.Quantity > b.itemConfig.Quantity end end if a.itemConfig.ItemType == ItemType.EquipTreasure and b.itemConfig.ItemType == ItemType.EquipTreasure then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.refineLv == b.refineLv then if a.lv == b.lv then return a.id > b.id else return a.lv > b.lv end else return a.refineLv > b.refineLv end else return a.itemConfig.Quantity > b.itemConfig.Quantity end end if a.itemConfig.ItemType == ItemType.Equip and b.itemConfig.ItemType == ItemType.Equip then if a.itemConfig.Quantity == b.itemConfig.Quantity then return a.id > b.id else return a.itemConfig.Quantity > b.itemConfig.Quantity end end if a.itemConfig.ItemType == ItemType.HeroDebris and b.itemConfig.ItemType == ItemType.HeroDebris then local aNum = BagManager.GetItemCountById(a.itemConfig.Id) >= a.itemConfig.UsePerCount and 2 or 1 local bNum = BagManager.GetItemCountById(b.itemConfig.Id) >= b.itemConfig.UsePerCount and 2 or 1 if aNum == bNum then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.itemConfig.PropertyName == b.itemConfig.PropertyName then return a.id < b.id else return a.itemConfig.PropertyName < b.itemConfig.PropertyName end else return a.itemConfig.Quantity > b.itemConfig.Quantity end else return aNum > bNum end end else return a.itemConfig.ItemType < b.itemConfig.ItemType end else return a.itemConfig.ItemBaseType < b.itemConfig.ItemBaseType end elseif sortIndex == ItemBaseType.Equip or sortIndex == ItemBaseType.Materials or sortIndex == ItemBaseType.Special then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.itemConfig.ItemType == b.itemConfig.ItemType then return a.id > b.id else return a.itemConfig.ItemType < b.itemConfig.ItemType end else return a.itemConfig.Quantity > b.itemConfig.Quantity end elseif sortIndex == ItemBaseType.HeroChip then local aNum = BagManager.GetItemCountById(a.itemConfig.Id) >= a.itemConfig.UsePerCount and 2 or 1 local bNum = BagManager.GetItemCountById(b.itemConfig.Id) >= b.itemConfig.UsePerCount and 2 or 1 if aNum == bNum then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.itemConfig.PropertyName == b.itemConfig.PropertyName then return a.id < b.id else return a.itemConfig.PropertyName < b.itemConfig.PropertyName end else return a.itemConfig.Quantity > b.itemConfig.Quantity end else return aNum > bNum end elseif sortIndex == ItemBaseType.DemonSoul then local aNum = BagManager.GetItemCountById(a.itemConfig.Id) >= a.itemConfig.UsePerCount and 2 or 1 local bNum = BagManager.GetItemCountById(b.itemConfig.Id) >= b.itemConfig.UsePerCount and 2 or 1 if aNum == bNum then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.itemConfig.ItemType == b.itemConfig.ItemType then return a.id > b.id else return a.itemConfig.ItemType < b.itemConfig.ItemType end else return a.itemConfig.Quantity > b.itemConfig.Quantity end else return aNum > bNum end elseif sortIndex == ItemBaseType.SoulPrint then if a.quality == b.quality then return a.id > b.id else return a.quality > b.quality end elseif sortIndex == ItemBaseType.EquipTreasure then if a.itemConfig.Quantity == b.itemConfig.Quantity then if a.refineLv == b.refineLv then if a.lv == b.lv then return a.id > b.id else return a.lv > b.lv end else return a.refineLv > b.refineLv end else return a.itemConfig.Quantity > b.itemConfig.Quantity end end end) end --获取所有背包物品 function this.GetBagItemData() local _index = 1 local _bagItemData = {} for i, v in pairs(BagManager.bagDatas) do if v.isBag and v.num > 0 and v.itemConfig.ItemType ~= ItemType.Pokemon and v.itemConfig.ItemType ~= ItemType.HunYin and v.itemConfig.ItemType ~= ItemType.GodPrint then --进背包 数量大于零的 不是异妖部件 _bagItemData[_index] = v _index = _index + 1 end end return _bagItemData end --界面销毁时调用(用于子类重写) function BagPanel:OnDestroy() this.spLoader:Destroy() SubUIManager.Close(this.UpView) SubUIManager.Close(this.BtView) this.ScrollView = nil this.ScrollView1 = nil ClearRedPointObject(RedPointType.Bag_HeroDebris, tabs1RedPoint[ItemBaseType.HeroChip]) ClearRedPointObject(RedPointType.Bag_BoxAndBlueprint, tabs1RedPoint[ItemBaseType.Special]) list={} orginLayer2=0 orginLayer=0 this.tabsList = {} this.selectImg = {} if this.playerInfoView then SubUIManager.Close(this.playerInfoView) this.playerInfoView = nil end end --跳转显示新手提示圈 function this.ShowGuideGo() local item1Btn = Util.GetGameObject(this.transform, "scroll/ScrollCycleView/grid/item1") if item1Btn then JumpManager.ShowGuide(UIName.BagPanel, item1Btn) end end function this.ShowWarPowerChange(powernum,type) Timer.New(function() local str=nil if type==PowerChangeJumpType.ride then str=Language[12236] elseif type== PowerChangeJumpType.title then str=Language[12291] end MsgPanel.ShowTwo(str,function() -- 所有坐骑设置为旧的 PlayerSetTitleRideSkinManager.SetAllOldRide() end,function() UIManager.OpenPanel(UIName.SettingPanel,type) end) end, 1):Start() end return BagPanel