【背包优化】宝物背包按照品质优先级进行排序,并增加阵营筛选功能

dev_chengFeng
ZhangBiao 2021-09-16 16:16:50 +08:00
parent 537af282e6
commit 1e17301cc8
3 changed files with 1723 additions and 36 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,12 @@ 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",
}
--初始化组件(用于子类重写)
function BagPanel:InitComponent()
this.spLoader = SpriteLoader.New()
@ -29,6 +35,7 @@ function BagPanel:InitComponent()
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.Ta = Util.GetGameObject(self.gameObject, "fenJieBtn")
this.fenJieBtn = Util.GetGameObject(self.gameObject, "fenJieBtn")
this.itemNumText = Util.GetGameObject(self.gameObject, "itemNumText")
this.ItemView = Util.GetGameObject(self.gameObject, "ItemView")
@ -39,7 +46,18 @@ function BagPanel:InitComponent()
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")
end
@ -54,6 +72,16 @@ function BagPanel:BindEvent()
end)
for i = 1, 7 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
@ -79,18 +107,55 @@ function BagPanel:BindEvent()
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
end
end)
Util.AddClick(this.tabsBtn, function()
this:MoveTabs()
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)
@ -100,8 +165,9 @@ function this:SetSelectBtn(_btn)
else
this.selectBtn1:SetActive(false)
end
this.fenJieBtn:SetActive(sortIndex == ItemBaseType.SoulPrint or sortIndex == ItemBaseType.Equip)--装备
this.fenJieBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite(sortIndex == ItemBaseType.SoulPrint and "r_fenjie_zh" or "r_chushou_zh" )--装备
this.tabsBtn:SetActive(sortIndex == ItemBaseType.EquipTreasure)
this.fenJieBtn:SetActive(sortIndex == ItemBaseType.SoulPrint or sortIndex == ItemBaseType.Equip or sortIndex == ItemBaseType.EquipTreasure)--装备
this.fenJieBtn:GetComponent("Image").sprite = this.spLoader:LoadSprite(tostring(ImgList[sortIndex]))--装备
this.itemNumText:SetActive(sortIndex == ItemBaseType.Equip or sortIndex == ItemBaseType.SoulPrint or sortIndex == ItemBaseType.EquipTreasure)--装备 法宝
end
@ -129,7 +195,7 @@ function this.BagGoldChangeCallBackOnClickTabBtn()
this.OnClickTabBtn(sortIndex, sortIndexBtnGo,false,true)
end
function this.OnClickTabBtn(_index, _clickBtn, isTop,isNotAni)
function this.OnClickTabBtn(_index, _clickBtn, isTop,isNotAni,_tabIndex)
sortIndexBtnGo = _clickBtn
itemData = {}
local itemNumText = this.itemNumText:GetComponent("Text")
@ -152,14 +218,13 @@ function this.OnClickTabBtn(_index, _clickBtn, isTop,isNotAni)
itemNumText.text = Language[10173]..#itemData.."/"..specialConfig[9].Value
this:SetItemData(itemData, isTop,isNotAni)
elseif (_index == ItemBaseType.EquipTreasure) then
itemData = EquipTreasureManager.GetAllTreasures()
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)
else
itemData = BagManager.GetBagItemDataByItemType(_index)
this:SetItemData(itemData, isTop,isNotAni)
end
@ -509,6 +574,17 @@ 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
@ -763,7 +839,8 @@ function BagPanel:OnDestroy()
list={}
orginLayer2=0
orginLayer=0
this.tabsList = {}
this.selectImg = {}
if this.playerInfoView then
SubUIManager.Close(this.playerInfoView)
this.playerInfoView = nil

View File

@ -412,13 +412,12 @@ function this.GetAllTreasuresByLocation(Location, PropertyName)
end
--获取所有宝物 不算英雄身上穿的
function this.GetAllTreasures(PropertyName)
if PropertyName then
end
local curAllEquipTreasure = {}
for key, value in pairs(allTreasures) do
if value.upHeroDid == "" or value.upHeroDid == "0" then
if PropertyName then
if jewelConfig[value.id].Race == PropertyName then
if jewelConfig[value.id].Race == PropertyName or PropertyName == 0 then
table.insert(curAllEquipTreasure, value)
end
else
@ -427,20 +426,17 @@ function this.GetAllTreasures(PropertyName)
end
end
if LengthOfTable(curAllEquipTreasure) > 0 then
table.sort(
curAllEquipTreasure,
function(a, b)
if a.quantity == b.quantity then
if a.lv == b.lv then
return a.refineLv > b.refineLv
else
return a.lv > b.lv
end
table.sort(curAllEquipTreasure,function(a, b)
if a.quantity == b.quantity then
if a.lv == b.lv then
return a.refineLv > b.refineLv
else
return a.quantity > b.quantity
return a.lv > b.lv
end
else
return a.quantity > b.quantity
end
)
end)
return curAllEquipTreasure
end