local UIAssistanceInfoTips = UIViewClass() local HeadImgPath = ConstAssetPathConfig.HeadImgPath local ShowAttrNum = 13 function UIAssistanceInfoTips:OnOpened(context) local formationIndex = context.FormationIndex local mainHeroId = context.heroIdList[context.MainHeroIndex] local subHeroId = context.heroIdList[context.SubHeroIndex] local isHeroFormation = context.isHeroFormation == true self.state_Title:SetState(formationIndex - 1) self.mainHeroAttrs = nil self.mainHeroGs = 0 UIUtils.SetActive(self.group_TeamFormation.img_MainHeroHead, mainHeroId and mainHeroId > 0) if mainHeroId and mainHeroId > 0 then self.mainHeroAttrs = MDL.HeroDetail.GetTotalAttr(mainHeroId) self.mainHeroGs = isHeroFormation and MDL.Player.GetHeroLinUpPower()[context.MainHeroIndex] or MDL.HeroSelect.GetHeroGs(mainHeroId) UTL.Item.SetHeroIconByHeroId(self.group_TeamFormation.img_MainHeroHead, mainHeroId, MDL.HeroAwaken.GetIsHeroAwaken(mainHeroId)) end self.subHeroAttrs = nil self.subHeroGs = 0 UIUtils.SetActive(self.group_TeamFormation.img_AssistantHeroHead, subHeroId and subHeroId > 0) if subHeroId and subHeroId > 0 then self.subHeroAttrs = MDL.HeroDetail.GetTotalAttr(subHeroId) self.subHeroGs = isHeroFormation and MDL.Player.GetHeroLinUpPower()[context.SubHeroIndex] or MDL.HeroSelect.GetHeroGs(subHeroId) UTL.Item.SetHeroIconByHeroId(self.group_TeamFormation.img_AssistantHeroHead, subHeroId, MDL.HeroAwaken.GetIsHeroAwaken(subHeroId)) end self.formationInfo = MDL.AssistanceFight.GetFormationInfo(formationIndex) self.power = 0 for _, slotInfo in ipairs (self.formationInfo) do if slotInfo.data ~= nil then self.power = self.power + slotInfo.data.gs end end self.amountGS = isHeroFormation and MDL.Player.GetFormationGS(formationIndex) or (self.mainHeroGs + self.subHeroGs + self.power) if self.mainHeroAttrs then self.LoopScroll_BasicProperties:AddData(0, 0) for i = 1, ShowAttrNum do self.LoopScroll_BasicProperties:AddData(i, 0) end end end function UIAssistanceInfoTips:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_BasicProperties then if data == 0 then -- 显示战力 UIUtils.SetLabelText(cellTable.lab_Name, Const_IDS["IDS_Team_TotalCapacity"]) UTL.Item.SetAtlasSprite(cellTable.img_Attributes, "UI_Team", "zd_icon_zdz") UIUtils.SetLabel(cellTable.txt_TeamAttributes, self.amountGS) UIUtils.SetLabel(cellTable.txt_MainHero, self.mainHeroGs) UIUtils.SetLabel(cellTable.txt_SubHero, self.subHeroGs) UIUtils.SetLabel(cellTable.txt_AssistantHero, self.power) return end local attrData = DataSheetManager.AttrData:GetDataByID(data) UTL.Item.SetAtlasSprite(cellTable.img_Attributes, "UI_Common", attrData.Icon) UIUtils.SetLabelText(cellTable.lab_Name, Const_IDS[attrData.Name]) local mainAttrValue = self.mainHeroAttrs[data] local subAttrValue = self.subHeroAttrs and self.subHeroAttrs[data] or 0 local assistanceAttrValue = 0 for _, slotInfo in ipairs (self.formationInfo) do if slotInfo.data ~= nil then -- 特殊处理 服务器把下标0的也发过来了 所以向后偏移一个下标 只有助战的属性这么处理 if slotInfo.data.attrs and slotInfo.data.attrs[data + 1] then assistanceAttrValue = assistanceAttrValue + slotInfo.data.attrs[data + 1] end end end assistanceAttrValue = math.floor(assistanceAttrValue + 0.5) UIUtils.SetLabel(cellTable.txt_TeamAttributes, mainAttrValue + subAttrValue + assistanceAttrValue) UIUtils.SetLabel(cellTable.txt_MainHero, mainAttrValue) UIUtils.SetLabel(cellTable.txt_SubHero, subAttrValue) UIUtils.SetLabel(cellTable.txt_AssistantHero, assistanceAttrValue) end end function UIAssistanceInfoTips:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.LoopScroll_BasicProperties then if data > 0 then local attrData = DataSheetManager.AttrData:GetDataByID(data) UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel, { target = cellTable.img_Attributes, posType = LuaConst.DescriptionPanelType.LeftLower, offsetX = 100, text = Const_IDS[attrData.AttrDesc] }) end end end function UIAssistanceInfoTips:OnBackButtonPressed() self:OnButtonClicked(self.close) end function UIAssistanceInfoTips:OnButtonClicked(comp) if comp == self.Bottom or comp == self.close then self:CloseView() end end return UIAssistanceInfoTips