diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index 229ae60b..e952236e 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -4,6 +4,7 @@ local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png" function MainComp:init() self.uiMap = self:getBaseObject():genAllChildren() self:initChapter() + self:initStageFormation() self:initGM() end @@ -28,6 +29,16 @@ function MainComp:initChapter() end) end +function MainComp:initStageFormation() + self.heroCells = { + self.uiMap["main_comp.hero_bg.hero_cell_1"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL), + self.uiMap["main_comp.hero_bg.hero_cell_2"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL), + self.uiMap["main_comp.hero_bg.hero_cell_3"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL), + self.uiMap["main_comp.hero_bg.hero_cell_4"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL), + self.uiMap["main_comp.hero_bg.hero_cell_5"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL), + } +end + function MainComp:initGM() self.btnGM = self.uiMap["main_comp.gm_btn"] self.btnGM:setVisible(not Platform:getIsPublishChannel(), 2) @@ -38,6 +49,7 @@ end function MainComp:refresh() self:refreshChapter() + self:refreshStageFormaion() end function MainComp:onFightBtnClick() @@ -59,4 +71,20 @@ function MainComp:refreshChapter() end end +function MainComp:refreshStageFormaion() + local formation = DataManager.FormationData:getStageFormation() + for i, heroCell in ipairs(self.heroCells) do + if formation[i] then + local heroEntity = DataManager.HeroData:getHeroById(formation[i]) + if heroEntity then + heroCell:refresh(heroEntity) + else + heroCell:setVisible(false) + end + else + heroCell:setVisible(false) + end + end +end + return MainComp \ No newline at end of file