local UIPetReproductionStarTip = UIViewClass() local Star_Merge = 4 --星数以下的合并 local Star_Min = 2 function UIPetReproductionStarTip:OnOpened(context) self.data = {} --key:繁殖结果left*10 + right value:一代总星数[left, right] self.sortArray = {} for i, v in DataSheetManager.PetLineage:GetDataByLineageID_LineageType_ParentStar(context.lineageID, 2) do local minStar = v.Lineage_Table[1].LineageStar local maxStar = v.Lineage_Table[#v.Lineage_Table].LineageStar local encodeNum = minStar * 10 + maxStar local data = self.data[encodeNum] if data == nil then table.insert(self.sortArray, encodeNum) self.data[encodeNum] = { [1] = v.ParentStar } else if v.ParentStar > data[1] and data[2] == nil then data[2] = v.ParentStar elseif v.ParentStar > data[1] and v.ParentStar > data[2] then data[2] = v.ParentStar elseif v.ParentStar < data[1] and data[2] == nil then data[2] = data[1] data[1] = v.ParentStar elseif v.ParentStar < data[1] then data[1] = v.ParentStar end end end local tempLeft, tempRight for i, v in ipairs(self.sortArray) do local data = self.data[v] if (data[2] and data[2] <= Star_Merge) or (data[2] == nil and data[1] <= Star_Merge) then self.data[v] = nil local left = math.floor(v / 10) local right = v % 10 if tempLeft == nil or tempLeft > left then tempLeft = left end if tempRight == nil or tempRight < right then tempRight = right end end end local encodeNum = tempLeft * 10 + tempRight self.data[encodeNum] = { [1] = Star_Min, [2] = Star_Merge, } table.insert(self.sortArray, 1, encodeNum) for i = #self.sortArray, 1, -1 do if self.data[self.sortArray[i]] then self.scroll_Details:AddData(self.sortArray[i], 0) end end end function UIPetReproductionStarTip:OnCellInit(scrollRect, index, cellTable, data) local left = math.floor(data / 10) local right = data % 10 cellTable.txt_Star02.text = left .. "-" .. right local result = self.data[data] if #result > 1 then cellTable.txt_Star01.text = result[1] .. "-" .. result[2] else cellTable.txt_Star01.text = result[1] end end function UIPetReproductionStarTip:OnBackButtonPressed() self:OnButtonClicked(self.btn_CloseTips) end function UIPetReproductionStarTip:OnButtonClicked(comp) if comp == self.btn_CloseTips then self:CloseView() end end return UIPetReproductionStarTip