主界面

This commit is contained in:
chenxi 2023-04-11 20:11:35 +08:00
parent 4b621b0e07
commit b33b241e53

View File

@ -4,6 +4,7 @@ local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
function MainComp:init() function MainComp:init()
self.uiMap = self:getBaseObject():genAllChildren() self.uiMap = self:getBaseObject():genAllChildren()
self:initChapter() self:initChapter()
self:initStageFormation()
self:initGM() self:initGM()
end end
@ -28,6 +29,16 @@ function MainComp:initChapter()
end) end)
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() function MainComp:initGM()
self.btnGM = self.uiMap["main_comp.gm_btn"] self.btnGM = self.uiMap["main_comp.gm_btn"]
self.btnGM:setVisible(not Platform:getIsPublishChannel(), 2) self.btnGM:setVisible(not Platform:getIsPublishChannel(), 2)
@ -38,6 +49,7 @@ end
function MainComp:refresh() function MainComp:refresh()
self:refreshChapter() self:refreshChapter()
self:refreshStageFormaion()
end end
function MainComp:onFightBtnClick() function MainComp:onFightBtnClick()
@ -59,4 +71,20 @@ function MainComp:refreshChapter()
end end
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 return MainComp