local UIGoldenHeroStoryEnding = UIViewClass() local EndingState = { NotUnlock = 0, -- 未解锁 UnlockedUnclaimed = 1, -- 解锁未领取 AlreadyReceived = 2 -- 已领取 } function UIGoldenHeroStoryEnding:OnOpened(context) self.activityId = context.activityId self.goldenHeroID = context.heroType self.isLoop = false UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_GoldHeroActivity_ActivityLevel_Title2) -- 弹窗名 self:RegistSystemEvent(EventID.UI_GoldenHeroStory_RefreshEnding, self.ShowEndingList) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:ShowEndingList() end function UIGoldenHeroStoryEnding:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView() end end end function UIGoldenHeroStoryEnding:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIGoldenHeroStoryEnding:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close then self:CloseView() else if not self.isLoop then for i, v in ipairs(self.groups) do if comp == v.btn_bg then self:ShowBigSecretPicture(self.endingInfoList[i]) elseif comp == v.btn_Receive then MDL.GoldenHeroStory.GoldHeroStoryAwardRequest(self.activityId, self.endingInfoList[i].config.EndingID) self:ShowBigSecretPicture(self.endingInfoList[i]) else for index, rewardItem in ipairs(v.group_Reward) do if comp == rewardItem.item.event_Click then UTL.ItemTips.ShowCommonTipsById(self.endingInfoList[i].config.Item_Table[index].ItemID) end end end end end end end function UIGoldenHeroStoryEnding:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_End then UIUtils.SetActive(cellTable.gameObject, true) local endingInfo = DataSheetManager.GoldHeroEndingRecord:GetDataByEndingID(data.id) local info = {config = endingInfo, endingState = data.state} self:ShowSecretPicture(cellTable, info) table.insert(self.endingInfoList, info) end end function UIGoldenHeroStoryEnding:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_End then if target == cellTable.btn_bg then self:ShowBigSecretPicture(self.endingInfoList[index + 1]) elseif target == cellTable.btn_Receive then MDL.GoldenHeroStory.GoldHeroStoryAwardRequest(self.activityId, self.endingInfoList[index + 1].config.EndingID) self:ShowBigSecretPicture(self.endingInfoList[index + 1]) else for i, rewardItem in ipairs(cellTable.group_Reward) do if target == rewardItem.item.event_Click then UTL.ItemTips.ShowCommonTipsById(self.endingInfoList[index + 1].config.Item_Table[i].ItemID) end end end end end function UIGoldenHeroStoryEnding:ShowEndingList() UIUtils.SetActive(self.groups.gameObject, false) UIUtils.SetActive(self.loop_End.gameObject, false) local endingIDList = MDL.GoldenHeroStory.GetEndingIDListByActivityID(self.activityId) self.endingInfoList = {} if #endingIDList <= 3 then self.isLoop = false UIUtils.SetActive(self.groups.gameObject, true) for i, v in ipairs(self.groups) do if endingIDList[i] and endingIDList[i].id then UIUtils.SetActive(v.gameObject, true) local endingInfo = DataSheetManager.GoldHeroEndingRecord:GetDataByEndingID(endingIDList[i].id) local info = {config = endingInfo, endingState = endingIDList[i].state} self:ShowSecretPicture(v, info) table.insert(self.endingInfoList, info) else UIUtils.SetActive(v.gameObject, false) end end else self.isLoop = true UIUtils.SetActive(self.loop_End.gameObject, true) self.loop_End:ReloadAll(endingIDList) end end -- 结局小图 function UIGoldenHeroStoryEnding:ShowSecretPicture(cellTable, data) local state = EndingState.NotUnlock UIUtils.SetImageByAssetBundle(cellTable.img_Scene, data.config.Pic_Small) -- 结局图片 UIUtils.SetLabelText(cellTable.txt_Title, Const_IDS[data.config.EndingName]) -- 结局标题 UIUtils.SetActive(cellTable.btn_bg, true) cellTable.effect:StopUIEffect() cellTable.state_img:SetState(0) cellTable.state_btn:SetState(0) if data.endingState == EndingState.NotUnlock then cellTable.state_img:SetState(1) cellTable.state_btn:SetState(2) elseif data.endingState == EndingState.UnlockedUnclaimed then cellTable.state_btn:SetState(1) cellTable.effect:PlayUIEffect() elseif data.endingState == EndingState.AlreadyReceived then cellTable.state_btn:SetState(0) end UIUtils.SetActive(cellTable.group_Reward.gameObject, data.endingState ~= EndingState.AlreadyReceived) if data.endingState ~= EndingState.AlreadyReceived then local rewards = data.config.Item_Table for i, rewardItem in ipairs(cellTable.group_Reward) do UTL.Item.SetItemCell(rewardItem.item, rewards[i].ItemID, rewards[i].ItemNum) end end end -- 结局大图展示 function UIGoldenHeroStoryEnding:ShowBigSecretPicture(data) local endingInfo = {bgName = data.config.Pic_Big, endingTitle = data.config.EndingName, endingDes = data.config.EndingDes} UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoryEndingShow, {activityId = self.activityId, heroType = self.heroType, endingData = endingInfo}) end return UIGoldenHeroStoryEnding