local HeroUnlockUI = class("HeroUnlockUI", BaseUI) function HeroUnlockUI:getPrefabPath() return "assets/prefabs/ui/hero/hero_unlock_ui.prefab" end function HeroUnlockUI:ctor(params) self.heroIdList = params and params.heroIdList end function HeroUnlockUI:onLoadRootComplete() self.uiMap = self.root:genAllChildren() self.uiMap["hero_unlock_ui.bg"]:addClickListener(function() self:closeUI() end) self:initTitleAndDesc() self:initHeroes() end function HeroUnlockUI:initTitleAndDesc() self.uiMap["player_level_up_ui.title_tx"]:setText("临时文本:英雄解锁") self.uiMap["player_level_up_ui.reward_title"]:setText("临时文本:现在可从宝箱中获得") self.uiMap["player_level_up_ui.continue"]:setText("临时文本:点击继续") end function HeroUnlockUI:initHeroes() if self.heroIdList then local count = #self.heroIdList if count > 3 then count = 3 end if count > 0 then for i = 1, count do local heroEntity = DataManager.HeroData:getHeroById(self.heroIdList[i]) self.uiMap["hero_unlock_ui.bg_" .. i]:setVisible(true) local rewardCell = self.uiMap["hero_unlock_ui.bg_" .. i .. ".reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL) rewardCell:refreshItemById(heroEntity:getFragmentId(), 0) self.uiMap["hero_unlock_ui.bg_" .. i .. ".name_tx"]:setText(heroEntity:getName()) self.uiMap["hero_unlock_ui.bg_" .. i .. ".desc_tx"]:setText(heroEntity:getDesc()) end for i = count + 1, 3 do self.uiMap["hero_unlock_ui.bg_" .. i]:setVisible(false) end if count == 1 then self.uiMap["hero_unlock_ui.bg_1"]:setAnchoredPositionY(100) else self.uiMap["hero_unlock_ui.bg_1"]:setAnchoredPositionY(180) end else self:hideAllHeroes() end else self:hideAllHeroes() end end function HeroUnlockUI:hideAllHeroes() self.uiMap["hero_unlock_ui.bg_1"]:setVisible(false) self.uiMap["hero_unlock_ui.bg_2"]:setVisible(false) self.uiMap["hero_unlock_ui.bg_3"]:setVisible(false) end return HeroUnlockUI