local UIWarHorseAttrInfoView = UIViewClass() function UIWarHorseAttrInfoView:OnOpened(context) local activeInfo = MDL.WarHorse.GetInfoByID(context.horseId) local horseData = DataSheetManager.HorseData:GetDataByHorseID(context.horseId) local baseAttrTable = horseData.Attr_Table --图标和名字 UIUtils.SetLabelText(self.txt_ItemName, Const_IDS[horseData.HorseName]) UIUtils.SetImageByAssetBundle(self.img_TreasureIcon, horseData.HorseIcon) if self.loop_TreasureInfoAttr.Count > 0 then self.loop_TreasureInfoAttr:ClearCells() end if activeInfo then --战力 self.txt_CE.text = activeInfo.HorseInfo.gs --属性 self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_8"}, 0) for i = 1, #activeInfo.HorseInfo.attr.attrs do local attrNum = activeInfo.HorseInfo.attr.attrs[i] if attrNum > 0 then self.loop_TreasureInfoAttr:AddData({AttrType = i, AttrNum = math.floor(attrNum + 0.5)}, 1) end end --基础属性 self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_10"}, 0) for i = 1, #baseAttrTable do self.loop_TreasureInfoAttr:AddData({AttrType = baseAttrTable[i].AttrType, AttrNum = baseAttrTable[i].AttrNum}, 1) end --突破属性 local isHasBreak = false local attrs = activeInfo.HorseInfo.horseBreakAttr.attrs for i = 1, #attrs do if attrs[i] > 0 then if not isHasBreak then self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_9"}, 0) isHasBreak = true end self.loop_TreasureInfoAttr:AddData({AttrType = i, AttrNum = attrs[i]}, 1) end end --魂珠属性 local attrs, isEquiped = CTL.HorseSoul.GetHorseSoulAttrs(context.horseId) if isEquiped then self.loop_TreasureInfoAttr:AddData({IDS = "IDS_HorseEquip_Hint_28"}, 0) for _, v in ipairs(attrs) do local attrNum = math.floor(v.AttrNum * MDL.HorseSoul.GetHorsePictorialAdd() + 0.5) self.loop_TreasureInfoAttr:AddData({AttrType = v.AttrType, AttrNum = attrNum}, 1) end end --战装属性 local attrs, isEquiped = CTL.HorseEquip.GetHorseAttr(context.horseId) if isEquiped then self.loop_TreasureInfoAttr:AddData({IDS = "IDS_HorseEquip_Hint_27"}, 0) for _, v in ipairs(attrs) do self.loop_TreasureInfoAttr:AddData(v, 1) end end else --战力 local fight = UTL.Attr.CalculateFight(baseAttrTable) self.txt_CE.text = fight self.loop_TreasureInfoAttr:AddData({IDS = "IDS_Treasure_Information_10"}, 0) --属性 for i = 1, #baseAttrTable do self.loop_TreasureInfoAttr:AddData({AttrType = baseAttrTable[i].AttrType, AttrNum = baseAttrTable[i].AttrNum}, 1) end end end function UIWarHorseAttrInfoView:OnBackButtonPressed() self:OnButtonClicked(self.btn_Bottom) end function UIWarHorseAttrInfoView:OnButtonClicked(comp) if comp == self.btn_Bottom or comp == self.btn_Close then self:CloseView() end end function UIWarHorseAttrInfoView:OnCellInit(scrollRect, index, cellTable, data) if data.IDS then UIUtils.SetLabelText(cellTable.txt_CellTitle, Const_IDS[data.IDS]) else UTL.Attr.SetAttrItemByCompName(cellTable, data.AttrType, data.AttrNum, true) end end return UIWarHorseAttrInfoView