local UIBossChallengeReward = UIViewClass() local SliderSensitivityParam = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("SliderSensitivityParam").FloatValue) function UIBossChallengeReward:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_RewardPreview) self.dragDict = {} self.seasonId = CTL.BossChallenge.GetSeasonId() self:RefreshBossTypeList() local index = (curSeasonId and context) and (curSeasonId - context.seasonId) or 0 self.loopScroll_BossType:SelectIndex(index) end function UIBossChallengeReward:RefreshBossTypeList() local nowSeasonBossId = CTL.BossChallenge.GetSeasonBossById(self.seasonId) self.loopScroll_BossType:AddData({bossId = nowSeasonBossId, seasonId = self.seasonId, isOpen = CTL.BossChallenge.IsSeasonOpen(self.seasonId)}, 0) if CTL.BossChallenge.IsSeasonOpen(self.seasonId) then local lastSeasonId = CTL.BossChallenge.GetLastSeasonId() if lastSeasonId > 0 then local lastSeasonBossId = CTL.BossChallenge.GetSeasonBossById(lastSeasonId) self.loopScroll_BossType:AddData({bossId = lastSeasonBossId, seasonId = lastSeasonId, isOpen = CTL.BossChallenge.IsSeasonOpen(lastSeasonId)}, 0) end end end function UIBossChallengeReward:RefreshBossRankReward(bossId) if CTL.BossChallenge.IsSeasonOpen(self.seasonId) then UIUtils.SetLabelText(self.lab_Tips, Const_IDS["IDS_BossChallenge_Reward_SeasonTip"]) else UIUtils.SetLabelText(self.lab_Tips, Const_IDS["IDS_BossChallenge_Reward_LastSeasonTip"]) end if self.loopScroll_BossReward.Count > 0 then self.loopScroll_BossReward:ClearCells() end for i, v in DataSheetManager.BossChallengeReward:GetEnumerator() do if v.BossChallengeID == bossId then self.loopScroll_BossReward:AddData(v, 0) end end end function UIBossChallengeReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIBossChallengeReward:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() end end function UIBossChallengeReward:SaveSelectedBossId() if self.context then self.context.seasonId = self.seasonId else self.context = {seasonId = self.seasonId} end end function UIBossChallengeReward:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loopScroll_BossType then self.seasonId = data.seasonId self:RefreshBossRankReward(data.bossId) self:SaveSelectedBossId() end end function UIBossChallengeReward:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loopScroll_BossReward then local myRank = MDL.BossChallenge.GetBossRankByBossLevelId() or 0 if data.RankMin == data.RankMax then UIUtils.SetLabel(cellTable.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_BossChallenge_Reward_RankRange_OneNum"], data.RankMin)) else UIUtils.SetLabel(cellTable.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_BossChallenge_Reward_RankRange_TwoNum"], data.RankMin, data.RankMax)) end -- 获取奖励列表 当前赛季是战区,读取战区不是战区读取正常奖励,上一个赛季 有数据且 这个赛季为战区,则读取战区,否侧读取正常 local rewardDatas if CTL.BossChallenge.GetSeasonId() == self.seasonId then if CTL.BossChallenge.IsWarZoneStyle() then rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeat).Item_Table end else if CTL.BossChallenge.GetLastSeasonId() > 0 and CTL.BossChallenge.IsWarZoneStyle() then rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeat).Item_Table end end for i, rewardData in ipairs(rewardDatas) do local contentItem = cellTable.ItemContent[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.ItemContent, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(contentItem, rewardData.ItemID, rewardData.ItemNum, false) UIUtils.SetActive(contentItem.gameObject, true) end for i = #rewardDatas + 1, #cellTable.ItemContent do UIUtils.SetActive(cellTable.ItemContent[i].gameObject, false) end --需要判断是不是自己所在的排名,显示标签 if CTL.BossChallenge.IsSeasonOpen(self.seasonId) then if myRank > 0 and myRank >= data.RankMin and myRank <= data.RankMax then UIUtils.SetActive(cellTable.img_Own, true) else UIUtils.SetActive(cellTable.img_Own, false) end else UIUtils.SetActive(cellTable.img_Own, false) end --注册拖拽透传的事件 scrollRect:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.BeginDrag, index) scrollRect:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.Drag, index) scrollRect:RegistTriggerEvent(cellTable.drag_Obj, UIEventTriggerType.EndDrag, index) self.dragDict[cellTable.drag_Obj.gameObject] = cellTable.ItemScrollView.gameObject elseif scrollRect == self.loopScroll_BossType then local bossData = DataSheetManager.BossChallengeData:GetDataByID(data.bossId) UIUtils.SetLabelText(cellTable.lab_BossTypeUnCheck, Const_IDS[bossData.BossChallengeName]) UIUtils.SetLabelText(cellTable.lab_BossTypeCheck, Const_IDS[bossData.BossChallengeName]) UIUtils.SetActive(cellTable.icon_OpenUnCheck, data.isOpen) UIUtils.SetActive(cellTable.icon_OpenCheck, data.isOpen) end end function UIBossChallengeReward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loopScroll_BossReward then for i,v in ipairs(cellTable.ItemContent) do if v.event_Click == target then local rewardDatas if CTL.BossChallenge.GetSeasonId() == self.seasonId then if CTL.BossChallenge.IsWarZoneStyle() then rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeat).Item_Table end else if CTL.BossChallenge.GetLastSeasonId() > 0 and CTL.BossChallenge.IsWarZoneStyle() then rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.BossChallengeRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeat).Item_Table end end UTL.ItemTips.ShowCommonTipsById(rewardDatas[i].ItemID) break end end end end function UIBossChallengeReward:Cell_OnBeginDrag(scrollRect, index, comp, eventData) if math.abs(eventData.delta.x) > SliderSensitivityParam then self.curDragObj = self.dragDict[comp.gameObject] else self.curDragObj = self.loopScroll_BossReward.gameObject end UIUtils.ExecuteBeginDrag(self.curDragObj, eventData) end function UIBossChallengeReward:Cell_OnDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteDrag(self.curDragObj, eventData) end function UIBossChallengeReward:Cell_OnEndDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteEndDrag(self.curDragObj, eventData) end return UIBossChallengeReward