local UIWorldBossMainPanel = UIViewClass() local worldBossProtectTime = DataSheetManager.ConstData:GetDataByID("WorldBossProtectTime").IntValue local GuideMissionID = 1 local REMIND_ANIM_KEY = "WORLDBOSS_REMIND_ANIM" function UIWorldBossMainPanel:OnOpened(context) if not CTL.Unlock.CheckIfFuncUnlock(MDL.Unlock.FunctionType.WorldBoss, self, true) then return end self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) -- 界面标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_ActivityName_WorldBoss"]) if context then self.defaultSelectBossId = context[1] end self:RegistSystemEvent(EventID.UI_WorldBoss_UpdateInfo, self.UpdateWorldBossInfo) self:RegistSystemEvent(EventID.UI_WorldBoss_UpdateRewardTimes, self.UpdateWorldBossRewardTimes) self:RegistSystemEvent(EventID.UI_PurchaseNumsSuccess, self.UpdateWorldBossRewardTimes) self:InitScene() self:UpdateWorldBossInfo() --奖励次数 self:UpdateWorldBossRewardTimes() UIManager.ActiveUIModle(false, "UIWorldBossMainPanel") self:UpdateRemindAnim() end function UIWorldBossMainPanel: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 UIWorldBossMainPanel:CheckIfFuncUnlock(funcId, isUnlock) if funcId and funcId == MDL.Unlock.FunctionType.WorldBoss then CTL.Unlock.CheckIfFuncUnlock(funcId, self, true) end end --加个计时器,刷新数据 function UIWorldBossMainPanel:TimerFunc(deltaTime, timeSinceUpdate) logging.log(LTAG.LOG,"Refresh BossMain Info") self:UpdateWorldBossInfo() end function UIWorldBossMainPanel:UpdateWorldBossInfo() --下方boss选项 self.minTimeRefresh = 0 local selectIndex = 0 local maxIndex = 0 local maxLev = 0 local firstInfo = nil local isInit = self.group_Scroll.Count == 0 local index = 0 for i,info in ipairs(MDL.WorldBoss.WorldBossInfoDic) do local bossState,lev = CTL.WorldBoss.GetBossStateAndLev(info) --默认选中指定的boss if self.defaultSelectBossId then if self.defaultSelectBossId == info.ID then selectIndex = i - 1 end else --默认选中满足等级的 if self.SelectBossInfo == nil and bossState ~= CTL.WorldBoss.BossState.UnOpen and lev > maxLev then maxLev = lev maxIndex = index + 1 end if firstInfo == nil then firstInfo = info end end if isInit then self.group_Scroll:AddData(info, 0) else self.group_Scroll:UpdateIndex(index, info) end local refreshTime = CTL.WorldBoss.GetBossRefreshTime(info.BossConfig) if self.minTimeRefresh == 0 or self.minTimeRefresh > refreshTime then self.minTimeRefresh = refreshTime end index = index + 1 end if selectIndex > 0 then self.defaultSelectBossId = nil self:MoveAndSelectIndex(selectIndex - 1) else if self.SelectBossInfo == nil then if maxLev > 0 then self:MoveAndSelectIndex(maxIndex - 1) else self:MoveAndSelectIndex(0) end end end self:UpdateWorldBossEntryBtnState() self:StopRepeatFunc(self.TimerFunc) if self.minTimeRefresh > 0 then logging.log(LTAG.LOG,"Next Refresh BossMain Time",self.minTimeRefresh) self:StartRepeatFunc(self.TimerFunc, self.minTimeRefresh + 3) end end function UIWorldBossMainPanel:MoveAndSelectIndex(selectIndex) local max = #MDL.WorldBoss.WorldBossInfoDic - 1 if selectIndex <= max - 2 then if selectIndex <= 2 then self.group_Scroll:MoveIndex(0) else self.group_Scroll:MoveIndex(selectIndex - 2) end else self.group_Scroll:MoveEnd() end self.group_Scroll:SelectIndex(selectIndex) end --更新进入战斗按钮状态 function UIWorldBossMainPanel:UpdateWorldBossEntryBtnState() -- 特殊判断引导副本 if self.SelectBossInfo.ID == GuideMissionID and not MDL.WorldBoss.IsPassGuideMission() then self.btn_Challenge:SetGray(false) return end local state = CTL.WorldBoss.GetBossStateAndLev(self.SelectBossInfo) if state == CTL.WorldBoss.BossState.Opening then self.btn_Challenge:SetGray(false) else self.btn_Challenge:SetGray(true,true) end end function UIWorldBossMainPanel:InitScene() self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.BossShowModel) UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, ConstAssetPathConfig.Common2DScenePrefab, 1600, 0, 1600, ConstAssetPathConfig.AssetPath152, true, UTL.UIRender.LayerActiveType.BossChallenge) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0.16, -1.2, 0) -- 设置模型位移信息 UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) -- 设置模型位移信息 end function UIWorldBossMainPanel:UpdateBossDetail() if self.SelectBossInfo then -- 显示模型 local bossData = self.SelectBossInfo.BossConfig -- 释放之前的模型 UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) -- 加载模型、武器、灯光 UTL.UIRender.CreateNonPlayerModel(self.modelComponentDataHandle, bossData.BossShow, bossData.ModelScale, bossData.ShowEquipmentID, bossData.ModelLight) UIUtils.SetLabelText(self.txt_BossName,Const_IDS[bossData.WordBossName]) --参与奖励 local participateShowReward = bossData.ParticipateShowReward local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(participateShowReward) local rewardData = DataSheetUtil.GetRewardClientShowItemTable(cfg) self.LevelRewardScroll01:ReloadAll(rewardData) --额外奖励 local extraShowReward = bossData.ExtraShowReward local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(extraShowReward) local extraData = DataSheetUtil.GetRewardClientShowItemTable(cfg) self.LevelRewardScroll02:ReloadAll(extraData) self:UpdateWorldBossEntryBtnState() end end function UIWorldBossMainPanel:UpdateWorldBossRewardTimes() local totalTimes = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.WorldBoss).DailyRefreshTimes --只显示基础次数 local str = string.format("%d/%d", MDL.WorldBoss.RewardCountLeft, totalTimes) if MDL.WorldBoss.RewardCountLeft == 0 then str = UTL.Color.FormatRedColor(str) elseif MDL.WorldBoss.RewardCountLeft > totalTimes then str = UTL.Color.FormatGreenColor(str) end UIUtils.SetLabel(self.txt_Times,str) -- 副本引导任务 self:UpdateWorldBossEntryBtnState() self.group_Scroll:UpdateIndex(0) end function UIWorldBossMainPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_Scroll then --boss local bossInfo = data local bossState, bossLev = CTL.WorldBoss.GetBossStateAndLev(bossInfo) local bossConfig = bossInfo.BossConfig UIUtils.SetLabelText(cellTable.txt_Activities,Const_IDS[bossConfig.WordBossName]) UIUtils.SetImageByAssetBundle(cellTable.img_Icon, bossConfig.Icon) CTL.WorldBoss.SetBossLevel(cellTable.txt_Condition01, bossLev) cellTable.timer_Condition01:EndTimer() UnityEngine.UI.LayoutRebuilder.MarkLayoutForRebuild(cellTable.group_Condition02) cellTable.cdTimer:EndTimer() if bossInfo.ID == GuideMissionID and not MDL.WorldBoss.IsPassGuideMission() then -- 引导副本特殊判断 默认开启 cellTable.obj_mainState:SetState(2) elseif bossState == CTL.WorldBoss.BossState.UnOpen then cellTable.obj_mainState:SetState(1) cellTable.txt_lock.text = nil 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(cellTable.txt_Condition01, bossLev, 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 cellTable.timer_Condition01: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)) cellTable.timer_Condition01:ResetAndBeginCustomTimer(false, leftTime, 0, nil) end end isUnlock = false break end end elseif bossState == CTL.WorldBoss.BossState.WaitToOpen then--等待开启 --判断是否过了保护的时间 local rebornTime = bossInfo.NextTime - UTL.Time.GetServerTimestamp() local offsetTime = UTL.Time.GetServerSecondsIntervalFromZero() local endTime = DataSheetManager.TimeRefresh:GetDataByID(bossConfig.EndTime).HMS --复活时间 + 保护时间 > 活动结束时间 if (rebornTime + worldBossProtectTime) > (endTime - offsetTime) then cellTable.obj_mainState:SetState(0) cellTable.obi_subState:SetState(1) else cellTable.obj_mainState:SetState(0) cellTable.obi_subState:SetState(0) cellTable.cdTimer:ResetAndBeginTimer(false, rebornTime) end elseif bossState == CTL.WorldBoss.BossState.Opening then--正开启 cellTable.obj_mainState:SetState(2) elseif bossState == CTL.WorldBoss.BossState.Closed then --今天已结束 cellTable.obj_mainState:SetState(0) cellTable.obi_subState:SetState(1) else --今天未开启 cellTable.obj_mainState:SetState(0) cellTable.obi_subState:SetState(2) cellTable.txt_Condition05.text = UTL.Time.GetDiffLocalStrById(bossConfig.StartTime) end UIUtils.SetLabel(cellTable.txt_Condition02, CTL.LevelSelect.GetSubjugateGsText(bossConfig.SubjugateDataPVE, bossConfig.Battle)) else UTL.Item.SetItemCell(cellTable.item, data.ItemID,data.ItemNum) end end function UIWorldBossMainPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.group_Scroll then self.SelectBossInfo = data self:UpdateBossDetail() else UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end function UIWorldBossMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIWorldBossMainPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then MDL.WorldBoss.SetIsEnterMain(false) self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then MDL.WorldBoss.SetIsEnterMain(false) CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Challenge then if self.SelectBossInfo then if CTL.WorldBoss.TryToEnterWorldBoss(self.SelectBossInfo.ID) then MDL.WorldBoss.SetIsEnterMain(true) end end elseif comp == self.UITemplateTitlePanel.btn_Info then local _,timeStr = UTL.Time.GetDateDescAndTimeById(1501,1502) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.WorldBoss,params = {timeStr,UTL.Time.GetDiffLocalStrById(1)}}) elseif comp == self.btn_Remind then PersistentData.PlayerData:Set(REMIND_ANIM_KEY, true, true) self:UpdateRemindAnim() CTL.WorldBoss.OpenSettingNoticePanel() elseif comp == self.btn_Team then CTL.Team.OpenTeamPanel(LuaConst.ActivityType.WorldBoss) elseif comp == self.btn_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {SubIndex = 0}) elseif comp == self.btn_Info then UIUtils.SetActive(self.group_TipsPanel, true) UIUtils.SetActive(self.Btn_CloseClick, true) self.txt_Info.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_WorldBoss_EquipRewardDes) elseif comp == self.Btn_CloseClick then UIUtils.SetActive(self.group_TipsPanel, false) UIUtils.SetActive(self.Btn_CloseClick, false) end end function UIWorldBossMainPanel:OnClosed() UIManager.ActiveUIModle(true, "UIWorldBossMainPanel") UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end return UIWorldBossMainPanel