local UIRewardGainPanel = UIViewClass() local EventSystem = require('Event/EventSystem') function UIRewardGainPanel:OnCreated() self.rewardDataDict = {} end ---@param context ---{ --- itemList : 奖励, --- tipsIDS : 底部奖励描述, --- topContentIDS : 顶部title, --- duration : 自定义时间(不传默认8秒) ---} function UIRewardGainPanel:OnOpened(context) self.context = nil self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) local itemList = context if context.tipsIDS then -- 新增奖励提示 UIUtils.SetLabelText(self.lab_Tips, Const_IDS[context.tipsIDS]) itemList = context.itemList end if context.topContentIDS then --顶部显示文本 UIUtils.SetLabelText(self.lab_RewardTitle, Const_IDS[context.topContentIDS]) itemList = context.itemList end -- 传入自定义duration, 不传为8秒默认 self.duration = context.duration and context.duration or DataSheetManager.ConstData:GetDataByID("ItemGetUITimeOut").IntValue UIUtils.AdjustGridAlignment(self.grid_Reward,#itemList) for _, reward in ipairs(itemList) do self.rewardDataDict[reward.ItemId] = reward.ItemCount self.scroll_Reward:AddData(reward,0) end UIUtils.SetActive(self.labLocal_Timer, true) UIUtils.SetLabel(self.labLocal_Timer,string.FormatByIdsId(Const_IDS.IDS_Item_GetUI_TimeOut,math.ceil(self.duration))) if CTL.WinLogin.IsUsePCNtSdk() then if not SDKUtil.IsExistSdkPanle() then self:StartRepeatFunc(self.OnUpdateFun, 1) else UIUtils.SetActive(self.labLocal_Timer, false) end else self:StartRepeatFunc(self.OnUpdateFun, 1) end ---UIUtils.SetLocalizationImage(self.sprite_Get,"img_EquipmentGet.png") CTL.Sound.PlayGameSound("UI_congratulation") end function UIRewardGainPanel:OnUpdateFun(deltaTime, timeSinceUpdate) if timeSinceUpdate > self.duration then self:CloseView() else UIUtils.SetLabel(self.labLocal_Timer,string.FormatByIdsId(Const_IDS.IDS_Item_GetUI_TimeOut,math.ceil(self.duration- timeSinceUpdate))) end end function UIRewardGainPanel:OnButtonClicked(obj) if obj==self.event_Bottom then self:CloseView() end end function UIRewardGainPanel:OnClosed() -- 发送事件播放章节奖励特效 EventSystem.Dispatch(EventID.UI_ChapterGoal_RewardPanelClose, self.rewardDataDict) -- 天地群雄战斗结算面板 EventSystem.Dispatch(EventID.UI_HeroMatch1v1_OnShowBattleSummary) EventSystem.Dispatch(EventID.UI_HeroMatch3v3_OnShowBattleSummary) -- 天下会武3V3结算,包括以后复用公平3V3结算协议的玩法 EventSystem.Dispatch(EventID.UI_SyncTeamPVP_SummaryAfterReward) end --region -- **************** cell ******************* -- function UIRewardGainPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.scroll_Reward then self:SetRewardCell(cellTable,data) end end function UIRewardGainPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.scroll_Reward then UTL.ItemTips.ShowCommonTipsById(data.ItemId, false, false, data.UniqId) end end function UIRewardGainPanel:SetRewardCell(cellTable,data) UTL.Item.SetItemCell(cellTable.item, data.ItemId, data.ItemCount) local itemCfgData = DataSheetManager.ItemData:GetDataByID(data.ItemId) local itemNameAndDesc = UTL.Item.GetItemDataSpliceByType(data.ItemId) local colorName = UTL.Color.FormatQualityText(itemNameAndDesc.Name, itemCfgData.Color) UIUtils.SetActive(cellTable.UIScrollText, true) cellTable.UIScrollText:SetText(colorName) end function UIRewardGainPanel:OnRewardClick(data) UTL.ItemTips.ShowCommonTipsById(data.ItemId) end --endregion cell return UIRewardGainPanel