local HeroDetailUI = class("HeroDetailUI", BaseUI) local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR local SKILL_BUFF_BG = { [2] = "frame_1", [3] = "frame_2", [4] = "frame_3", } function HeroDetailUI:isFullScreen() return false end function HeroDetailUI:getPrefabPath() return "assets/prefabs/ui/hero/hero_detail_ui.prefab" end function HeroDetailUI:ctor(parmas) local heroId = parmas.heroId self.heroEntity = DataManager.HeroData:getHeroById(heroId) end function HeroDetailUI:onLoadRootComplete() self:_display() self:_addListeners() self:_bind() end function HeroDetailUI:_display() local uiMap = self.root:genAllChildren() uiMap["hero_detail_ui.bg.title_desc"]:setText(self.heroEntity:getName()) uiMap["hero_detail_ui.bg.lv_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv())) uiMap["hero_detail_ui.bg.element_desc"]:setText(ModuleManager.HeroManager:getMatchTypeName(self.heroEntity:getMatchType())) uiMap["hero_detail_ui.bg.skill_desc"]:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getActiveSkill())) uiMap["hero_detail_ui.bg.hp_name"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2)) uiMap["hero_detail_ui.bg.atk_name"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3)) uiMap["hero_detail_ui.bg.skill_icon"]:setSprite(GConst.ATLAS_PATH.ICON_SKILL, ModuleManager.HeroManager:getSkillIcon(self.heroEntity:getActiveSkill())) uiMap["hero_detail_ui.bg.hero_icon"]:setSprite(GConst.ATLAS_PATH.ICON_HERO, self.heroEntity:getIcon()) uiMap["hero_detail_ui.bg.hero_element"]:setSprite(GConst.ATLAS_PATH.ICON_HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType())) local materials = self.heroEntity:getLvUpMaterials() or {} local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFramentId()) local needFragmentCount = materials[1] or 1 uiMap["hero_detail_ui.bg.fragment_num"]:setText(fragmentCount .. "/" .. needFragmentCount) uiMap["hero_detail_ui.bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount local activeCount = self.heroEntity:getActiveRogueCount() local skillList = self.heroEntity:getRogueSkillList() local skillLvs = ModuleManager.HeroManager:getActiveRogueLvs() for i = 1, 3 do local skillId = skillList[i] if skillId then local skillIcon = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".icon"] local skillBg = uiMap["hero_detail_ui.bg.skill_up_" .. i] local skillLv = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".desc"] skillBg:addClickListener(function() ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId), skillIcon) end) skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueBg(skillId)) skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueIcon(skillId)) skillBg:setImageGray(i > activeCount) skillBg:setTouchEnable(true) if i > activeCount then skillLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, skillLvs[i] or 0)) else skillLv:setText(GConst.EMPTY_STRING) end end end uiMap["hero_detail_ui.bg.fragment_bg"]:setVisible(not self.heroEntity:isMaxLv()) local canLvUp = self.heroEntity:canLvUp() uiMap["hero_detail_ui.bg.fragment_bg.arrow"]:setVisible(canLvUp) uiMap["hero_detail_ui.bg.fragment_icon"]:setVisible(not canLvUp) local lv = self.heroEntity:getLv() local str local hpStr local atkStr if self.heroEntity:isActived() then str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4) local curHp = self.heroEntity:getCfgHp() // DEFAULT_FACTOR local curAtk = self.heroEntity:getCfgAtk() // DEFAULT_FACTOR local addHp = self.heroEntity:getCfgHp(lv + 1) // DEFAULT_FACTOR - curHp local addAtk = self.heroEntity:getCfgAtk(lv + 1) // DEFAULT_FACTOR - curAtk if addHp <= 0 then hpStr = curHp else hpStr = curHp .. "+" .. addHp .. "" end if addAtk <= 0 then atkStr = curAtk else atkStr = curAtk .. "+" .. addAtk .. "" end else str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_5) hpStr = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR atkStr = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR end uiMap["hero_detail_ui.bg.up_btn.desc"]:setText(str) uiMap["hero_detail_ui.bg.up_btn.num"]:setText(materials[2]) uiMap["hero_detail_ui.bg.up_btn.rp"]:setVisible(self.heroEntity:canLvUp()) uiMap["hero_detail_ui.bg.hp"]:setText(hpStr) uiMap["hero_detail_ui.bg.atk"]:setText(atkStr) uiMap["hero_detail_ui.bg.up_btn"]:setImageGray(not GFunc.checkCost(GConst.ItemConst.ITEM_ID_GOLD, materials[2] or 0)) uiMap["hero_detail_ui.bg.up_btn"]:setActive(not self.heroEntity:isMaxLv()) end function HeroDetailUI:_addListeners() local uiMap = self.root:genAllChildren() uiMap["hero_detail_ui.bg.back_btn"]:addClickListener(function() self:closeUI() end) uiMap["hero_detail_ui.bg.up_btn"]:addClickListener(function() ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity) end) end function HeroDetailUI:_bind() self:bind(self.heroEntity, "lv", function() self:_display() end) end return HeroDetailUI