local UISyncSoloReward = UIViewClass() local SliderSensitivityParam = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("SliderSensitivityParam").FloatValue) local TotalNum = DataSheetManager.ConstData:GetDataByID("SoloFightSeasonRewardNeedMatch").IntValue function UISyncSoloReward:OnOpened(context) self:RegistSystemEvent(EventID.UI_SyncSolo_RankRefresh, self.RefreshSyncSoloDanRewardPanel) self:RegistSystemEvent(EventID.UI_SyncSolo_WinRewardRefresh, self.RefreshSeasonWinCountPanel) self:RegistSystemEvent(EventID.UI_FairPlay_SyncSoloEloScoreUpdate, 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.SyncSolo.CanNotGetReward()) self.group_Toggle:SetRedPoint(1, CTL.SyncSolo.HasSyncSoloWinReward()) self.selectToggleIndex = 0 UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_BossChallenge_Reward_Title) UIUtils.SetActive(self.UICommonPopUp.img_Info, true) MDL.SyncSolo.SyncSoloOpenReq() self.group_Toggle:SelectIndex(self.selectToggleIndex) end function UISyncSoloReward:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UISyncSoloReward: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_1V1, 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.SyncSolo.GetSyncSoloCurNum() < TotalNum then CTL.Tips.AddTipsMsg(string.FormatByIdsKey("IDS_RankOptimization_Tip_NeedMatch",TotalNum)) elseif MDL.SyncSolo.GetSyncSoloRewardDan() == MDL.SyncSolo.GetSyncSoloHistoryDan() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_RankOptimization_Tip_NoReward"]) else MDL.SyncSolo.SyncSoloRewardReq() end else if self.hasReward then MDL.SyncSolo.GetFairSoloWinNumRewardReq() else CTL.Tips.AddTipsMsg(Const_IDS["IDS_RankOptimization_Tip_NoReward"]) end end end end function UISyncSoloReward:OnValueChanged(comp,value) if comp == self.group_Toggle then self.selectToggleIndex = value if value == 0 then self.State:SetState(0) self:RefreshSyncSoloDanRewardPanel() elseif value == 1 then self.State:SetState(2) self:RefreshSeasonWinCountPanel() elseif value == 2 then self.State:SetState(1) self:RefreshSeasonRewardPanel() end end end local function SortByReverse(a, b) return a.Rank < b.Rank end function UISyncSoloReward:RefreshSyncSoloDanRewardPanel() self.group_Toggle:SetRedPoint(0, not CTL.SyncSolo.CanNotGetReward()) if self.selectToggleIndex ~= 0 then return end if(MDL.SyncSolo.GetSyncSoloCurNum() 0 then self.loopScroll_DanReward:ClearCells() end for i, v in DataSheetManager.SyncSoloData:GetEnumerator() do self.loopScroll_DanReward:AddData(v, 0) end if self.myRankLevel > 0 then self.loopScroll_DanReward:MoveIndex(self.myRankLevel - 1) end end function UISyncSoloReward: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.SyncSolo.GetSyncSoloLevelRank() if self.loopScroll_SeasonReward.Count > 0 then self.loopScroll_SeasonReward:ClearCells() end local dataList = {} for i, v in DataSheetManager.SyncSoloReward: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 UISyncSoloReward:RefreshSeasonWinCountPanel() self.group_Toggle:SetRedPoint(1, CTL.SyncSolo.HasSyncSoloWinReward()) 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.SyncSolo.GetSyncSoloWinInfo() 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.SyncSoloSeasonWin: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 UISyncSoloReward:OnCellInit(scrollRect, index, cellTable, data) local rewardDatas if scrollRect == self.loopScroll_DanReward then local rankData = DataSheetManager.SyncSoloData: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.SyncSolo.GetSyncSoloRewardDan() then cellTable.RewardState:SetState(2) elseif rankData.LevelID > MDL.SyncSolo.GetSyncSoloRewardDan() and rankData.LevelID <= MDL.SyncSolo.GetSyncSoloHistoryDan() then cellTable.RewardState:SetState(1) elseif rankData.LevelID > MDL.SyncSolo.GetSyncSoloHistoryDan() then cellTable.RewardState:SetState(0) end if CTL.SyncSolo.IsWarZoneStyle() then rewardDatas = DataSheetManager.SyncSoloRewardRepeat:GetDataByAttrRepeatID(data.LevelRewardWarZone).Item_Table else rewardDatas = DataSheetManager.SyncSoloRewardRepeat: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.SyncSoloData: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.SyncSolo.IsWarZoneStyle() then rewardDatas = DataSheetManager.SyncSoloRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.SyncSoloRewardRepeat: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.SyncSolo.GetSyncSoloWinInfo() 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.SyncSoloSeasonWinReward:GetDataByAttrRepeatID(data.SyncSoloSeasonWinReward).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 UISyncSoloReward: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 UISyncSoloReward: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.SyncSolo.IsWarZoneStyle() then rewardDatas = DataSheetManager.SyncSoloRewardRepeat:GetDataByAttrRepeatID(data.LevelRewardWarZone).Item_Table else rewardDatas = DataSheetManager.SyncSoloRewardRepeat: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.SyncSolo.IsWarZoneStyle() then rewardDatas = DataSheetManager.SyncSoloRewardRepeat:GetDataByAttrRepeatID(data.RewardRepeatWarZone).Item_Table else rewardDatas = DataSheetManager.SyncSoloRewardRepeat: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.SyncSoloSeasonWinReward:GetDataByAttrRepeatID(data.SyncSoloSeasonWinReward).Item_Table UTL.ItemTips.ShowCommonTipsById(rewardDatas[i].ItemID) break end end end end function UISyncSoloReward: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 UISyncSoloReward:Cell_OnDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteDrag(self.curDragObj, eventData) end function UISyncSoloReward:Cell_OnEndDrag(scrollRect, index, comp, eventData) UIUtils.ExecuteEndDrag(self.curDragObj, eventData) end function UISyncSoloReward:OnClosed() UIUtils.SetActive(self.UICommonPopUp.img_Info, false) end return UISyncSoloReward