local UIHeroBreakSuccess = UIViewClass() function UIHeroBreakSuccess:OnOpened(context) if context.isWarHorse then self:SetHorseInfo(context.horseId) UIUtils.SetActive(self.group_Info.gameObject,true) UIUtils.SetActive(self.ImageKuang,false) else local heroId = context[1] self:ShowHeroBreakInfo(heroId) CTL.Sound.PlayGameSound("UI_breakthrough_03") UIUtils.SetActive(self.group_Info.gameObject,true) end UIUtils.SetLabel(self.UITemplatePopUpZero.txt_Title, UIUtils.GetLocalizedTxt(Const_IDS.IDS_MagicWeapon_SmallStar)) end function UIHeroBreakSuccess:OnClosed() CTL.FormationResonance.OpenSubResonanceLevelUp() end function UIHeroBreakSuccess:SetAttrLabel() local attrHpData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.hplmt) local attrAtkData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.atk) local attrDefData = DataSheetManager.AttrData:GetDataByID(LuaConst.AttrTypeId.def) UTL.Attr.SetAttrIconByAttrIcon(self.group_Info.group_Hp.img_Icon, attrHpData.Icon) UTL.Attr.SetAttrIconByAttrIcon(self.group_Info.group_Atk.img_Icon, attrAtkData.Icon) UTL.Attr.SetAttrIconByAttrIcon(self.group_Info.group_Def.img_Icon, attrDefData.Icon) UIUtils.SetLabel(self.group_Info.group_Hp.Lab_Hp, string.FormatByIdsId(Const_IDS.IDS_HeroStarGrowth, UIUtils.GetLocalizedTxt(Const_IDS[attrHpData.Name]))) UIUtils.SetLabel(self.group_Info.group_Atk.Lab_Atk, string.FormatByIdsId(Const_IDS.IDS_HeroStarGrowth, UIUtils.GetLocalizedTxt(Const_IDS[attrAtkData.Name]))) UIUtils.SetLabel(self.group_Info.group_Def.Lab_Def, string.FormatByIdsId(Const_IDS.IDS_HeroStarGrowth, UIUtils.GetLocalizedTxt(Const_IDS[attrDefData.Name]))) end function UIHeroBreakSuccess:SetAttrNum(attrGroup, oldAttr, newAttr) UIUtils.SetLabel(attrGroup.txt_Old, string.format("%.1f", oldAttr)) UIUtils.SetLabel(attrGroup.txt_New, string.format("%.1f", newAttr)) UIUtils.SetActive(attrGroup.gameObject, true) end function UIHeroBreakSuccess:OnButtonClicked(comp) if comp == self.UITemplatePopUpZero.Bottom then self:CloseView() end end function UIHeroBreakSuccess:ShowHeroBreakInfo(heroId) local heroStar = MDL.HeroStar.GetHeroStarLevel(heroId) UIUtils.SetLabel(self.txt_OldStar, string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, heroStar - 1)) UIUtils.SetLabel(self.txt_NewStar, string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, heroStar)) local starData = DataSheetManager.HeroStar:GetDataByHeroID_Star(heroId, heroStar) if starData.StarType == LuaConst.UIBreakStarType.Attrs then self.txtState:SetState(0) for i, comp in ipairs(self.group_Attrs) do local attrTxt = CTL.HeroStar.GetHeroBreakAttrText(heroId, heroStar)[i] UIUtils.SetLabel(comp, attrTxt) end else self.txtState:SetState(1) local developEffectData = DataSheetManager.DevelopEffectData:GetDataByID(starData.DevelopEffectID) local iconPath = ConstAssetPathConfig.skillPath .. developEffectData.Icon .. ".png" UIUtils.SetImageByAssetBundle(self.ImageSkillIcon, iconPath) local name, desc = MDL.HeroStar.GetTalentNameAndDesc(starData.DevelopEffectID) self.txt_DevelopEffectInfo.text = desc local level = MDL.HeroStar.GetHeroTalentLevel(heroId, starData.DevelopEffectID) UIUtils.SetActive(self.group_Level.gameObject, level > 0) self.txt_Lv.text = level end local attrTypeId = MDL.HeroSelect.GetHeroLevelAttrID(heroId) local newAtk, newDef, newHp = MDL.HeroSelect.GetAtkDefHpGrowNumber(attrTypeId, heroStar) local oldAtk, oldDef, oldHp = MDL.HeroSelect.GetAtkDefHpGrowNumber(attrTypeId, heroStar - 1) self:SetAttrLabel() self:SetAttrNum(self.group_Info.group_Hp, oldHp, newHp) self:SetAttrNum(self.group_Info.group_Atk, oldAtk, newAtk) self:SetAttrNum(self.group_Info.group_Def, oldDef, newDef) end function UIHeroBreakSuccess:SetHorseInfo(horseId) self.txtState:SetState(1) local info = MDL.WarHorse.GetInfoByID(horseId) local starLevel = info.HorseInfo.starLevel UIUtils.SetLabel(self.txt_OldStar, string.FormatByIdsId(Const_IDS.IDS_Horse_Star_2, starLevel - 1)) UIUtils.SetLabel(self.txt_NewStar, string.FormatByIdsId(Const_IDS.IDS_Horse_Star_2, starLevel)) local starConfig = DataSheetManager.HorseStar:GetDataByHorseID_Star(horseId, starLevel - 1) UIUtils.SetLabel(self.txt_DevelopEffectInfo, UTL.String.FormatCombineTextByID(starConfig.StarText)) local attrData = DataSheetManager.HorseStarAttrSpecial:GetDataByAttrRepeatID(starConfig.AttrSpecial).Attr_Table self:SetAttrItem(self.group_Info.group_Hp, self.group_Info.group_Hp.Lab_Hp, attrData[1]) self:SetAttrItem(self.group_Info.group_Atk, self.group_Info.group_Atk.Lab_Atk, attrData[2]) self:SetAttrItem(self.group_Info.group_Def, self.group_Info.group_Def.Lab_Def, attrData[3]) end function UIHeroBreakSuccess:SetAttrItem(attrGroup, attrName, attr) local attrData = DataSheetManager.AttrData:GetDataByID(attr.AttrType) UIUtils.SetLabelText(attrName, Const_IDS[attrData.Name]) UTL.Attr.SetAttrIconByAttrIcon(attrGroup.img_Icon, attrData.Icon) UIUtils.SetLabel(attrGroup.txt_New, "+" .. attr.AttrNum) UIUtils.SetActive(attrGroup.gameObject, true) UIUtils.SetActive(attrGroup.txt_Old, false) UIUtils.SetActive(attrGroup.Arrow, false) end return UIHeroBreakSuccess