local UIPersonalBossPanel = UIViewClass() local HeadImgPath = ConstAssetPathConfig.HeadImgPath local SelectedScaleRatio = 1.2 local Common2DScenePrefab = ConstAssetPathConfig.Common2DScenePrefab local EventSystem = require('Event/EventSystem') local SelectCellEffectConfig = { [MDL.PersonalBoss.DifficultIndex.Nightmare] = ConstAssetPathConfig.AssetPath153, [MDL.PersonalBoss.DifficultIndex.Hell] = ConstAssetPathConfig.AssetPath153, [MDL.PersonalBoss.DifficultIndex.Purgatory] = ConstAssetPathConfig.AssetPath154, [MDL.PersonalBoss.DifficultIndex.Max] = ConstAssetPathConfig.AssetPath154, } function UIPersonalBossPanel:OnOpened(context) self.difficultTrans = self.group_Difficult.gameObject.transform self.oriAnchorPosX, self.oriAnchorPosY = self.difficultTrans:GetAnchoredPosition() self.modelComponentHandle = UTL.UIRender.CreateModelComponentDatas(self.BossShowScene) -- 界面标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title,Const_IDS.IDS_PersonalBoss_PersonalBoss) if context then self.defaultSelectBossId = context[1] local personalBossData = DataSheetManager.PersonalBoss:GetDataByID(self.defaultSelectBossId) self.curDifficultIndex = personalBossData.Level end self:ShowDifficultBtns() self.selectIndex = 0 self:RefreshPersonalBossPanel() self:UpdatePersonalRewardTimes() self:RegistSystemEvent(EventID.UI_PersonalBoss_UpdateRewardTimes, self.UpdatePersonalRewardTimes) self:RegistSystemEvent(EventID.UI_FubenQuickPass, self.OnFubenQuickPass) if not GameAppInfo.IsOverseaPackage() then self:RegistSystemEvent(EventID.UI_PersonalBoss_RefreshFirstPassInfo, self.RefreshFirstPassInfo) end UIManager.ActiveUIModle(false, "UIPersonalBossPanel") -- 打开界面的时候 重新请求一下 MDL.PersonalBoss.PersonalBossGetInfoReq() end function UIPersonalBossPanel:RefreshPersonalBossPanel() self.passBossId = MDL.PersonalBoss.GetPassBossID() if self.passBossId == DataSheetManager.PersonalBoss:GetDataCount() then self.nextData = DataSheetManager.PersonalBoss:GetDataByID(self.passBossId) else self.nextData = DataSheetManager.PersonalBoss:GetDataByID(self.passBossId + 1) end self:UpdatePersonalBossInfo(self.curDifficultIndex) end function UIPersonalBossPanel:OnFubenQuickPass(mapType) if mapType == LuaConst.LevelType.PersonalBoss then self:RefreshPersonalBossPanel() end end function UIPersonalBossPanel:ShowDifficultBtns() local index = MDL.PersonalBoss.GetDifficultIndex() if self.curDifficultIndex == nil then self.curDifficultIndex = MDL.PersonalBoss.GetCurShowDifficultIndex() end if index == MDL.PersonalBoss.DifficultIndex.Normal then --全部隐藏 for i, v in ipairs(self.group_Difficult) do UIUtils.SetActive(v, false) end elseif index == MDL.PersonalBoss.DifficultIndex.Max then --全部显示 for i, v in ipairs(self.group_Difficult) do UIUtils.SetActive(v, true) end else for i, v in ipairs(self.group_Difficult) do if i <= index then UIUtils.SetActive(v, true) else UIUtils.SetActive(v, false) end end end if index >= MDL.PersonalBoss.DifficultIndex.Hell then --需要将scroll的滑动至最后 self.difficultTrans:SetAnchoredPosition(self.oriAnchorPosX - 1000, self.oriAnchorPosY) end end function UIPersonalBossPanel:OnClickDifficultBtn(comp) self.selectIndex = 0 for i, v in ipairs(self.group_Difficult) do if comp == v then self:UpdatePersonalBossInfo(i) end end end function UIPersonalBossPanel:RefreshSelectedButtonState(index) for i, v in ipairs(self.group_Difficult) do if i == index then v.gameObject.transform:SetLocalScale(SelectedScaleRatio, SelectedScaleRatio, SelectedScaleRatio) else v.gameObject.transform:SetLocalScale(1, 1, 1) end end end function UIPersonalBossPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIPersonalBossPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Challenge then if self.SelectBossInfo then --重新获取下状态,可能没刷新 local state = CTL.PersonalBoss.GetBossStateAndLev(self.SelectBossInfo[1]) if state == CTL.PersonalBoss.BossState.UnOpen then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS["IDS_WorldBoss_State_LevelNotEnough"]) elseif state == CTL.PersonalBoss.BossState.Opening then self:OnClickPersonalBossChallenge() end end elseif comp == self.btn_Sweep then self:OnClickSweep() elseif comp == self.UITemplateTitlePanel.btn_Info then local timeStr1 = UTL.Time.GetDiffLocalStrById(1) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.PersonalBoss, params = {timeStr1}}) elseif comp == self.btn_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, { SubIndex = 0 }) else self:OnClickDifficultBtn(comp) end end function UIPersonalBossPanel:OnClosed() UTL.UIRender.DisposeModelComponentData(self.modelComponentHandle) UIManager.ActiveUIModle(true, "UIPersonalBossPanel") EventSystem.Dispatch(EventID.UI_Activity_Refresh_ListOrder) end --region -----循环列表---- function UIPersonalBossPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_Scroll then --boss local showUnlock = false local showLevelText = true local bossConfig = data[1] local bossLev = data[2] UIUtils.SetLabelText(cellTable.txt_BossName, Const_IDS[bossConfig.WordBossName]) -- boss名 UIUtils.SetImageByAssetBundle(cellTable.img_HeroHead, string.format(HeadImgPath, bossConfig.Icon)) -- boss图片 UIUtils.SetLabel(cellTable.txt_Number, CTL.LevelSelect.GetSubjugateGsText(bossConfig.SubjugateDataPVE, bossConfig.Battle)) -- 推荐战力 UnityEngine.UI.LayoutRebuilder.MarkLayoutForRebuild(cellTable.group_RecommendCapability) -- 推荐战力 cellTable.img_Background:SetState(bossConfig.Level - 1) cellTable.img_Background_Cover:SetState(bossConfig.Level - 1) -- 未解锁图片显隐 if self.nextData then if bossConfig.ID > self.nextData.ID then showUnlock = true showLevelText = false elseif bossConfig.ID == self.nextData.ID then if not MDL.Unlock.IsComplete(self.nextData.Unlock_Table[1].UnlockCondition, self.nextData.Unlock_Table[1].UnlockConditionParam) then showUnlock = true showLevelText = false end end end -- if showUnlock then -- CTL.PersonalBoss.SetBossLevel(cellTable.txt_UnlockLevel, bossLev, UTL.Color.Red) -- else -- CTL.PersonalBoss.SetBossLevel(cellTable.txt_Level, bossLev) -- end UIUtils.SetActive(cellTable.group_locked.gameObject, showUnlock) UIUtils.SetActive(cellTable.group_Level.gameObject, showLevelText) UIUtils.SetActive(cellTable.img_BgSelect.gameObject, self.selectIndex == index) if self.selectIndex == index and SelectCellEffectConfig[bossConfig.Level] then cellTable.effect_Selected:PlayUIEffect(SelectCellEffectConfig[bossConfig.Level], -1) else cellTable.effect_Selected:StopUIEffect() end else UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum, data.FristGothrough) end end function UIPersonalBossPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.group_Scroll then self:UpdatePersonalBossDetail(index, data) else UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end --endregion -----循环列表---- function UIPersonalBossPanel:UpdatePersonalBossInfo(difficultIndex, isInit) self.state_Difficulty:SetState(difficultIndex - 1) --下方boss选项 local selectIndex = 0 local maxIndex = 0 local maxLev = 0 local index = 0 local dataList = {} local list = MDL.PersonalBoss.GetDifficultList(difficultIndex) for i, info in ipairs(list) do local bossState, lev = CTL.PersonalBoss.GetBossStateAndLev(info) local data = { [1] = info, [2] = lev } --默认选中指定的boss if self.defaultSelectBossId and self.curDifficultIndex == info.Level then if self.defaultSelectBossId == info.ID then selectIndex = i - 1 end else --默认选中满足等级的 if self.curDifficultIndex == info.Level and self.SelectBossInfo == nil and lev > maxLev and info.ID == self.passBossId + 1 then if bossState ~= CTL.PersonalBoss.BossState.UnOpen then maxLev = lev maxIndex = index + 1 else local bossState, level = CTL.PersonalBoss.GetBossStateAndLev(DataSheetManager.PersonalBoss:GetDataByID(info.ID)) maxLev = level maxIndex = index end end index = index + 1 end table.insert(dataList, data) end if selectIndex > 0 then self.defaultSelectBossId = nil self.selectIndex = selectIndex - 1 else if self.SelectBossInfo == nil then if maxLev > 0 then self.selectIndex = maxIndex - 1 else self.selectIndex = 0 local bossState, lev = CTL.PersonalBoss.GetBossStateAndLev(dataList[#dataList][1]) if bossState == CTL.PersonalBoss.BossState.Opening then self.selectIndex = #dataList - 1 end end end end self.group_Scroll:ReloadAll(dataList) self.SelectBossInfo = {[1] = self:GetSelectBossInfo(difficultIndex, self.selectIndex + 1) } self.recommendIndex = self.SelectBossInfo[1].ID -- 这里记录一下当前可挑战的最前bossID,下面判断是否弹窗 self:MoveIndex(#dataList - 1,self.selectIndex) self:UpdatePersonalBossDetail(self.selectIndex, self.SelectBossInfo, true) self:RefreshSelectedButtonState(difficultIndex) end function UIPersonalBossPanel:MoveIndex(max, selectIndex) if selectIndex <= max - 2 then if selectIndex <= 1 then self.group_Scroll:MoveIndex(0) else self.group_Scroll:MoveIndex(selectIndex - 1) end else self.group_Scroll:MoveEnd() end end function UIPersonalBossPanel:GetSelectBossInfo(difficultIndex, bossIndex) local index = 1 for i, info in DataSheetManager.PersonalBoss:GetEnumerator() do if info.Level == difficultIndex then if index == bossIndex then return info end index = index + 1 end end end function UIPersonalBossPanel:UpdatePersonalBossDetail(cellIndex, bossInfo, isInit) if not isInit then if self.SelectBossInfo[1].ID == bossInfo[1].ID then return end -- 判断等级 local tmpIsUnlock, tmpContent = MDL.Unlock.IsComplete(bossInfo[1].Unlock_Table[1].UnlockCondition, bossInfo[1].Unlock_Table[1].UnlockConditionParam, "IDS_MultiplayerDungeon_InsufficientLevel2") if not tmpIsUnlock then CTL.Tips.AddTipsMsg(tmpContent) return end end -- 先判断是否是可挑战的下一关 if self.nextData and self.nextData.ID < bossInfo[1].ID then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS["IDS_MultiplayerDungeon_Tips4"]) return end self.SelectBossInfo = bossInfo local passCellIndex = self.selectIndex self.selectIndex = cellIndex self.group_Scroll:UpdateIndex(passCellIndex) self.group_Scroll:UpdateIndex(self.selectIndex) --显示模型 local bossData = self.SelectBossInfo[1] local equipTable = {} if bossData.ShowEquipmentID and bossData.ShowEquipmentID > 0 then local equipData = DataSheetManager.EquipPartsData:GetDataByID(bossData.ShowEquipmentID) for i, v in ipairs(equipData.EquipPart_Table) do local data = {} data.Prefeb = v.Prefeb data.EquipSlotStr = v.EquipSlotStr table.insert(equipTable, data) end end --加载新模型之前先卸载掉之前的模型 UTL.UIRender.DisposePlayerModel(self.modelComponentHandle) --加载模型并设置2D背景 local bgTexturePath = ConstAssetPathConfig.bgTexturePath3 UTL.UIRender.Create2DTextureBgScene(self.modelComponentHandle, bgTexturePath, nil, nil, nil) UTL.UIRender.CreateNonPlayerModel(self.modelComponentHandle, bossData.BossShow, bossData.ModelScale, bossData.ShowEquipmentID, bossData.ModelLight, bossData.ModelOffset) UTL.UIRender.SetHeroParentPos(self.modelComponentHandle, 0.12, -1.36, 0) UTL.UIRender.SetHeroParentRot(self.modelComponentHandle, 0, -10, 0) -- 首通 self.group_ChallengeChance:SetState(bossInfo[1].ID == self.passBossId + 1 and 1 or 0) -- 扫荡按钮 if bossInfo[1].ID < self.passBossId + 1 then self.btn_Sweep:SetText(UIUtils.GetLocalizedTxt(Const_IDS.IDS_ResourcesChapter_button_1)) UIUtils.SetActive(self.btn_Sweep, true) elseif MDL.Player.GetLineUpGs()>=self.SelectBossInfo[1].Battle then self.btn_Sweep:SetText(UIUtils.GetLocalizedTxt(Const_IDS.IDS_PlayEasier_Button)) UIUtils.SetActive(self.btn_Sweep, true) else UIUtils.SetActive(self.btn_Sweep, false) end -- 首通玩家 if not GameAppInfo.IsOverseaPackage() then self:RefreshFirstPassInfo() end --参与奖励 local participateShowReward = bossData.ParticipateShowReward local rewardData = {} local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(participateShowReward) local itemTable = DataSheetUtil.GetRewardClientShowItemTable(cfg) for _,v in ipairs(itemTable) do if (self.SelectBossInfo[1].ID == self.passBossId + 1) == v.FristGothrough then table.insert(rewardData, v) elseif v.FristGothrough == false then table.insert(rewardData, v) end end self.loop_PBReward:ReloadAll(rewardData) self:UpdateBtnState() self.RewardFrame:SetState(bossData.Level - 1) end --更新按钮状态 function UIPersonalBossPanel:UpdateBtnState() local state = CTL.PersonalBoss.GetBossStateAndLev(self.SelectBossInfo[1]) if state == CTL.PersonalBoss.BossState.Opening then self.btn_Challenge:SetGray(false) else self.btn_Challenge:SetGray(true, true) end end function UIPersonalBossPanel:OnClickSweep() if self.haveRewardCount <= 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_PersonalBoss_Exhaust) return end if self.SelectBossInfo[1].ID < self.passBossId + 1 then MDL.PersonalBoss.SweepSelfBossReq(self.SelectBossInfo[1].ID) else UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_PlayEasier_Button, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PlayEasier_Tips2), function() MDL.LevelSelect.FubenQuickPassReq(LuaConst.LevelType.PersonalBoss, self.SelectBossInfo[1].ID, self.SelectBossInfo[1].ID) end) end end --进入关卡逻辑 function UIPersonalBossPanel:OnClickPersonalBossChallenge(clickIndex) if self.haveRewardCount > 0 or self.SelectBossInfo[1].ID == self.passBossId + 1 then -- 六测先不开这个弹窗,先隐藏代码 --if self.recommendIndex > self.SelectBossInfo[1].ID then --UIManager.OpenView(Const_UI_Lua.UIEnum.UIPersonalBossNotice, {bossID = self.SelectBossInfo[1].ID, recommendBossID = self.recommendIndex}) --else MDL.PersonalBoss.EnterPersonalBossRequest(self.SelectBossInfo[1].ID) --end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_PersonalBoss_Exhaust) end end function UIPersonalBossPanel:UpdatePersonalRewardTimes() if self.totalAwardTimes == nil then local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.PersonalBoss) self.totalAwardTimes = activityData.DailyRefreshTimes end local curCount = MDL.PersonalBoss.GetRewardCountLeft() self.haveRewardCount = self.totalAwardTimes >= curCount and self.totalAwardTimes - curCount or 0 local str = string.format("%d/%d", self.haveRewardCount, self.totalAwardTimes) if self.haveRewardCount == 0 then str = UTL.Color.FormatRedColor(str) elseif self.haveRewardCount > self.totalAwardTimes then str = UTL.Color.FormatGreenColor(str) end UIUtils.SetLabel(self.txt_Number, str) end function UIPersonalBossPanel:RefreshFirstPassInfo() local firstPassInfo = MDL.PersonalBoss.GetFirstPassInfoByBossId(self.SelectBossInfo[1].ID) if firstPassInfo then self.group_First.UIState:SetState(0) -- 设置玩家名字 UIUtils.SetLabel(self.group_First.txt_Name, firstPassInfo.name) -- 设置玩家头像 CTL.Character.SetPortraitAndFrame(self.group_First.HeroHead, firstPassInfo.PortraitId, firstPassInfo.FrameId) -- 设置首通时间 UIUtils.SetLabel(self.group_First.txt_Time, UTL.Time.FormatTimeCompletely(firstPassInfo.passTime)) else self.group_First.UIState:SetState(1) end end return UIPersonalBossPanel