local UISyncTeamPVPReward = UIViewClass() local SliderSensitivityParam = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("SliderSensitivityParam").FloatValue) local TotalNum = DataSheetManager.ConstData:GetDataByID("SoloFightSeasonRewardNeedMatch").IntValue function UISyncTeamPVPReward:OnOpened(context) self:RegistSystemEvent(EventID.UI_FairPlay_RefreshPVPRankInfo, self.RefreshTeamPVPDanRewardPanel) self:RegistSystemEvent(EventID.UI_FairPlay_WinRewardRefresh, self.RefreshSeasonWinCountPanel) self:RegistSystemEvent(EventID.UI_FairPlay_TVTSeasonInfoUpdate, self.RefreshSeasonWinCountPanel) self.dragDict = {} self.group_Toggle:SetToggleIDS(1, "lab_PVPReward", Const_IDS.IDS_RankOptimization_RankReward) self.group_Toggle:SetToggleIDS(2, "lab_Win", Const_IDS.IDS_FairPlaySeasonWin_Title) self.group_Toggle:SetToggleIDS(3, "lab_PVPReward_1", Const_IDS.IDS_RankOptimization_SeasonReward) -- 页签红点 self.group_Toggle:SetRedPoint(0, not CTL.SyncTeamPVP.CanNotGetReward()) self.group_Toggle:SetRedPoint(1, CTL.SyncTeamPVP.HasSyncTVTWinReward()) self.selectToggleIndex = 0 UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_BossChallenge_Reward_Title) UIUtils.SetActive(self.UICommonPopUp.img_Info, true) MDL.SyncTeamPVP.FairPlayTvTOpenReq() self.group_Toggle:SelectIndex(self.selectToggleIndex) end function UISyncTeamPVPReward:OnValueChanged(comp,value) if comp == self.group_Toggle then self.selectToggleIndex = value if value == 0 then self.State:SetState(0) self:RefreshTeamPVPDanRewardPanel() elseif value == 1 then self.State:SetState(2) self:RefreshSeasonWinCountPanel() elseif value == 2 then self.State:SetState(1) self:RefreshSeasonRewardPanel() end end end function UISyncTeamPVPReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISyncTeamPVPReward:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() elseif comp == self.UICommonPopUp.img_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView,{id = LuaConst.NoteID.BattleGroundRank_3V3, params = {MDL.SyncSolo.GetSoloLevelRank()}}) elseif comp == self.event_Collect then self.event_Collect:SetGray(true,true) self.event_Collect:SetRedPoint(false) if self.selectToggleIndex == 0 then if MDL.SyncTeamPVP.GetSyncTeamPVPCurNum() < TotalNum then CTL.Tips.AddTipsMsg(string.format(UIUtils.GetLocalizedTxt(Const_IDS["IDS_RankOptimization_Tip_NeedMatch"]), TotalNum)) elseif MDL.SyncTeamPVP.GetSyncTeamPVPRewardDan() == MDL.SyncTeamPVP.GetSyncTeamPVPHistoryDan() then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS["IDS_RankOptimization_Tip_NoReward"])) else MDL.SyncTeamPVP.SyncTeamPVPRewardReq() end else if self.hasReward then MDL.SyncTeamPVP.GetFairPlayWinNumRewardReq() else CTL.Tips.AddTipsMsg(Const_IDS["IDS_RankOptimization_Tip_NoReward"]) end end end end local function SortByReverse(a, b) return a.Rank < b.Rank end function UISyncTeamPVPReward:RefreshTeamPVPDanRewardPanel() self.group_Toggle:SetRedPoint(0, not CTL.SyncTeamPVP.CanNotGetReward()) if self.selectToggleIndex ~= 0 then return end UIUtils.SetActive(self.loopScroll_DanReward,true) UIUtils.SetActive(self.loopScroll_SeasonWinReward, false) UIUtils.SetActive(self.loopScroll_SeasonReward,false) if(MDL.SyncTeamPVP.GetSyncTeamPVPCurNum() 0 then self.loopScroll_DanReward:ClearCells() end for i, v in DataSheetManager.ThreeBattleLevelData:GetEnumerator() do self.loopScroll_DanReward:AddData(v, 0) end if self.myRankLevel > 0 then self.loopScroll_DanReward:MoveIndex(self.myRankLevel - 1) end end function UISyncTeamPVPReward:RefreshSeasonRewardPanel() UIUtils.SetActive(self.loopScroll_DanReward,false) UIUtils.SetActive(self.loopScroll_SeasonWinReward, false) UIUtils.SetActive(self.loopScroll_SeasonReward,true) UIUtils.SetActive(self.txt_WeeklyParticipate,false) UIUtils.SetActive(self.event_Collect,false) UIUtils.SetLabelText(self.lab_Tips,Const_IDS.IDS_1v1Sync_MailSendReward) self.myRankLevel = CTL.SyncTeamPVP.GetLevelRank() if self.loopScroll_SeasonReward.Count > 0 then self.loopScroll_SeasonReward:ClearCells() end local dataList = {} for i, v in DataSheetManager.ThreeBattleReward3V3:GetEnumerator() do table.insert(dataList, v) end table.sort(dataList, SortByReverse) for i, v in ipairs(dataList) do self.loopScroll_SeasonReward:AddData(v, 0) end if self.myRankLevel > 0 then self.loopScroll_SeasonReward:MoveIndex(self.myRankLevel - 1) end end function UISyncTeamPVPReward:RefreshSeasonWinCountPanel() self.group_Toggle:SetRedPoint(1, CTL.SyncTeamPVP.HasSyncTVTWinReward()) if self.selectToggleIndex ~= 1 then return end UIUtils.SetActive(self.loopScroll_DanReward, false) UIUtils.SetActive(self.loopScroll_SeasonReward, false) UIUtils.SetActive(self.loopScroll_SeasonWinReward, true) UIUtils.SetActive(self.txt_WeeklyParticipate,true) UIUtils.SetActive(self.event_Collect,true) UIUtils.SetLabelText(self.lab_Tips,Const_IDS.IDS_RankOptimization_RankReward_Tips) local winInfo = MDL.SyncTeamPVP.GetSyncTVTWinInfo() local targetIndex, receivedIndex = 0, 0 self.hasReward = nil if self.loopScroll_SeasonWinReward.Count > 0 then self.loopScroll_SeasonWinReward:ClearCells() end for i, v in DataSheetManager.ThreeBattleSeasonWin:GetEnumerator() do self.loopScroll_SeasonWinReward:AddData(v, 0) if not self.hasReward and winInfo.winNum >= v.ID and winInfo.maxReceivedRewardID < v.ID then self.hasReward = true receivedIndex = i - 1 end if winInfo.maxReceivedRewardID >= v.ID then targetIndex = i - 1 end end if self.hasReward then self.event_Collect:SetGray(false,true) self.event_Collect:SetRedPoint(true) self.loopScroll_SeasonWinReward:MoveIndex(receivedIndex) else self.event_Collect:SetGray(true,true) self.event_Collect:SetRedPoint(false) self.loopScroll_SeasonWinReward:MoveIndex(targetIndex) end UIUtils.SetLabel(self.txt_WeeklyParticipate, string.FormatByIdsId(Const_IDS["IDS_FairPlaySeasonWin_Tips2"], winInfo.winNum)) end function UISyncTeamPVPReward:OnCellInit(scrollRect, index, cellTable, data) local rewardDatas if scrollRect == self.loopScroll_DanReward then --local myRankData = 获取PVP自己排名的方法 local rankData = DataSheetManager.ThreeBattleLevelData:GetDataByLevelID(data.LevelID) UIUtils.SetLabelText(cellTable.txt_NotReached,Const_IDS.IDS_RankOptimization_RankReward_NotGet) UIUtils.SetLabelText(cellTable.txt_Available,Const_IDS.IDS_RankOptimization_RankReward_AbleToGet) local curStar = rankData.Star local maxStar = rankData.MaxStar if curStar == 0 then UIUtils.SetActive(cellTable.group_Star.gameObject,false) else UIUtils.SetActive(cellTable.group_Star.gameObject,true) for i,v in ipairs(cellTable.group_Stars) do UIUtils.SetActive(v.gameObject, maxStar >= i) UIUtils.SetActive(v.img_Star_1, curStar >= i) end end UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS[rankData.LevelNameBrife]) if rankData.LevelID <= MDL.SyncTeamPVP.GetSyncTeamPVPRewardDan() then cellTable.RewardState:SetState(2) elseif rankData.LevelID > MDL.SyncTeamPVP.GetSyncTeamPVPRewardDan() and rankData.LevelID <= MDL.SyncTeamPVP.GetSyncTeamPVPHistoryDan() then cellTable.RewardState:SetState(1) elseif rankData.LevelID > MDL.SyncTeamPVP.GetSyncTeamPVPHistoryDan() then cellTable.RewardState:SetState(0) end if CTL.SyncTeamPVP.IsWarZoneStyle() then rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.LevelRewardWarZone).Item_Table else rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.LevelReward).Item_Table end if self.myRankLevel > 0 and self.myRankLevel == data.LevelID then UIUtils.SetActive(cellTable.img_Own, true) else UIUtils.SetActive(cellTable.img_Own, false) end self:DragClosed(self.loopScroll_DanReward, cellTable.drag_Obj_Dan, index ,cellTable) elseif scrollRect == self.loopScroll_SeasonReward then local rankData = DataSheetManager.ThreeBattleLevelData:GetDataByLevelID(data.Rank) local curStar = rankData.Star local maxStar = rankData.MaxStar if curStar == 0 then UIUtils.SetActive(cellTable.group_Star.gameObject,false) else UIUtils.SetActive(cellTable.group_Star.gameObject,true) for i,v in ipairs(cellTable.group_Stars) do UIUtils.SetActive(v.gameObject, maxStar >= i) UIUtils.SetActive(v.img_Star_1, curStar >= i) end end UIUtils.SetLabelText(cellTable.txt_Rank, Const_IDS[rankData.LevelNameBrife]) if CTL.SyncTeamPVP.IsWarZoneStyle() then rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeat).Item_Table end if self.myRankLevel > 0 and self.myRankLevel == data.Rank then UIUtils.SetActive(cellTable.img_Own, true) else UIUtils.SetActive(cellTable.img_Own, false) end self:DragClosed(self.loopScroll_SeasonReward, cellTable.drag_Obj_Season, index ,cellTable) elseif scrollRect == self.loopScroll_SeasonWinReward then local winInfo = MDL.SyncTeamPVP.GetSyncTVTWinInfo() UIUtils.SetLabelText(cellTable.txt_NotReached,Const_IDS.IDS_RankOptimization_RankReward_NotGet) UIUtils.SetLabelText(cellTable.txt_Available,Const_IDS.IDS_RankOptimization_RankReward_AbleToGet) UIUtils.SetActive(cellTable.group_Stars.gameObject, false) UIUtils.SetLabel(cellTable.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_FairPlaySeasonWin_Tips1"], data.ID)) if winInfo.maxReceivedRewardID >= data.ID then -- 已领取 cellTable.RewardState:SetState(2) elseif winInfo.winNum >= data.ID then -- 可领取 cellTable.RewardState:SetState(1) else -- 未达成 cellTable.RewardState:SetState(0) end rewardDatas = DataSheetManager.ThreeBattleSeasonWinReward:GetDataByAttrRepeatID(data.ThreeBattleSeasonWinReward).Item_Table self:DragClosed(self.loopScroll_SeasonWinReward, cellTable.drag_Obj_Dan, index ,cellTable) 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 end --穿透函数封装 function UISyncTeamPVPReward:DragClosed(scrollRect, drag_Obj, index ,cellTable) scrollRect:RegistTriggerEvent(drag_Obj, UIEventTriggerType.BeginDrag, index) scrollRect:RegistTriggerEvent(drag_Obj, UIEventTriggerType.Drag, index) scrollRect:RegistTriggerEvent(drag_Obj, UIEventTriggerType.EndDrag, index) self.dragDict[drag_Obj.gameObject] = cellTable.ItemScrollView.gameObject end function UISyncTeamPVPReward:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loopScroll_DanReward then for i,v in ipairs(cellTable.ItemContent) do if v.event_Click == target then local rewardDatas if CTL.SyncTeamPVP.IsWarZoneStyle() then rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.LevelRewardWarZone).Item_Table else rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.LevelReward).Item_Table end UTL.ItemTips.ShowCommonTipsById(rewardDatas[i].ItemID) break end end elseif scrollRect == self.loopScroll_SeasonReward then for i,v in ipairs(cellTable.ItemContent) do if v.event_Click == target then local rewardDatas if CTL.SyncTeamPVP.IsWarZoneStyle() then rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.ThreeBattleRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeat).Item_Table end UTL.ItemTips.ShowCommonTipsById(rewardDatas[i].ItemID) break end end elseif scrollRect == self.loopScroll_SeasonWinReward then for i,v in ipairs(cellTable.ItemContent) do if v.event_Click == target then local rewardDatas = DataSheetManager.ThreeBattleSeasonWinReward:GetDataByAttrRepeatID(data.ThreeBattleSeasonWinReward).Item_Table UTL.ItemTips.ShowCommonTipsById(rewardDatas[i].ItemID) break end end end end function UISyncTeamPVPReward:Cell_OnBeginDrag(scrollRect, index, comp, eventData) if math.abs(eventData.delta.x) > SliderSensitivityParam then self.curDragObj = self.dragDict[comp.gameObject] else if scrollRect == self.loopScroll_DanReward then self.curDragObj = self.loopScroll_DanReward.gameObject elseif scrollRect == self.loopScroll_SeasonReward then self.curDragObj = self.loopScroll_SeasonReward.gameObject elseif scrollRect == self.loopScroll_SeasonWinReward then self.curDragObj = self.loopScroll_SeasonWinReward.gameObject end end UIUtils.ExecuteBeginDrag(self.curDragObj, eventData) end function UISyncTeamPVPReward:Cell_OnDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteDrag(self.curDragObj, eventData) end function UISyncTeamPVPReward:Cell_OnEndDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteEndDrag(self.curDragObj, eventData) end function UISyncTeamPVPReward:OnClosed() UIUtils.SetActive(self.UICommonPopUp.img_Info, false) end return UISyncTeamPVPReward