local UISuperGoldStoryEndingTarget = UIViewClass() -- 排序:id local function SortEnding(ending_1, ending_2) local state_1 = ending_1.state local state_2 = ending_2.state if ending_1.state == 0 then state_1 = 1 elseif ending_1.state == 1 then state_1 = 0 end if ending_2.state == 0 then state_2 = 1 elseif ending_2.state == 1 then state_2 = 0 end if state_1 == state_2 then return ending_1.cfg.NeedEndingNum < ending_2.cfg.NeedEndingNum end return state_1 < state_2 end function UISuperGoldStoryEndingTarget:OnOpened(context) self.activityId = context.activityId self.goldenHeroID = context.heroType self:RegistSystemEvent(EventID.UI_SuperGoldStory_RefreshInfo, self.RefreshView) -- 领取奖励后刷新界面 self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RefreshView() end function UISuperGoldStoryEndingTarget:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UISuperGoldStoryEndingTarget:RefreshView() self.openEndingIDList = MDL.SuperGoldStory.GetOpenEndingIDListByActivityID(self.activityId) self.doneEndingTaskIDList = MDL.SuperGoldStory.GetDoneEndingTaskIDListByActivityID(self.activityId) local endingInfoList = MDL.SuperGoldStory.GetEndingInfoListByActivityID(self.activityId) table.sort(endingInfoList, SortEnding) self.scroll_Target:ReloadAll(endingInfoList) end function UISuperGoldStoryEndingTarget:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UISuperGoldStoryEndingTarget:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() end end function UISuperGoldStoryEndingTarget:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.scroll_Target then UIUtils.SetLabel(cellTable.txt_StarInfo, string.FormatByIdsId(Const_IDS.IDS_SuperGoldHeroActivity_Level_Hint_3, data.cfg.NeedEndingNum)) --通关奖励 local rewardDatas = data.cfg.Item_Table for i, rewardData in ipairs(rewardDatas) do local contentItem = cellTable.Content[i] if not contentItem then contentItem = self:InstantiateCellCollection(cellTable.cell.gameObject, cellTable.Content, self.cell_Reward.gameObject) end UTL.Item.SetItemCell(contentItem.item, rewardData.ItemID, rewardData.ItemNum) UIUtils.SetActive(contentItem.gameObject, true) -- 可领取播特效 -- 已领取显示蒙版 end for i = #rewardDatas + 1, #cellTable.Content do UIUtils.SetActive(cellTable.Content[i].gameObject, false) end UIUtils.ResetScrollRect(cellTable.scrollView_Item) -- 位置重置 cellTable.state_btn:SetState(data.state) end end function UISuperGoldStoryEndingTarget:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.scroll_Target then if cellTable.btn_Receive == target then MDL.SuperGoldStory.SuperGoldExperienceRewardRequest(self.activityId, data.cfg.NeedEndingNum) else -- 打开物品详情弹窗 local levelRewardTable = data.cfg.Item_Table for i,v in ipairs(cellTable.Content) do if v.item.event_Click == target then UTL.ItemTips.ShowCommonTipsById(levelRewardTable[i].ItemID) break end end end end end return UISuperGoldStoryEndingTarget