优化排序
This commit is contained in:
parent
26fab280b3
commit
153cf72fb2
@ -16,7 +16,7 @@ function HeroManager:upgradeHero(heroId, heroEntity)
|
||||
end
|
||||
|
||||
local fragmentCost = materials[1] or 0
|
||||
if not GFunc.checkCost(heroEntity:getFramentId(), fragmentCost, true) then
|
||||
if not GFunc.checkCost(heroEntity:getFragmentId(), fragmentCost, true) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ function HeroCell:refresh(heroEntity, isGray)
|
||||
self.lvUpArrow:setVisible(canLvUp)
|
||||
self.fragmenImg:setVisible(not canLvUp)
|
||||
local materials = heroEntity:getLvUpMaterials() or {}
|
||||
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(heroEntity:getFramentId())
|
||||
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(heroEntity:getFragmentId())
|
||||
local needFragmentCount = materials[1] or 1
|
||||
self.progressTx:setText(fragmentCount .. "/" .. needFragmentCount)
|
||||
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
|
||||
|
||||
@ -46,7 +46,7 @@ function HeroListCell:refresh(index, heroList, stageFormation, allHeroCount, act
|
||||
local heroIndex = heroStartIndex
|
||||
for i = 1, 4 do
|
||||
if heroIndex <= activeCount then
|
||||
local heroId = heroList[heroIndex]
|
||||
local heroId = heroList[heroIndex].cfgId
|
||||
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
||||
local matchType = heroEntity:getMatchType()
|
||||
self.heroCells[i]:setVisible(true)
|
||||
@ -61,7 +61,7 @@ function HeroListCell:refresh(index, heroList, stageFormation, allHeroCount, act
|
||||
if heroStartIndex <= activeCount then
|
||||
self.heroCells[i]:setVisible(false)
|
||||
else
|
||||
local heroId = heroList[heroIndex]
|
||||
local heroId = heroList[heroIndex].cfgId
|
||||
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
||||
self.heroCells[i]:setVisible(true)
|
||||
self.heroCells[i]:refresh(heroEntity, true)
|
||||
|
||||
@ -17,7 +17,7 @@ function HeroComp:init()
|
||||
self.heroList = {}
|
||||
local heroCfg = ConfigManager:getConfig("hero")
|
||||
for id, v in pairs(heroCfg) do
|
||||
table.insert(self.heroList, id)
|
||||
table.insert(self.heroList, {cfgId = id, sort = id, elementType = v.position})
|
||||
end
|
||||
self.heroNodeList = {
|
||||
self.uiMap["hero_ui.formation.hero_1"],
|
||||
@ -120,30 +120,26 @@ function HeroComp:sortHeroList()
|
||||
local heroA
|
||||
local heroB
|
||||
local HeroData = DataManager.HeroData
|
||||
for _, info in ipairs(self.heroList) do
|
||||
local heroEntity = HeroData:getHeroById(info.cfgId)
|
||||
local sort = info.cfgId -- id 预留6位
|
||||
sort = sort + (10 - info.elementType) * 1000000 -- 位置预留1位
|
||||
|
||||
if heroEntity:isUnlock() then
|
||||
sort = sort + 30000000
|
||||
elseif DataManager.BagData.ItemData:getItemNumById(heroEntity:getFragmentId()) > 0 then
|
||||
sort = sort + 20000000
|
||||
else
|
||||
sort = sort + 10000000
|
||||
end
|
||||
|
||||
sort = sort + 100000000 * heroEntity:getQlt() -- 品质1位
|
||||
sort = sort + 1000000000 * heroEntity:getLv() -- 预留3位
|
||||
|
||||
info.sort = sort
|
||||
end
|
||||
table.sort(self.heroList, function(a, b)
|
||||
heroA = HeroData:getHeroById(a)
|
||||
heroB = HeroData:getHeroById(b)
|
||||
if heroA:isUnlock() == heroB:isUnlock() then
|
||||
if heroA:isActived() and heroB:isActived() then
|
||||
if heroA:getLv() == heroB:getLv() then
|
||||
if heroA:getQlt() == heroB:getQlt() then
|
||||
return a > b
|
||||
else
|
||||
return heroA:getQlt() > heroB:getQlt()
|
||||
end
|
||||
else
|
||||
return heroA:getLv() > heroB:getLv()
|
||||
end
|
||||
elseif heroA:isActived() and not heroB:isActived() then
|
||||
return true
|
||||
elseif heroB:isActived() and not heroA:isActived() then
|
||||
return false
|
||||
else
|
||||
return a > b
|
||||
end
|
||||
else
|
||||
return heroA:isUnlock()
|
||||
end
|
||||
return a.sort > b.sort
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ function HeroDetailUI:_display()
|
||||
uiMap["hero_detail_ui.bg.hero_element"]:setSprite(GConst.ATLAS_PATH.ICON_HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType()))
|
||||
|
||||
local materials = self.heroEntity:getLvUpMaterials() or {}
|
||||
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFramentId())
|
||||
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFragmentId())
|
||||
local needFragmentCount = materials[1] or 1
|
||||
uiMap["hero_detail_ui.bg.fragment_num"]:setText(fragmentCount .. "/" .. needFragmentCount)
|
||||
uiMap["hero_detail_ui.bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
|
||||
|
||||
@ -149,7 +149,7 @@ function HeroEntity:canLvUp()
|
||||
end
|
||||
|
||||
local fragmentCost = cost[1] or 0
|
||||
if not GFunc.checkCost(self:getFramentId(), fragmentCost, false) then
|
||||
if not GFunc.checkCost(self:getFragmentId(), fragmentCost, false) then
|
||||
return false
|
||||
end
|
||||
local goldCost = cost[2] or 0
|
||||
@ -205,7 +205,7 @@ function HeroEntity:getHurtSkill()
|
||||
return self.config.hurt_skill
|
||||
end
|
||||
|
||||
function HeroEntity:getFramentId()
|
||||
function HeroEntity:getFragmentId()
|
||||
return self.config.item_id
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user