local UIHeroDetailRelation = UIViewClass() function UIHeroDetailRelation:OnCreated() UIUtils.SetActive(self.group_RelationTipsMask, false) UIUtils.SetActive(self.group_Tip, false) end function UIHeroDetailRelation:OnOpened(context) self:RegistSystemEvent(EventID.UI_HeroShow_UpdateHeroShow, self.UpdateInfo) self:RegistSystemEvent(EventID.UI_HeroRelation_Refresh, self.UpdateInfo) self.activeConfigList = {} self:UpdateInfo() end function UIHeroDetailRelation:UpdateInfo() CTL.HeroSelect.UpdateSortedRelationList(MDL.HeroSelect.curSelectHeroID, self.activeConfigList) self.loop_Relation:ReloadAll(self.activeConfigList) end function UIHeroDetailRelation:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Relation then UIUtils.SetLabelText(cellTable.txt_Title, Const_IDS[data.HeroRelationName]) local lev = MDL.HeroSelect.GetRelationLev(MDL.HeroSelect.curSelectHeroID, data.ID) if lev > 0 then cellTable.obj_state:SetState(1) cellTable.txt_Lv.text = string.FormatByIdsId(Const_IDS.IDS_HeroRelation_DengJi, lev) local config = DataSheetManager.HeroRelation:GetDataByID_Level(data.ID, lev) self:SetCellAttr(config.Attr_Table, cellTable.cell.gameObject, cellTable.content_Attr, self.relationAttrItem.gameObject) else cellTable.obj_state:SetState(0) cellTable.txt_Lv.text = nil for i = 1, #cellTable.content_Attr do UIUtils.SetActive(cellTable.content_Attr[i].gameObject, false) end end --武将头像 local maxNum = 1 + #data.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 = MDL.HeroSelect.curSelectHeroID else heroId = data.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 elseif scrollRect == self.loop_Hero then self:SetHeroItemWithBreakLev(cellTable, data) elseif scrollRect == self.loop_RelationTipsItem then cellTable.txt_Lv.text = string.FormatByIdsId(Const_IDS.IDS_HeroRelation_DengJi, data.Level) if data.Level == 1 then UIUtils.SetLabelText(cellTable.txt_Limit, Const_IDS.IDS_HeroRelation_JiHuoYaoQiu) else cellTable.txt_Limit.text = string.FormatByIdsId(Const_IDS.IDS_HeroRelation_ShengJiYaoQiu, data.LevelUp) end local curLev = MDL.HeroSelect.GetRelationLev(MDL.HeroSelect.curSelectHeroID, data.ID) if curLev > data.Level then cellTable.obj_state:SetState(2) elseif curLev == data.Level then cellTable.obj_state:SetState(1) else cellTable.obj_state:SetState(0) end self:SetCellAttr(data.Attr_Table, cellTable.cell.gameObject, cellTable.content_TipsAttr, self.relationAttrItem.gameObject) end end function UIHeroDetailRelation:SetHeroItemWithBreakLev(heroItem, heroId) local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) local isAwaken = MDL.HeroAwaken.GetIsHeroAwaken(heroId) if isAwaken then UTL.Item.SetItemCell(heroItem.baseItem, CTL.HeroAwaken.GetItemIconId(heroId)) UIUtils.SetActive(heroItem.baseItem.group_Shard, false) else UTL.Item.SetItemCell(heroItem.baseItem, heroData.HeroItem, nil, nil, nil, MDL.HeroSelect.IsHasHero(heroId)) end if isAwaken then UIUtils.SetActive(heroItem.bg_Break, true) local awakenLevel = MDL.HeroAwaken.GetCurStar(heroId) UIUtils.SetLabel(heroItem.lab_Break, string.FormatByIdsId(Const_IDS["IDS_HeroAwaken_AwakenLevelNum"], awakenLevel)) else 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 end if heroItem.txt_Name then UIUtils.SetLabelText(heroItem.txt_Name,Const_IDS[heroData.NameIDS]) end UIUtils.SetActive(heroItem.img_Gray, not MDL.HeroSelect.IsHasHero(heroId)) UIUtils.SetActive(heroItem.gameObject, true) end function UIHeroDetailRelation:SetCellAttr(attrTable, cellRectObj, cellContent, cellSourceObj) local attrNum = #attrTable for i = 1, attrNum do local attr = attrTable[i] local comp = cellContent[i] if not comp then self:InstantiateCellCollection(cellRectObj, cellContent, cellSourceObj) comp = cellContent[i] end UIUtils.SetActive(comp.gameObject, true) UTL.Attr.SetAttrItemByCompName(comp, attr.AttrType, attr.AttrNum, true, true) end for i = attrNum + 1, #cellContent do UIUtils.SetActive(cellContent[i].gameObject, false) end end function UIHeroDetailRelation:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.btn_Info then self:ShowRelationTips(data) end end function UIHeroDetailRelation:OnButtonClicked(comp) if comp == self.group_RelationTipsMask then UIUtils.SetActive(self.group_RelationTipsMask, false) UIUtils.SetActive(self.group_Tip, false) end end function UIHeroDetailRelation:ShowRelationTips(data) UIUtils.SetActive(self.group_RelationTipsMask, true) UIUtils.SetActive(self.group_Tip, true) UIUtils.SetLabelText(self.txt_Name, Const_IDS[data.HeroRelationName]) self.loop_Hero:ReloadAll(data.Activation) self.loop_Hero:InsertData(0, MDL.HeroSelect.curSelectHeroID, 0) self.loop_RelationTipsItem:ClearCells() for i, v in DataSheetManager.HeroRelation:GetDataByID_Level(data.ID) do self.loop_RelationTipsItem:AddData(v, 0) end end return UIHeroDetailRelation