local UIGVGFightRewardInfo = UIViewClass() --[[ 攻城略地——收益界面 --]] local GVGFightHarvestTimeMax = DataSheetManager.ConstData:GetDataByID("GVGFightHarvestTimeMax").IntValue * 60 -------------------- function UIGVGFightRewardInfo:OnOpened(context) self:RegistSystemEvent(EventID.GVGFight_RefreshIncomeReward, self.RefreshIncomeReward) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.GVGFight_Reward, self.RefreshRewardRp) self:RegistSystemEvent(EventID.GVGFight_RefreshGVGFightState, self.RefreshGVGState) self:RefreshRewardRp(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.GVGFight_Reward)) self:InitPanel() -- 请求收益信息 MDL.GVGFight.GVGRewardInfoReq() end function UIGVGFightRewardInfo:OnClosed() self.cdTimer:EndTimer() self.btn_Get:SetRedPoint(false) end function UIGVGFightRewardInfo:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGVGFightRewardInfo:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView(false) elseif comp == self.btn_Get then MDL.GVGFight.GVGGetRewardInfoReq() end end function UIGVGFightRewardInfo:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.ConditionScroll_Item then UTL.Item.SetItemCell(cellTable.UIItem, data.itemId, data.itemNum) end end function UIGVGFightRewardInfo:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.ConditionScroll_Item then if target == cellTable.UIItem.event_Click then UTL.ItemTips.ShowCommonTipsById(data.itemId) end end end -------------------- function UIGVGFightRewardInfo:InitPanel() UIUtils.SetLabelText(self.lab_Info, Const_IDS.IDS_GVGFight_Income_TimeMax) UIUtils.SetActive(self.txt_Limit, true) UIUtils.SetLabel(self.txt_Limit, UTL.Time.FormatTimeClockBySeconds(GVGFightHarvestTimeMax)) UIUtils.SetActive(self.txt_Position, false) UIUtils.SetActive(self.txt_Reward, false) UIUtils.SetLabelText(self.lab_Tips, Const_IDS.IDS_GVGFight_Income_Tips1) -- 初始化时间、奖励 self:RefreshIncomeReward() end function UIGVGFightRewardInfo:RefreshIncomeReward() -- 设置时间 local duration = MDL.GVGFight.GetIncomeTime() if duration >= GVGFightHarvestTimeMax then self.cdTimer:SetCDLabel(UTL.Color.FormatRedColor(UTL.Time.FormatTimeClockBySeconds(GVGFightHarvestTimeMax))) else self.cdTimer:SetAndContinueTimer(true, duration, GVGFightHarvestTimeMax) end -- 设置奖励 if MDL.GVGFight.GetIncomeRewardItemCount() > 0 then UIUtils.SetActive(self.lab_Tips, false) UIUtils.SetActive(self.ConditionScroll_Item, true) if self.ConditionScroll_Item.Count > 0 then self.ConditionScroll_Item:ClearCells() end for _, v in MDL.GVGFight.GetIncomeRewardItemIterator() do self.ConditionScroll_Item:AddData(v, 0) end self.btn_Get:SetGray(false, true) else UIUtils.SetActive(self.lab_Tips, true) UIUtils.SetActive(self.ConditionScroll_Item, false) self.btn_Get:SetGray(true, false) end end function UIGVGFightRewardInfo:RefreshRewardRp(active) self.btn_Get:SetRedPoint(active) end function UIGVGFightRewardInfo:RefreshGVGState() local curGVGFightState = MDL.GVGFight.GetCurGVGFightState() if curGVGFightState == MDL.GVGFight.GVGFightStage.OffSeason then UTL.MessageBox.ShowOnlyOkNoCloseBox("", Const_IDS.IDS_GVGFight_Protection_Tips9, function() self:OnBackButtonPressed() end) end end return UIGVGFightRewardInfo