local UICountryWorldBossMain = UIViewClass() local worldBossProtectTime = DataSheetManager.ConstData:GetDataByID("WorldBossProtectTime").IntValue local OnePageNum = 6 local REMIND_ANIM_KEY = "WARZONE_BOSS_REMIND_ANIM" function UICountryWorldBossMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_CountryWorldBoss_UpdateInfo, self.UpdateCountryWorldBossList) self:RegistSystemEvent(EventID.UI_CountryWorldBoss_UpdateRewardTimes, self.UpdateCountryWorldBossRewardTimes) -- 刷新战区boss奖励次数 self:RegistSystemEvent(EventID.UI_PurchaseNumsSuccess, self.UpdateCountryWorldBossRewardTimes) -- 活动次数购买成功 self:RegistSystemEvent(EventID.UI_CountryWorldBoss_OnCloseGamePlay, self.OnCloseGamePlay) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_ActivityName_WarZoneBoss) self.curPage = 1 --奖励次数 self:UpdateCountryWorldBossRewardTimes() self:UpdateCountryWorldBossList() self:UpdateRemindAnim() end function UICountryWorldBossMain:UpdateRemindAnim() local state = PersistentData.PlayerData:Get(REMIND_ANIM_KEY, false) if state == false then if self.remindAnimID then self:PlayUIAnimation(self.remindAnimID) else self.remindAnimID = self:PlayUIAnimation("BtnShake") end else if self.remindAnimID then self:StopUIAnimation(self.remindAnimID, true, false, true) self.remindAnimID = nil end end end --加个计时器,刷新数据 function UICountryWorldBossMain:TimerFunc(deltaTime, timeSinceUpdate) logging.log(LTAG.LOG,"Refresh BossMain Info") self:UpdateCountryWorldBossList() end function UICountryWorldBossMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UICountryWorldBossMain:OnButtonClicked(comp) if self.UITemplateTitlePanel.btn_close == comp then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif self.UITemplateTitlePanel.btn_Info == comp then -- 玩法说明 local data = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.CountryWorldBoss).Time_Table[1] local _,timeStr = UTL.Time.GetDateDescAndTimeById(data.StartTime, data.EndTime) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.CountryWorldBoss, params = {timeStr, UTL.Time.GetDiffLocalStrById(1)}}) elseif self.btn_Remind == comp then -- 提醒 PersistentData.PlayerData:Set(REMIND_ANIM_KEY, true, true) self:UpdateRemindAnim() CTL.CountryWorldBoss.OpenSettingNoticePanel() elseif self.btn_WarList == comp then -- 战区列表 UIManager.OpenView(Const_UI_Lua.UIEnum.UIWarzoneList) elseif self.btn_Before == comp then if self.curPage > 1 then self.subView:CloseAll() self.curPage = self.curPage - 1 self:UpdateCountryWorldBossList() end elseif self.btn_Next == comp then if self.curPage < self.maxPage then self.subView:CloseAll() self.curPage = self.curPage + 1 self:UpdateCountryWorldBossList() end else for i, itemTable in pairs(self.group_bossItem) do if itemTable.bossItem.img_Click == comp then self.subView:CloseAll() self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICountryWorldBossDetail), self.bossInfoList[i]) return end end end end function UICountryWorldBossMain:UpdateCountryWorldBossRewardTimes() local totalTimes = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.CountryWorldBoss).DailyRefreshTimes --只显示基础次数 local str = string.format("%d/%d", MDL.CountryWorldBoss.GetRewardCountLeft(), totalTimes) if MDL.CountryWorldBoss.GetRewardCountLeft() == 0 then str = UTL.Color.FormatRedColor(str) elseif MDL.CountryWorldBoss.GetRewardCountLeft() > totalTimes then str = UTL.Color.FormatGreenColor(str) end UIUtils.SetLabel(self.txt_Times,str) end function UICountryWorldBossMain:UpdateCountryWorldBossList() self.CountryWorldBossDic = MDL.CountryWorldBoss.GetCountryWorldBossDic() if self.CountryWorldBossDic == nil or next(self.CountryWorldBossDic) == nil then return end -- 先设置最大页数 self.maxPage = 0 for i, info in pairs(self.CountryWorldBossDic) do local page = math.floor((i % 1000 - 1) / OnePageNum) + 1 if page >= self.maxPage then self.maxPage = page end if self.bossInfoList == nil or #self.bossInfoList == 0 then local bossState = CTL.WorldBoss.GetBossStateAndLev(info) if bossState ~= CTL.WorldBoss.BossState.UnOpen then self.curPage = math.max(page, self.curPage) end end end UIUtils.SetActive(self.ani_Before, self.curPage > 1) UIUtils.SetActive(self.ani_Next, self.curPage < self.maxPage) self.bossInfoList = {} for i = 1, OnePageNum do local index = (self.curPage - 1) * OnePageNum + i local info = self.CountryWorldBossDic[index + 1000] -- 战区boss配表从1000开始 local itemCell = self.group_bossItem[i] local bossItem = itemCell.bossItem if info then UIUtils.SetActive(itemCell.gameObject, true) self.minTimeRefresh = 0 local bossConfig = info.BossConfig local bossState = CTL.WorldBoss.GetBossStateAndLev(info) -- 用每页的第一个boss首领设置背景图片 if i == 1 then UIUtils.SetTextureByAssetBundle(self.img_bg, bossConfig.WarZoneBossBG) end -- 设置自身背景 UIUtils.SetImageByAssetBundle(bossItem.img_Bg, bossConfig.WarZoneBossPoint) if itemCell.img_Line then UIUtils.SetImageByAssetBundle(itemCell.img_Line, bossConfig.WarZoneBossPointLine) end UIUtils.SetLabelText(bossItem.txt_Name,Const_IDS[bossConfig.WordBossName]) UIUtils.SetImageByAssetBundle(bossItem.img_Boss, bossConfig.Icon) bossItem.effect_Show:SetSortingCanvas(self.subCanvas) CTL.WorldBoss.SetBossLevel(bossItem.txt_Lv, bossConfig.ShowLevel) bossItem.cdTimer:EndTimer() bossItem.timer_Lock:EndTimer() bossItem.effect_Show:StopUIEffect() if bossState == CTL.WorldBoss.BossState.UnOpen then--等级不足 bossItem.obj_mainState:SetState(1) local isUnlock = true for i, v in ipairs(bossConfig.Unlock_Table) do if CTL.Unlock.JudgeUnlockByParameterTable(v) == false then if v.UnlockCondition == LuaConst.UnlockConditionType.TeamLevel then CTL.WorldBoss.SetBossLevel(bossItem.txt_Lv, bossConfig.ShowLevel, UTL.Color.Red) elseif v.UnlockCondition == LuaConst.UnlockConditionType.ServerDay then local leftTime = (tonumber(v.UnlockConditionParam) - 1) * UTL.Time.TotalSecondsOneDay + MDL.Player.GetServerDayCountTimestamp() - UTL.Time.GetServerTimestamp() if leftTime > 0 then if self.minTimeRefresh == 0 or self.minTimeRefresh > leftTime then self.minTimeRefresh = leftTime end bossItem.timer_Lock:SetDHMSStr(UIUtils.GetLocalizedTxt(Const_IDS.IDS_7DayActivityNew_Hint2), UIUtils.GetLocalizedTxt(Const_IDS.IDS_7DayActivityNew_Hint3), UIUtils.GetLocalizedTxt(Const_IDS.IDS_7DayActivityNew_Hint4), UIUtils.GetLocalizedTxt(Const_IDS.IDS_7DayActivityNew_Hint5)) bossItem.timer_Lock:ResetAndBeginCustomTimer(false, leftTime, 0, nil) end end isUnlock = false break end end elseif bossState == CTL.WorldBoss.BossState.WaitToOpen then--等待开启 --判断是否过了保护的时间 local rebornTime = info.NextTime - UTL.Time.GetServerTimestamp() --复活时间 > 保护时间 (活动已经结束) if rebornTime > worldBossProtectTime then bossItem.obj_mainState:SetState(0) bossItem.obi_subState:SetState(1) else bossItem.obj_mainState:SetState(0) bossItem.obi_subState:SetState(0) bossItem.cdTimer:ResetAndBeginTimer(false, rebornTime) end elseif bossState == CTL.WorldBoss.BossState.Opening then--正开启 bossItem.obj_mainState:SetState(2) if MDL.CountryWorldBoss.GetRewardCountLeft() > 0 then bossItem.effect_Show:PlayUIEffect(bossConfig.WarZoneBossEffects, -1) end elseif bossState == CTL.WorldBoss.BossState.Closed then --今天已结束 bossItem.obj_mainState:SetState(0) bossItem.obi_subState:SetState(1) else --今天未开启 bossItem.obj_mainState:SetState(0) bossItem.obi_subState:SetState(2) bossItem.txt_Condition05.text = UTL.Time.GetDiffLocalStrById(bossConfig.StartTime) end self.bossInfoList[i] = info local refreshTime = CTL.WorldBoss.GetBossRefreshTime(info.BossConfig) if self.minTimeRefresh == 0 or self.minTimeRefresh > refreshTime then self.minTimeRefresh = refreshTime end else UIUtils.SetActive(itemCell.gameObject, false) end end self:StopRepeatFunc(self.TimerFunc) if self.minTimeRefresh > 0 then logging.log(LTAG.LOG,"Next Refresh CountryWorldBossMain Time",self.minTimeRefresh) self:StartRepeatFunc(self.TimerFunc, self.minTimeRefresh + 3) end end function UICountryWorldBossMain:OnCloseGamePlay() self:CloseView(true) end return UICountryWorldBossMain