local UIRecycleFragmentProperty = UIViewClass() -------------------- function UIRecycleFragmentProperty:OnOpened(context) self:InitPanel() end function UIRecycleFragmentProperty:OnButtonClicked(comp) if comp == self.btn_Close or comp == self.btn_BgClose then self:CloseView() end end function UIRecycleFragmentProperty:OnCellInit(scrollRect, index, cellTable, data) if data.contextIDS then UIUtils.SetLabelText(cellTable.txt_Title, data.contextIDS) elseif data.curAttrData or data.nextAttrData then if data.nextAttrData then local attrData = DataSheetManager.AttrData:GetDataByID(data.nextAttrData.AttrType) local name = UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name]) if data.curAttrData then UIUtils.SetLabel(cellTable.txt_Left, string.FormatByIdsId(Const_IDS.IDS_RFPower_Detail_RFLevelDetail2, name, data.curAttrData.AttrNum * 100)) if data.curAttrData.AttrNum ~= data.nextAttrData.AttrNum then UIUtils.SetLabel(cellTable.txt_Right, string.FormatByIdsId(Const_IDS.IDS_RFPower_Detail_RFLevelDetail1, UTL.Color.FormatGreenColor(data.nextAttrData.AttrNum * 100))) else UIUtils.SetLabel(cellTable.txt_Right, string.FormatByIdsId(Const_IDS.IDS_RFPower_Detail_RFLevelDetail1, data.nextAttrData.AttrNum * 100)) end else UIUtils.SetLabel(cellTable.txt_Left, string.FormatByIdsId(Const_IDS.IDS_RFPower_Detail_RFLevelDetail2, name, 0)) UIUtils.SetLabel(cellTable.txt_Right, string.FormatByIdsId(Const_IDS.IDS_RFPower_Detail_RFLevelDetail1, UTL.Color.FormatGreenColor(data.nextAttrData.AttrNum * 100))) end else local attrData = DataSheetManager.AttrData:GetDataByID(data.curAttrData.AttrType) local name = UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name]) UIUtils.SetLabel(cellTable.txt_Left, string.FormatByIdsId(Const_IDS.IDS_RFPower_Detail_RFLevelDetail2, name, data.curAttrData.AttrNum * 100)) end elseif data.nextLimit then UIUtils.SetLabelText(cellTable.txt_Left, data.areaIds) UIUtils.SetLabel(cellTable.txt_Right, string.FormatByIdsId(Const_IDS.IDS_Team_Zhaomu03, data.nextLimit)) elseif data.AttrType then local attrData = DataSheetManager.AttrData:GetDataByID(data.AttrType) local name = UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name]) UIUtils.SetLabel(cellTable.txt_Left, name) UIUtils.SetLabel(cellTable.txt_Right, string.format("+%s", data.AttrNum)) end end -------------------- function UIRecycleFragmentProperty:InitPanel() if self.loop_Info.Count > 0 then self.loop_Info:ClearCells() end -- 设置纳灵等级 self.loop_Info:AddData({contextIDS = Const_IDS.IDS_RFPower_Detail_RFLevelTitle}, 0) local curLevel = MDL.Reborn.GetRecycleFragmentLevel() local curLevelData = DataSheetManager.RecycleFragmentLevel:GetDataByRecycleFragmentLevel(curLevel) local nextLevelData = DataSheetManager.RecycleFragmentLevel:GetDataByRecycleFragmentLevel(curLevel + 1) -- 设置属性 if nextLevelData then for _, nextAttrData in ipairs(nextLevelData.Attr_Table) do local curAttrData = nil for _, v in ipairs(curLevelData.Attr_Table) do if v.AttrType == nextAttrData.AttrType then curAttrData = v end end self.loop_Info:AddData({curAttrData = curAttrData, nextAttrData = nextAttrData}, 1) end else for _, curAttrData in ipairs(curLevelData.Attr_Table) do self.loop_Info:AddData({curAttrData = curAttrData}, 1) end end -- 设置下一个突破所需 if nextLevelData then self.loop_Info:AddData({contextIDS = Const_IDS.IDS_RFPower_Detail_RFLevelLimit}, 0) if curLevelData.RFAreaLevelLimit_1 > 0 then self.loop_Info:AddData({areaIds = Const_IDS.IDS_RFArea1_Name, nextLimit = curLevelData.RFAreaLevelLimit_1}, 1) end if curLevelData.RFAreaLevelLimit_2 > 0 then self.loop_Info:AddData({areaIds = Const_IDS.IDS_RFArea2_Name, nextLimit = curLevelData.RFAreaLevelLimit_2}, 1) end if curLevelData.RFAreaLevelLimit_3 > 0 then self.loop_Info:AddData({areaIds = Const_IDS.IDS_RFArea3_Name, nextLimit = curLevelData.RFAreaLevelLimit_3}, 1) end end -- 灵区属性加成 self.loop_Info:AddData({contextIDS = Const_IDS.IDS_RFPower_Detail_RFLevelAreaAttr}, 0) local attrList = {} -- 人之灵 加成 local info = MDL.Reborn.GetRFAreaInfoByType(MDL.Reborn.RecycleFragmentType.Man) if info and curLevelData.RFAreaLevelLimit_1 > 0 then local data = DataSheetManager.RecycleFragmentArea:GetDataByRFAreaType_RFAreaLevel_RFAreaLevelPoint(MDL.Reborn.RecycleFragmentType.Man, info.Level, info.Node) for _, v in ipairs(data.Attr_Table) do self:AddAttrData(attrList, v.AttrType, v.AttrNum) end end -- 地之灵 加成 info = MDL.Reborn.GetRFAreaInfoByType(MDL.Reborn.RecycleFragmentType.Earth) if info and curLevelData.RFAreaLevelLimit_2 > 0 then local data = DataSheetManager.RecycleFragmentArea:GetDataByRFAreaType_RFAreaLevel_RFAreaLevelPoint(MDL.Reborn.RecycleFragmentType.Earth, info.Level, info.Node) for _, v in ipairs(data.Attr_Table) do self:AddAttrData(attrList, v.AttrType, v.AttrNum) end end -- 天之灵 加成 info = MDL.Reborn.GetRFAreaInfoByType(MDL.Reborn.RecycleFragmentType.Heaven) if info and curLevelData.RFAreaLevelLimit_3 > 0 then local data = DataSheetManager.RecycleFragmentArea:GetDataByRFAreaType_RFAreaLevel_RFAreaLevelPoint(MDL.Reborn.RecycleFragmentType.Heaven, info.Level, info.Node) for _, v in ipairs(data.Attr_Table) do self:AddAttrData(attrList, v.AttrType, v.AttrNum) end end -- 排序 table.sort(attrList, function(a, b) return a.AttrType < b.AttrType end) for _, v in ipairs(attrList) do self.loop_Info:AddData(v, 1) end end function UIRecycleFragmentProperty:AddAttrData(attrList, attrType, attrNum) for i, v in ipairs(attrList) do if v.AttrType == attrType then v.AttrNum = v.AttrNum + attrNum return end end table.insert(attrList, {AttrType = attrType, AttrNum = attrNum}) end return UIRecycleFragmentProperty