local UIHeroRelationActivePopUp = UIViewClass() local ANIM_TIME = 0.2 function UIHeroRelationActivePopUp:OnOpened(context) UIUtils.SetLabelText(self.UITemplatePopUpZero.txt_Title, Const_IDS[context.titleIDS]) local infos = context.infoArray self:UpdateInfo(infos) CTL.Sound.PlayGameSound("UI_completion") end function UIHeroRelationActivePopUp:OnUpdateFun(deltaTime, timeSinceUpdate) if #self.context.infoArray > 1 then self.obj_state:SetState(1) else self.obj_state:SetState(0) end end function UIHeroRelationActivePopUp:UpdateInfo(infos) if #infos > 1 then self.obj_state:SetState(0) self.loop_More:ReloadAll(infos) else self.obj_state:SetState(1) local info = infos[1] self.txt_RelationName.text = self:GetTitleContent(info) local relationData = DataSheetManager.HeroRelation:GetDataByID_Level(info.relationId, info.relationLevel) self.loop_HeroOne:AddData(info.heroId, 0) for _, v in ipairs(relationData.Activation) do self.loop_HeroOne:AddData(v, 0) end self.loop_Attr:ReloadAll(relationData.Attr_Table) end self:StartRepeatFunc(self.OnUpdateFun, ANIM_TIME, -1, true, false) end function UIHeroRelationActivePopUp:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_HeroOne then self:SetHeroItemWithBreakLev(cellTable, data) elseif scrollRect == self.loop_Attr then UTL.Attr.SetAttrItemByCompName(cellTable, data.AttrType, data.AttrNum, true, true) elseif scrollRect == self.loop_More then cellTable.txt_RelationName.text = self:GetTitleContent(data) local relationData = DataSheetManager.HeroRelation:GetDataByID_Level(data.relationId, data.relationLevel) --武将头像 local maxNum = 1 + #relationData.Activation for i = 1, maxNum do local comp = cellTable.content_Hero[i] if not comp then self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.content_Hero, self.heroItem.gameObject) comp = cellTable.content_Hero[i] end local heroId if i == 1 then heroId = data.heroId else heroId = relationData.Activation[i - 1] end self:SetHeroItemWithBreakLev(comp, heroId) end for i = maxNum + 1, #cellTable.content_Hero do UIUtils.SetActive(cellTable.content_Hero[i].gameObject, false) end --属性 local attrTable = relationData.Attr_Table local attrNum = #attrTable for i = 1, attrNum do local attr = attrTable[i] local comp = cellTable.content_Attr[i] if not comp then self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.content_Attr, self.cell_Attr.gameObject) comp = cellTable.content_Attr[i] end UIUtils.SetActive(comp.gameObject, true) UTL.Attr.SetAttrItemByCompName(comp, attr.AttrType, attr.AttrNum, true, true) end for i = attrNum + 1, #cellTable.content_Attr do UIUtils.SetActive(cellTable.content_Attr[i].gameObject, false) end end end function UIHeroRelationActivePopUp:OnButtonClicked(comp) if comp == self.UITemplatePopUpZero.Bottom then self:CloseView() end end function UIHeroRelationActivePopUp:GetTitleContent(info) local heroData = DataSheetManager.HeroNum:GetDataByID(info.heroId) local relationData = DataSheetManager.HeroRelation:GetDataByID_Level(info.relationId, info.relationLevel) local levelShow = string.FormatByIdsId(Const_IDS.IDS_HeroRelation_DengJi, info.relationLevel) local heroName = UIUtils.GetLocalizedTxt(Const_IDS[heroData.NameIDS]) local relationName = UIUtils.GetLocalizedTxt(Const_IDS[relationData.HeroRelationName]) return string.format("%s %s %s", heroName, relationName, levelShow) end function UIHeroRelationActivePopUp:SetHeroItemWithBreakLev(heroItem, heroId) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) if MDL.HeroAwaken.GetIsHeroAwaken(heroId) then UTL.Item.SetItemCell(heroItem.baseItem, CTL.HeroAwaken.GetItemIconId(heroId)) else UTL.Item.SetItemCell(heroItem.baseItem, heroData.HeroItem) end local heroBreak = MDL.HeroStar.GetHeroStarLevel(heroId) if heroBreak == 0 then UIUtils.SetActive(heroItem.bg_Break, false) else UIUtils.SetActive(heroItem.bg_Break, true) UIUtils.SetLabel(heroItem.lab_Break, "+" .. heroBreak) end UIUtils.SetActive(heroItem.gameObject, true) end return UIHeroRelationActivePopUp