56 lines
2.0 KiB
Lua
56 lines
2.0 KiB
Lua
local HeroTrialUI = class("HeroTrialUI", BaseUI)
|
|
|
|
function HeroTrialUI:isFullScreen()
|
|
return false
|
|
end
|
|
|
|
function HeroTrialUI:getPrefabPath()
|
|
return "assets/prefabs/ui/main_city/hero_trial_ui.prefab"
|
|
end
|
|
|
|
function HeroTrialUI:ctor(params)
|
|
self.heroId = params.heroId
|
|
self.chapterId = params.chapterId
|
|
end
|
|
|
|
function HeroTrialUI:onClose()
|
|
if self.trialAtkInfo then
|
|
DataManager.ChapterData:setChapterId(self.chapterId)
|
|
ModuleManager.ChapterManager:startFight(true)
|
|
DataManager.ChapterData:MarkTrailHero()
|
|
end
|
|
end
|
|
|
|
function HeroTrialUI:onLoadRootComplete()
|
|
local uiMap = self.root:genAllChildren()
|
|
uiMap["hero_trial_ui.bg.desc_text"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_TRIAL_DESC_1))
|
|
uiMap["hero_trial_ui.bg.func_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_TRIAL_DESC_2))
|
|
uiMap["hero_trial_ui.bg.title_bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_TRIAL_DESC_3))
|
|
uiMap["hero_trial_ui.bg.func_btn"]:addClickListener(function()
|
|
self:buildTrailParams()
|
|
self:closeUI()
|
|
end)
|
|
uiMap["hero_trial_ui.close_btn"]:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
end
|
|
|
|
function HeroTrialUI:buildTrailParams()
|
|
local heroEntity = DataManager.HeroData:getHeroById(self.heroId)
|
|
local trailHeroEntity = DataManager.HeroData:getEntity({id = self.heroId, level = heroEntity:getBeginLv()})
|
|
self.trialAtkInfo = {}
|
|
local formation = DataManager.FormationData:getStageFormation()
|
|
for elementType, heroId in pairs(formation) do
|
|
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
|
if heroEntity then
|
|
if heroEntity:getMatchType() == trailHeroEntity:getMatchType() then
|
|
self.trialAtkInfo[elementType] = trailHeroEntity
|
|
else
|
|
self.trialAtkInfo[elementType] = heroEntity
|
|
end
|
|
end
|
|
end
|
|
DataManager.ChapterData:cacheTrailAtkInfo(self.trialAtkInfo)
|
|
end
|
|
|
|
return HeroTrialUI |