local UIDemonGodRewardDaily = UIViewClass() function UIDemonGodRewardDaily:OnOpened(context) self.dmgRecord = MDL.DemonGod.GetLineUpMaxDamage() self.moveIndex = nil if CTL.WarZone.IsWarZoneOpen() then for i, v in DataSheetManager.DemonGodBossPersonalRewardCS:GetEnumerator() do self.loop_Rank:AddData(v, 0) if self.moveIndex == nil and v.DamageAmount > self.dmgRecord then self.moveIndex = i - 2 end end self.cfgMaxCount = DataSheetManager.DemonGodBossPersonalRewardCS:GetDataCount() else for i, v in DataSheetManager.DemonGodBossPersonalReward:GetEnumerator() do self.loop_Rank:AddData(v, 0) if self.moveIndex == nil and v.DamageAmount > self.dmgRecord then self.moveIndex = i - 2 end end self.cfgMaxCount = DataSheetManager.DemonGodBossPersonalRewardCS:GetDataCount() end if self.moveIndex == nil or self.moveIndex >= (self.cfgMaxCount - 1) - 2 then --在末3个在最低部 local oriX, oriY = self.loop_Rank.content:GetAnchoredPosition() self.loop_Rank.content:SetAnchoredPosition(oriX, oriY - 100) self.loop_Rank:MoveEnd() elseif self.moveIndex <= 2 then --在头3个在最顶部 self.loop_Rank:MoveIndex(0) else self.loop_Rank:MoveIndex(self.moveIndex) end end function UIDemonGodRewardDaily:OnCellInit(scrollRect, index, cellTable, data) local reward = DataSheetManager.DemonGodBossReward:GetDataByID(data.PersonalRewardID) if #reward.Item_Table > 1 then UTL.Item.SetItemCell(cellTable.item, reward.Item_Table[1].ItemID, reward.Item_Table[1].ItemNum) UTL.Item.SetItemCell(cellTable.item2, reward.Item_Table[2].ItemID, reward.Item_Table[2].ItemNum) UIUtils.SetActive(cellTable.item2.gameObject, true) else UTL.Item.SetItemCell(cellTable.item, reward.Item_Table[1].ItemID, reward.Item_Table[1].ItemNum) UIUtils.SetActive(cellTable.item2.gameObject, false) end if index + 1 == self.cfgMaxCount then cellTable.txt_Rank.text = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_40, UTL.String.GetCountStr(data.DamageAmount)) UIUtils.SetActive(cellTable.img_Current, self.dmgRecord >= data.DamageAmount) else --获取下一行数据 local nextData if CTL.WarZone.IsWarZoneOpen() then nextData = DataSheetManager.DemonGodBossPersonalRewardCS:GetDataByID(data.ID + 1) else nextData = DataSheetManager.DemonGodBossPersonalReward:GetDataByID(data.ID + 1) end cellTable.txt_Rank.text = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_41, UTL.String.GetCountStr(data.DamageAmount), UTL.String.GetCountStr(nextData.DamageAmount)) UIUtils.SetActive(cellTable.img_Current, self.dmgRecord >= data.DamageAmount and self.dmgRecord < nextData.DamageAmount) end end function UIDemonGodRewardDaily:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.item.event_Click then local reward = DataSheetManager.DemonGodBossReward:GetDataByID(data.PersonalRewardID) UTL.ItemTips.ShowCommonTipsById(reward.Item_Table[1].ItemID) elseif target == cellTable.item2.event_Click then local reward = DataSheetManager.DemonGodBossReward:GetDataByID(data.PersonalRewardID) UTL.ItemTips.ShowCommonTipsById(reward.Item_Table[2].ItemID) end end return UIDemonGodRewardDaily