This commit is contained in:
xiekaidong 2023-06-20 11:35:26 +08:00
commit 4ea51dd7ec
4 changed files with 64 additions and 27 deletions

View File

@ -177,6 +177,9 @@ GConst.TYPEOF_LUA_CLASS = {
POP_HERO_CELL = "app/ui/shop/cell/pop_hero_cell", POP_HERO_CELL = "app/ui/shop/cell/pop_hero_cell",
POP_REWARD_CELL = "app/ui/shop/cell/pop_reward_cell", POP_REWARD_CELL = "app/ui/shop/cell/pop_reward_cell",
GIFT_REWARD_CELL = "app/ui/shop/cell/gift_reward_cell", GIFT_REWARD_CELL = "app/ui/shop/cell/gift_reward_cell",
-- comp
HERO_FORMATION_COMP = "app/ui/common/component/hero_formation_comp",
} }
GConst.ATLAS_PATH = { GConst.ATLAS_PATH = {

View File

@ -0,0 +1,47 @@
-- 英雄编队
local HeroFormationComp = class("HeroFormationComp", LuaComponent)
function HeroFormationComp:init()
local uiMap = self.baseObject:genAllChildren()
self.heroCells = {
uiMap["hero_formation_comp.hero_cell_1"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
uiMap["hero_formation_comp.hero_cell_2"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
uiMap["hero_formation_comp.hero_cell_3"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
uiMap["hero_formation_comp.hero_cell_4"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
uiMap["hero_formation_comp.hero_cell_5"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
}
end
function HeroFormationComp:refresh()
-- todo 传参控制显示对手还是自己的编队
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:setVisible(true, 1)
heroCell:refresh(heroEntity)
heroCell:addClickListener(function()
ModuleManager.HeroManager:showHeroDetailUI(heroEntity:getCfgId())
end)
else
heroCell:setVisible(false)
end
else
heroCell:setVisible(false)
end
end
end
function HeroFormationComp:setFormationVisible(visible)
self.baseObject:setVisible(visible)
end
function HeroFormationComp:getFormationPosY()
return self.baseObject:fastGetAnchoredPositionY()
end
return HeroFormationComp

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 313e4030686a03942908f4e6796b6ab6
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -174,23 +174,16 @@ function MainComp:getCurRightModuleIdx()
end end
function MainComp:initStageFormation() function MainComp:initStageFormation()
self.heroCells = { self.heroCells = self.uiMap["main_comp.hero_formation_comp"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_FORMATION_COMP)
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),
}
self.heroFormation = self.uiMap["main_comp.hero_bg"] local heroBgPosY = self.heroCells:getFormationPosY()
local heroBgPosY = self.heroFormation:fastGetAnchoredPositionY()
local sWidth, sHeight = GFunc.getUIExpandScreenSize() local sWidth, sHeight = GFunc.getUIExpandScreenSize()
local hSHeight = sHeight / 2 local hSHeight = sHeight / 2
self.btnPosY = (heroBgPosY + (BOTTOM_HEIGHT / 2 - hSHeight)) / 2 self.btnPosY = (heroBgPosY + (BOTTOM_HEIGHT / 2 - hSHeight)) / 2
end end
function MainComp:setFormationVisible(visible) function MainComp:setFormationVisible(visible)
self.heroFormation:setVisible(visible) self.heroCells:setFormationVisible(visible)
end end
function MainComp:refresh() function MainComp:refresh()
@ -218,23 +211,7 @@ function MainComp:refreshDungeon()
end end
function MainComp:refreshStageFormaion() function MainComp:refreshStageFormaion()
local formation = DataManager.FormationData:getStageFormation() self.heroCells:refresh()
for i, heroCell in ipairs(self.heroCells) do
if formation[i] then
local heroEntity = DataManager.HeroData:getHeroById(formation[i])
if heroEntity then
heroCell:setVisible(true, 1)
heroCell:refresh(heroEntity)
heroCell:addClickListener(function()
ModuleManager.HeroManager:showHeroDetailUI(heroEntity:getCfgId())
end)
else
heroCell:setVisible(false)
end
else
heroCell:setVisible(false)
end
end
end end
function MainComp:getDailyChallengeIconPos() function MainComp:getDailyChallengeIconPos()