From 153cf72fb2bd2cd098e508c13d94be11ff85f2a5 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Sun, 23 Apr 2023 12:07:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/hero/hero_manager.lua | 2 +- lua/app/ui/common/cell/hero_cell.lua | 2 +- lua/app/ui/hero/cell/hero_list_cell.lua | 4 +-- lua/app/ui/hero/hero_comp.lua | 42 +++++++++++-------------- lua/app/ui/hero/hero_detail_ui.lua | 2 +- lua/app/userdata/hero/hero_entity.lua | 4 +-- 6 files changed, 26 insertions(+), 30 deletions(-) diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index a11b9532..f1129723 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -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 diff --git a/lua/app/ui/common/cell/hero_cell.lua b/lua/app/ui/common/cell/hero_cell.lua index 73c0fad7..8d24ed4d 100644 --- a/lua/app/ui/common/cell/hero_cell.lua +++ b/lua/app/ui/common/cell/hero_cell.lua @@ -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 diff --git a/lua/app/ui/hero/cell/hero_list_cell.lua b/lua/app/ui/hero/cell/hero_list_cell.lua index 3a2372da..d0150529 100644 --- a/lua/app/ui/hero/cell/hero_list_cell.lua +++ b/lua/app/ui/hero/cell/hero_list_cell.lua @@ -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) diff --git a/lua/app/ui/hero/hero_comp.lua b/lua/app/ui/hero/hero_comp.lua index 80c8d271..427b5032 100644 --- a/lua/app/ui/hero/hero_comp.lua +++ b/lua/app/ui/hero/hero_comp.lua @@ -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 - 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 + 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 - return heroA:isUnlock() + 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) + return a.sort > b.sort end) end diff --git a/lua/app/ui/hero/hero_detail_ui.lua b/lua/app/ui/hero/hero_detail_ui.lua index 561843ec..792d0c8c 100644 --- a/lua/app/ui/hero/hero_detail_ui.lua +++ b/lua/app/ui/hero/hero_detail_ui.lua @@ -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 diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index f3a36a2f..94046f4d 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -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