From 5eb0d6fcba6d10edbe2d2d4e60121aa696652c23 Mon Sep 17 00:00:00 2001 From: yuanshuai <243578945@qq.com> Date: Thu, 1 Sep 2022 17:52:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=98=E6=98=9F=E9=98=81=E8=8B=B1=E9=9B=84?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Popup/HomeLandEquipPopup.lua | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Popup/HomeLandEquipPopup.lua b/Assets/ManagedResources/~Lua/Modules/Popup/HomeLandEquipPopup.lua index d90b124f81..60608d0528 100644 --- a/Assets/ManagedResources/~Lua/Modules/Popup/HomeLandEquipPopup.lua +++ b/Assets/ManagedResources/~Lua/Modules/Popup/HomeLandEquipPopup.lua @@ -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