c1_lua/lua/app/ui/arena/arena_formation_ui.lua
2025-09-23 19:55:35 +08:00

98 lines
3.1 KiB
Lua

-- 竞技场:调整阵容
local ArenaFormationUI = class("ArenaFormationUI", BaseUI)
function ArenaFormationUI:isFullScreen()
return true
end
function ArenaFormationUI:showCommonBG()
return false
end
function ArenaFormationUI:getPrefabPath()
return "assets/prefabs/ui/arena/arena_formation_ui.prefab"
end
function ArenaFormationUI:onPressBackspace()
self:closeUI()
end
function ArenaFormationUI:getCurrencyParams()
if self.currencyParams == nil then
self.currencyParams = {
itemIds = {
GConst.ItemConst.ITEM_ID_GEM,
GConst.ItemConst.ITEM_ID_ARENA_TICKET
},
showType = GConst.CURRENCY_TYPE.HORIZONTAL
}
end
return self.currencyParams
end
function ArenaFormationUI:ctor(params)
self.formationType = params.type
self.fromMatch = params.fromMatch
end
function ArenaFormationUI:onCover()
end
function ArenaFormationUI:onReshow()
end
function ArenaFormationUI:onClose()
end
function ArenaFormationUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
uiMap["arena_formation_ui.banner.btn_ok.tx_ok"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_24))
uiMap["arena_formation_ui.banner.btn_ok"]:addClickListener(function()
ModuleManager.FormationManager:reqArenaFormation()
if self.fromMatch then
UIManager:showUI("app/ui/arena/arena_match_ui")
end
self:closeUI()
end)
self.selectAttack = uiMap["arena_formation_ui.banner.btn_attack.img_select"]
uiMap["arena_formation_ui.banner.btn_attack.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_10))
uiMap["arena_formation_ui.banner.btn_attack"]:addClickListener(function()
self.formationType = GConst.BattleConst.FORMATION_TYPE.ARENA_ATTACK
self:onRefresh()
self.heroComp:hideLargeHeroCell()
end)
self.selectDefend = uiMap["arena_formation_ui.banner.btn_defend.img_select"]
uiMap["arena_formation_ui.banner.btn_defend.tx_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_9))
uiMap["arena_formation_ui.banner.btn_defend"]:addClickListener(function()
self.formationType = GConst.BattleConst.FORMATION_TYPE.ARENA_DEFEND
self:onRefresh()
self.heroComp:hideLargeHeroCell()
end)
local heroUI = uiMap["arena_formation_ui.hero_ui"]
heroUI:initPrefabHelper()
heroUI:genAllChildren()
self.heroComp = heroUI:addLuaComponent("app/ui/hero/hero_comp")
CellManager:addCellComp(uiMap["arena_formation_ui.player_info_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_INFO_CELL):refresh()
self:bind(DataManager.HeroData, "isDirty", function()
self:onRefresh()
end)
self:bind(DataManager.BagData.ItemData, "dirty", function()
self:onRefresh()
end)
self:addEventListener(EventManager.CUSTOM_EVENT.GO_SHOP, function()
self:closeUI()
end)
end
function ArenaFormationUI:onRefresh()
self.selectAttack:setActive(self.formationType == GConst.BattleConst.FORMATION_TYPE.ARENA_ATTACK)
self.selectDefend:setActive(self.formationType == GConst.BattleConst.FORMATION_TYPE.ARENA_DEFEND)
self.heroComp:refresh(self.formationType)
end
return ArenaFormationUI