local UIExpelMonsterMain = UIViewClass() local EventSystem = require('Event/EventSystem') function UIExpelMonsterMain:OnCreated() self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.BossShowScene) end function UIExpelMonsterMain:OnOpened(context) MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.ExpelMonster, {isPreRank = MDL.ExpelMonster.GetTodayBalance()}, CTL.Rank.SortType.MyServer) self:RegistSystemEvent(EventID.New_Day_Refresh, self.RefreshUI) --跨天 self:RegistSystemEvent(EventID.UI_ExpelMonster_Settlement_End, self.RefreshUI) --结算后刷新 self:RegistSystemEvent(EventID.UI_ExpelMonster_MainUIRefresh, self.RefreshUI) --界面刷新 self:RegistSystemEvent(EventID.UI_ExpelMonster_RefreshGuildRewardBox, self.RefreshGuildScore) self:RegistSystemEvent(EventID.UI_RefreshRankInfo, self.RefreshRank) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.NewYear_ExpelMonster, self.RefreshBtnRedPoint) self.activityId = context and context.activityId self:ShowBossModel() self:RefreshUI() local settlementStartTime = CTL.ExpelMonster.GetSettlementStartTime() if settlementStartTime > 0 then self:StartRepeatFunc(self.OnUpdateFun1, settlementStartTime, 1) end local settlementEndTime = CTL.ExpelMonster.GetSettlementEndTime() if settlementEndTime > 0 then self:StartRepeatFunc(self.OnUpdateFun2, settlementEndTime, 1) end self:StartRepeatFunc(self.OnUpdateFun3, 5) end function UIExpelMonsterMain:ShowBossModel() UIManager.ActiveUIModle(false, "UIExpelMonsterMain") local bossFightData = CTL.ExpelMonster.GetActivityBossFightData(self.activityId) UTL.UIRender.CreateRTSceneTrans(self.modelComponentDataHandle, bossFightData.ModelLight) UTL.UIRender.CreateRTRenderModel(self.modelComponentDataHandle, bossFightData.BossShow, 1, nil, bossFightData.Render, bossFightData.BossActor) end function UIExpelMonsterMain:RefreshUI() self:RefreshGuildScore() self:RefreshBtns() self:RefreshRankTips() end function UIExpelMonsterMain:OnUpdateFun1(deltaTime, timeSinceUpdate) self:RefreshBtns() end function UIExpelMonsterMain:OnUpdateFun2(deltaTime, timeSinceUpdate) self:RefreshBtns() self:RefreshRankTips() end function UIExpelMonsterMain:OnUpdateFun3(deltaTime, timeSinceUpdate) MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.ExpelMonster, {isPreRank = MDL.ExpelMonster.GetTodayBalance()}, CTL.Rank.SortType.MyServer) end function UIExpelMonsterMain:RefreshRank() local rankList = MDL.Rank.GetRankInfoDataByType(MDL.Rank.RankType.ExpelMonster) local myRankInfo = MDL.Rank.GetMyRankInfo() if rankList and #rankList > 0 then self.Scroll_Rank:ReloadAll(rankList) UIUtils.SetActive(self.group_Empty, false) else self.Scroll_Rank:ClearCells() UIUtils.SetActive(self.group_Empty, true) end if myRankInfo.index == nil or myRankInfo.index == 0 then UIUtils.SetLabel(self.txt_RankBg, "——") self.bg_Rank:SetState(3) else if myRankInfo.index and myRankInfo.index <= 2 then self.bg_Rank:SetState(myRankInfo.index-1) else self.bg_Rank:SetState(3) end UIUtils.SetLabel(self.txt_RankBg, myRankInfo.index) end UIUtils.SetLabel(self.txt_Name, BattleDataGetter.GetPlayerName()) UIUtils.SetLabel(self.txt_Score, UTL.String.GetCountStr(math.ceil(myRankInfo.param1))) self:RefreshRankTips() end function UIExpelMonsterMain:RefreshRankTips() local time = DataSheetManager.ConstData:GetDataByID("ActivityBossFightDailyRankEndTime").IntValue if UTL.Time.IsServerInOpeningTime(1, time) or CTL.ExpelMonster.IsInSettlementTime() then local time = DataSheetManager.ConstData:GetDataByID("ActivityBossFightDailyRankEndTime").IntValue UIUtils.SetLabel(self.group_Remind, string.FormatByIdsKey("IDS_ActivityBossFight_Hint_3", UTL.Time.GetDiffLocalStrById(time))) else UIUtils.SetLabelText(self.group_Remind, Const_IDS.IDS_ActivityBossFight_Hint_4) end end function UIExpelMonsterMain:RefreshGuildScore() local guildScore = MDL.ExpelMonster.GetGuildScore() local nextCfg, isMaxLv = CTL.ExpelMonster.GetNextActivityBossFightGuildCfg() self.isMaxLv = isMaxLv self.lab_Score.text = string.format("%s/%s",guildScore, nextCfg.IntegrationNumber) self.slider_Score.value = guildScore / nextCfg.IntegrationNumber self.lab_Level.text = CTL.ExpelMonster.GetNextActivityBossFightGuildCfg().ID self.RewardScroll:ClearCells() self.RewardScroll:ReloadAll(nextCfg.Reward_Table) end function UIExpelMonsterMain:RefreshBtns() self:RefreshBtnRedPoint() if CTL.ExpelMonster.IsInSettlementTime() then self.btn_state:SetState(1) else self.btn_state:SetState(0) if MDL.ExpelMonster.HasChanllengedToday() then UIUtils.SetActive(self.group_Sweep, true) else UIUtils.SetActive(self.group_Sweep, false) end end end function UIExpelMonsterMain:RefreshBtnRedPoint() local times = MDL.ExpelMonster.GetChanllengeTimes() UIUtils.SetLabel(self.txt_CostNum, 1) self.btn_Fight:SetRedPoint(times>0) end function UIExpelMonsterMain:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIExpelMonsterMain:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.img_Info then local timeStr1 = UTL.Time.GetDiffLocalStrById(1) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.ExpelMonster,params = {timeStr1}}) elseif comp == self.btn_Pre_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UIExpelMonsterPreReward) elseif comp == self.btn_Reward then if not CTL.ExpelMonster.IsCanGetReward() then --不可领取 return end if not MDL.ExpelMonster.HasChanllengedToday() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ActivityBossFight_Hint_1"]) return end MDL.ExpelMonster.GuildScoreRewardReq() elseif comp == self.btn_Fight then if not MDL.Guild.IsHasGuild() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild"]) return end if CTL.ExpelMonster.IsInSettlementTime() then --结算时间 CTL.Tips.AddTipsMsg(Const_IDS["IDS_ActivityBossFight_Hint_6"]) return end if MDL.ExpelMonster.GetChanllengeTimes() <= 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ActivityBossFight_Hint_5"]) return end local bossFightData = CTL.ExpelMonster.GetActivityBossFightData(self.activityId) MDL.ExpelMonster.EnterExpelMonsterReq(bossFightData.BossLevelID) elseif comp == self.btn_Sweep then if not MDL.Guild.IsHasGuild() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild"]) return end if CTL.ExpelMonster.IsInSettlementTime() then --结算时间 CTL.Tips.AddTipsMsg(Const_IDS["IDS_ActivityBossFight_Hint_6"]) return end if MDL.ExpelMonster.GetChanllengeTimes() <= 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ActivityBossFight_Hint_5"]) return end MDL.ExpelMonster.ExpelMonsterSweepReq() end end function UIExpelMonsterMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.Scroll_Rank then if index <= 2 then cellTable.bg_Rank:SetState(index) else cellTable.bg_Rank:SetState(3) end cellTable.txt_RankBg.text = data.index cellTable.txt_Name.text = data.name cellTable.txt_Score.text = UTL.String.GetCountStr(math.ceil(data.param1)) elseif scrollRect == self.RewardScroll then UTL.Item.SetItemCell(cellTable.UIItem, data.Item, data.ItemNum) UIUtils.SetActive(cellTable.mask_Received, self.isMaxLv) UIUtils.SetActive(cellTable.effect_Receive, CTL.ExpelMonster.IsCanGetReward()) end end function UIExpelMonsterMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.RewardScroll then if target == cellTable.UIItem.event_Click then if CTL.ExpelMonster.IsCanGetReward() then if not MDL.ExpelMonster.HasChanllengedToday() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ActivityBossFight_Hint_1"]) return end MDL.ExpelMonster.GuildScoreRewardReq() else UTL.ItemTips.ShowCommonTipsById(data.Item) end end end end function UIExpelMonsterMain:OnClosed() UIManager.ActiveUIModle(true, "UIExpelMonsterMain") UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) EventSystem.Dispatch(EventID.UI_ExpelMonster_MainUIClosed) end return UIExpelMonsterMain