local UIWorldBossRemind = UIViewClass() local AutoCloseTime = DataSheetManager.ConstData:GetDataByID("WorldBossRemindAutoCloseTime").IntValue function UIWorldBossRemind:OnOpened(bossInfo) if CTL.Country.IsInCountryScene() then --国战场景切换位置,防止UI重叠 self.state_Pos:SetState(1) else self.state_Pos:SetState(0) end self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) self:RegistSystemEvent(EventID.UI_WorldBoss_AddRemind, self.OnChangeRemind) self:StartRepeatFunc(self.TimerFunc, 1) self:UpdateBossInfo(bossInfo) end function UIWorldBossRemind:OnChangeRemind(bossInfo) if self.closeViewTime > 0 then local time = UTL.Time.GetServerTimestamp() + self.closeViewTime CTL.WorldBoss.SetRemindCloseTime(self.bossInfo.ID, time) else CTL.WorldBoss.SetRemindCloseTime(self.bossInfo.ID, nil) end self:ResetRepeatFunc(self.TimerFunc) self:UpdateBossInfo(bossInfo) end function UIWorldBossRemind:UpdateBossInfo(bossInfo) self.context = bossInfo self.bossInfo = bossInfo local bossData = bossInfo.BossConfig local activityData self.bossType = bossData.BossType if self.bossType == LuaConst.WorldBossType.WorldBoss then self.UIState:SetState(0) activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.WorldBoss) self.txt_Times.text = string.format("%d/%d", MDL.WorldBoss.RewardCountLeft, activityData.DailyRefreshTimes) elseif self.bossType == LuaConst.WorldBossType.WarZoneWorldBoss then self.UIState:SetState(1) activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.CountryWorldBoss) self.txt_Times.text = string.format("%d/%d", MDL.CountryWorldBoss.GetRewardCountLeft(), activityData.DailyRefreshTimes) end UIUtils.SetLabelText(self.txt_Name, Const_IDS[activityData.Activity]) UIUtils.SetImageByAssetBundle(self.img_Icon, bossData.Icon) self.txt_Level.text = UTL.Item.GetNobilityByTeamLevel(bossData.ShowLevel) -- 爵位转换 self.bossOpenTime = 0 self.bossUnOpen = false local state = CTL.WorldBoss.GetBossOpenState(bossInfo) if state == CTL.WorldBoss.BossState.Opening then self:OnBossOpen() else local offset = bossInfo.NextTime - UTL.Time.GetServerTimestamp() self.bossOpenTime = offset if offset > 0 then self.obj_state:SetState(1) self.cdTimer:ResetAndBeginCustomTimer(false, offset, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_WorldBoss_Remind_StartTime), 1) self.btn_Join:SetGray(true, true) UIUtils.SetActive(self.group_Condition01, true) self.bossUnOpen = true else self:OnBossOpen() end end self.closeTime = 0 local tarCloseTime = CTL.WorldBoss.GetRemindCloseTime(bossInfo.ID) if tarCloseTime then local offset = tarCloseTime - UTL.Time.GetServerTimestamp() if offset > 0 then self.closeTime = offset end else self.closeTime = AutoCloseTime + self.bossOpenTime end if self.closeTime > 0 then self.closeTimer:ResetAndBeginCustomTimer(false, self.closeTime, 0, "", 1) self.closeViewTime = self.closeTime else self:ManualClose() end end function UIWorldBossRemind:OnBossOpen() self.obj_state:SetState(0) self.bossUnOpen = false self.cdTimer:EndTimer() UIUtils.SetActive(self.group_Condition01, false) self.btn_Join:SetGray(false) end function UIWorldBossRemind:TimerFunc(deltaTime, timeSinceUpdate) if self.bossOpenTime <= 0 then if self.bossUnOpen == true then self:OnBossOpen() end else self.bossOpenTime = self.bossOpenTime - deltaTime end if self.closeViewTime <= 0 then self:ManualClose() else self.closeViewTime = self.closeViewTime - deltaTime end end function UIWorldBossRemind:OnButtonClicked(comp) if comp == self.btn_Join then if self.bossOpenTime > 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WorldBoss_Remind_WaitOpen"]) return end local state = CTL.WorldBoss.GetBossStateAndLev(self.bossInfo) if state == CTL.WorldBoss.BossState.Opening then MDL.WorldBoss.EnterWorldBossRequest(self.bossInfo.ID) elseif state == CTL.WorldBoss.BossState.WaitToOpen then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WorldBoss_Refuse_NotReborn"]) end elseif comp == self.btn_Close then self:ManualClose() elseif comp == self.btn_Setting then if self.bossType == LuaConst.WorldBossType.WorldBoss then CTL.WorldBoss.OpenSettingNoticePanel() elseif self.bossType == LuaConst.WorldBossType.WarZoneWorldBoss then CTL.CountryWorldBoss.OpenSettingNoticePanel() end end end function UIWorldBossRemind:ManualClose() self.closeViewTime = 0 CTL.WorldBoss.RemoveRemind(self.bossInfo) self:CloseView() CTL.WorldBoss.OpenNextRemind(false) end function UIWorldBossRemind:OnClosed() if self.closeViewTime > 0 then local time = UTL.Time.GetServerTimestamp() + self.closeViewTime CTL.WorldBoss.SetRemindCloseTime(self.bossInfo.ID, time) else CTL.WorldBoss.SetRemindCloseTime(self.bossInfo.ID, nil) end end return UIWorldBossRemind