local UIFightThroneCollectionReward = UIViewClass() function UIFightThroneCollectionReward:OnOpened(context) self:RegistSystemEvent(EventID.FightThrone_FailRewardPush, self.OnFailRewardPush) for i, v in DataSheetManager.RewardPreview:GetEnumerator() do local item = self.group_Reward[i] if item then UTL.Item.SetItemCell(item, v.RewardID, 0) else break end end if context.isDropOut then self.btn_Quit:SetText(Const_IDS.IDS_BUTTON_CONFIRM) UIUtils.SetActive(self.btn_Quit, true) else self.btn_Quit:SetText(Const_IDS.IDS_FightThrone_ExitActivity) UIUtils.SetActive(self.btn_Quit, false) end self:SetResult(context.canEnterNext, true, context.isDropOut) self:SetCollectNum(context.num1, context.num2, context.num3) end function UIFightThroneCollectionReward:SetResult(canEnterNext, isResetTimer, isDropOut) self.txt_Timer:EndTimer() if isDropOut then self.UIState_Color:SetState(1) UIUtils.SetLabelText(self.txt_Title1, Const_IDS.IDS_FightThrone_Settlement_Halfway) else if canEnterNext then self.UIState_Color:SetState(0) if self.context.isRandom then UIUtils.SetLabelText(self.txt_Title1, Const_IDS.IDS_FightThrone_Settlement_LuckySuccess) else UIUtils.SetLabelText(self.txt_Title1, Const_IDS.IDS_FightThrone_Settlement_Success) end if isResetTimer then local time = DataSheetManager.ConstData:GetDataByID("FightThroneSettlementTime").IntValue --能进下一层,正常不能弹按钮,防止服务器一直不拉到下一层,这里倒计时完弹个按钮让用户出去 self:StartRepeatFunc(self.OnTimerEnd, time + 10, 1) self.txt_Timer:ResetAndBeginCustomTimer(false, time, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_FightThrone_Settlement_SuccessCd)) end else self.UIState_Color:SetState(1) UIUtils.SetLabelText(self.txt_Title1, Const_IDS.IDS_FightThrone_Settlement_Fail) if isResetTimer then local time = DataSheetManager.ConstData:GetDataByID("FightThroneSettlementTime").IntValue self:StartRepeatFunc(self.OnTimerEnd, time + 1, 1) self.txt_Timer:ResetAndBeginCustomTimer(false, time, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_FightThrone_Settlement_FailCd)) end end end end function UIFightThroneCollectionReward:OnTimerEnd() if self.context.canEnterNext then logging.error(LTAG.ERROR, "excepted to enter next, but fail!") end UIUtils.SetActive(self.btn_Quit, true) end function UIFightThroneCollectionReward:OnFailRewardPush(result) UIUtils.SetActive(self.btn_Quit, true) self:SetResult(false, false, false) self:SetCollectNum(result.SilverChest, result.GoldChest, result.JadeFragment) end function UIFightThroneCollectionReward:SetCollectNum(num1, num2, num3) if num1 == 0 and num2 == 0 and num3 == 0 then UIUtils.SetActive(self.group_Reward.gameObject, false) UIUtils.SetLabelText(self.txt_Info, Const_IDS.IDS_FightThrone_NotObtained) UIUtils.SetActive(self.group_Tips, false) else UIUtils.SetActive(self.group_Reward.gameObject, true) UIUtils.SetActive(self.group_Tips, true) self.txt_Info.text = nil self:SetItemNum(self.group_Reward[1], num1) self:SetItemNum(self.group_Reward[2], num2) self:SetItemNum(self.group_Reward[3], num3) end end function UIFightThroneCollectionReward:SetItemNum(item, num) if num > 0 then UIUtils.SetActive(item.gameObject.transform.parent, true) item.lab_Count.text = num else UIUtils.SetActive(item.gameObject.transform.parent, false) end end function UIFightThroneCollectionReward:OnBackButtonPressed() if self.context.canEnterNext then return end self:OnButtonClicked(self.btn_Quit) end function UIFightThroneCollectionReward:OnButtonClicked(comp) if comp == self.btn_Quit then self:CloseView() if self.context.isDropOut == false then MDL.Level.SendRoleLeaveFuben() end elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UIFightThroneRewardPreview) else for i, item in ipairs(self.group_Reward) do if item.event_Click == comp then local id = DataSheetManager.RewardPreview:GetDataByID(i).RewardID UTL.ItemTips.ShowCommonTipsById(id) break end end end end return UIFightThroneCollectionReward