摘星阁英雄列表排序

dev_chengFeng
yuanshuai 2022-09-01 17:52:21 +08:00
parent cfa84cff79
commit 5eb0d6fcba
1 changed files with 22 additions and 1 deletions

View File

@ -234,6 +234,7 @@ function this:SetData()
end
---设置显示英雄列表
function this.SetHeroList(_roleDatas)
HeroManager.SortHeroDatas(_roleDatas)
this.scrollView:SetData(_roleDatas, function(index, go)
if index==1 then
this.SetHeroSelect(go)
@ -243,6 +244,26 @@ function this.SetHeroList(_roleDatas)
end, true,false)
end
--英雄排序
function this:SortHeroDatas(_heroDatas)
--上阵最优先星级优先同星级等级优先同星级同等级按sortId排序。排序时降序排序。
table.sort(_heroDatas, function(a, b)
if a.star == b.star then
if a.heroConfig.Natural ==b.heroConfig.Natural then
if a.lv == b.lv then
return a.heroConfig.Id < b.heroConfig.Id
else
return a.lv > b.lv
end
else
return a.heroConfig.Natural > b.heroConfig.Natural
end
else
return a.star > b.star
end
end)
end
--设置每条英雄数据
function this.SingleHeroDataShow(_go, _heroData)
local go=_go
@ -310,7 +331,7 @@ function this.SingleHeroDataShow(_go, _heroData)
Util.AddOnceClick(go, function()
curSelectHero=_heroData
this:SetData()
this:Refresh()
this.SetHeroSelect(go)
end)
end