local UIMultiplayerDungeonMain = UIViewClass() local MaxTeamMemberNum = 3 function UIMultiplayerDungeonMain:OnOpened(context) self.context = context self:RegistSystemEvent(EventID.UI_UpdateMultiplayerDungeonRewardTimes, self.OnBackButtonPressed) -- 收到这个协议需要关闭该界面 self:RegistSystemEvent(EventID.UI_UpdateMultiplayerDungeonDifficultInfo, self.RefreshRightInfo) self.levelData = MDL.MultiplayerDungeon.GetConfigByActivitiesID(self.context.activitiesID) self.passFarthestId = MDL.MultiplayerDungeon.GetPassFarthestIDByActivitiesID(self.context.activitiesID) local teamActivityData = DataSheetManager.ActivityData:GetDataByID(self.context.activitiesID) self.selectIndex = 0 self:InitData() -- 界面标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[teamActivityData.Activity]) -- 队伍人数 UIUtils.SetLabel(self.txt_TeamMember, string.FormatByIdsId(Const_IDS["IDS_MultiplayerDungeon_PlayerNum"], string.format("%s/%s", MDL.Team.GetTeamMemberNumbers(), MaxTeamMemberNum))) UIManager.ActiveUIModle(false, "UIMultiplayerDungeonMain") UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) end function UIMultiplayerDungeonMain:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) UIManager.ActiveUIModle(true, "UIMultiplayerDungeonMain") end function UIMultiplayerDungeonMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIMultiplayerDungeonMain: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_Strategy then -- 攻略 UIManager.OpenView(Const_UI_Lua.UIEnum.UIMultiplayerDungeonStrategy, {levelID = self.curDifficultyID}) elseif comp == self.btn_Tip then -- 打开奖励提示 UIUtils.SetActive(self.group_RewardTips.gameObject, true) elseif comp == self.btn_closeRewardTips then -- 关闭奖励提示 UIUtils.SetActive(self.group_RewardTips.gameObject, false) elseif comp == self.btn_Troop then -- 组队平台 CTL.Team.OpenTeamPanel(self.context.activitiesID) elseif comp == self.btn_TeamChallenge then -- 进入战斗 CTL.MultiplayerDungeon.EnterBattle(self.context.activitiesID, self.curDifficultyID) elseif comp == self.btn_TeamInfo or comp == self.btn_TeamInfo2 then -- 打开首通队伍界面 UIUtils.SetActive(self.group_Team.gameObject, true) elseif comp == self.btn_CloseTeam or comp == self.btn_teamBg then -- 关闭首通队伍界面 UIUtils.SetActive(self.group_Team.gameObject, false) elseif comp == self.btn_Shop then --店铺 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.ZuDui}) end end --region *********** 难度 ************* function UIMultiplayerDungeonMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_DifficultyScroll then local teamLevel = MDL.Player.GetRoleLevel() -- 难度 UIUtils.SetLabel(cellTable.txt_Difficulty, string.FormatByIdsId(Const_IDS["IDS_ActivityName_Difficulty"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_Number_Written_"..data.Difficulty]))) local isLock = CTL.Unlock.JudgeIfSatisfiedUnlockTable(data.Unlock_Table) local unlockLevel = CTL.Unlock.GetUnlockLevelByParameterTable(data.Unlock_Table) -- 红点 cellTable.cell:SetRedPoint(isLock and (self.nextData and data.ID == self.nextData.ID) or false) local levelStr = UTL.Item.GetNobilityByTeamLevel(unlockLevel) -- 爵位转换 -- 等级要求 if unlockLevel > teamLevel then levelStr = UTL.Color.FormatRedColor(levelStr) end cellTable.timer_Condition01:EndTimer() if isLock then UIUtils.SetLabel(cellTable.txt_EssentialLevel, string.FormatByIdsId(Const_IDS["IDS_MultiplayerDungeon_Lv"], levelStr)) else for i, v in ipairs(data.Unlock_Table) do if CTL.Unlock.JudgeUnlockByParameterTable(v) == false then if v.UnlockCondition == LuaConst.UnlockConditionType.TeamLevel then UIUtils.SetLabel(cellTable.txt_EssentialLevel, string.FormatByIdsId(Const_IDS["IDS_MultiplayerDungeon_Lv"], levelStr)) 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 break end end end -- 未锁定图片显隐 UIUtils.SetActive(cellTable.img_Lock.gameObject, false) if self.nextData then if data.ID > self.nextData.ID then UIUtils.SetActive(cellTable.img_Lock.gameObject, true) elseif data.ID == self.nextData.ID then if not CTL.Unlock.JudgeIfSatisfiedUnlockTable(self.nextData.Unlock_Table) then UIUtils.SetActive(cellTable.img_Lock.gameObject, true) end end end cellTable.state:SetState(self.selectIndex == index and 1 or 0) elseif scrollRect == self.loop_RewardPreview then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum) UIUtils.SetActive(cellTable.item.group_txt_Team, data.isTeamReward) end end function UIMultiplayerDungeonMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_RewardPreview then UTL.ItemTips.ShowCommonTipsById(data.ItemID) elseif scrollRect == self.group_DifficultyScroll then self:RefreshDifficultyInfo(index, false) end end --endregion *********** 难度 ************* function UIMultiplayerDungeonMain:InitData() local bossData = DataSheetManager.MultiplayerDungeonBoss:GetDataByID(self.context.activitiesID) -- 关卡简介 UIUtils.SetLabelText(self.txt_Introduction, Const_IDS[bossData.BossDes]) UIUtils.SetActive(self.group_Team.gameObject, false) UIUtils.SetActive(self.group_RewardTips.gameObject, false) self.minTimeRefresh = 0 self.passFarthestIndex = 1 local nextIndex = 1 self.nextData = nil for index, data in ipairs(self.levelData) do if self.passFarthestId == 0 then self.passFarthestIndex = index nextIndex = index self.nextData = self.levelData[self.passFarthestIndex] break end if data.ID == self.passFarthestId then self.passFarthestIndex = index if index < #self.levelData then nextIndex = index + 1 self.nextData = self.levelData[self.passFarthestIndex + 1] break end end end -- 难度列表 if self.context and self.context.levelID and self.context.levelID > 0 then self.selectIndex = self.context.levelID - 1 else if self.nextData and CTL.Unlock.JudgeIfSatisfiedUnlockTable(self.nextData.Unlock_Table) then self.selectIndex = nextIndex -1 else self.selectIndex = self.passFarthestIndex -1 end end for index, data in ipairs(self.levelData) do self.group_DifficultyScroll:AddData(data, 0) end if self.passFarthestIndex <= #self.levelData and self.passFarthestIndex >= #self.levelData - 5 then self.group_DifficultyScroll:MoveIndex(self.passFarthestIndex -1) end if #self.levelData <= 6 then -- 小于6个不能滑动 self.group_DifficultyScroll:SetMovementType(3) else self.group_DifficultyScroll:SetMovementType(1) end self:RefreshDifficultyInfo(self.selectIndex, true) if self.minTimeRefresh > 0 then self:StartRepeatFunc(self.RefreshTab, self.minTimeRefresh + 1, 1) end -- BOSS名 UIUtils.SetLabelText(self.txt_BossName, Const_IDS[bossData.BossName]) self.BossShowScene:Show2DBGModel(bossData.BossShow, UTL.UIRender.GetBossEquipTable(bossData), bossData.ModelScale, bossData.ModelLight) -- 加载模型 self.BossShowScene:SetSceneTexture(ConstAssetPathConfig.Path35) -- 加载2D背景 self.BossShowScene:SetNodePos(0.5,-1.36,0) -- 设置模型位移信息 self.BossShowScene:SetNodeRot(0,-10,0) -- 设置模型旋转角度 self.BossShowScene:SetSceneShadowPlane(true) -- 设置阴影面开关 -- 奖励次数 local rewardCountInfo = MDL.MultiplayerDungeon.GetRewardCountLeft() if rewardCountInfo.curCount == 0 then rewardCountInfo.curCount = UTL.Color.FormatRedColor(rewardCountInfo.curCount) end UIUtils.SetLabel(self.txt_RewardTimes, string.FormatByIdsId(Const_IDS["IDS_MultiplayerDungeon_RewardNum"], string.format("%s/%s", rewardCountInfo.curCount, rewardCountInfo.sumCount))) end -- 根据难度等级刷新右侧数据 function UIMultiplayerDungeonMain:RefreshDifficultyInfo(cellIndex, isInit) self.curCellData = self.levelData[cellIndex + 1] if not isInit then -- 判断等级 local tmpIsUnlock, tmpContent = CTL.Unlock.JudgeIfSatisfiedUnlockTable(self.curCellData.Unlock_Table) if not tmpIsUnlock then CTL.Tips.AddTipsMsgAndPlaySound(tmpContent) return end -- 先判断是否是可挑战的下一关 if self.nextData and self.nextData.ID < self.curCellData.ID then CTL.Tips.AddTipsMsgAndPlaySound(Const_IDS["IDS_MultiplayerDungeon_Tips4"]) return end end self.curDifficultyID = self.curCellData.ID if isInit then self:RefreshRightInfo(cellIndex) else MDL.MultiplayerDungeon.MultiplayerDungeonSpecialDifficultInfoRequest(self.context.activitiesID, self.curCellData.ID, cellIndex) end end function UIMultiplayerDungeonMain:RefreshRightInfo(cellIndex) local passCellIndex = self.selectIndex self.selectIndex = cellIndex self.group_DifficultyScroll:UpdateIndex(passCellIndex) self.group_DifficultyScroll:UpdateIndex(self.selectIndex) -- 难度等级 UIUtils.SetLabel(self.txt_Difficulty, string.FormatByIdsId(Const_IDS["IDS_ActivityName_Difficulty"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_Number_Written_"..self.curCellData.Difficulty]))) -- 推荐战力 UIUtils.SetLabel(self.txt_RecommendCapability, CTL.LevelSelect.GetSubjugateGsText(self.curCellData.SubjugateDataPVE, self.curCellData.Power)) -- 推荐战力 -- 通关奖励 local rewardDataList = {} if self.curCellData.ID > self.passFarthestId then -- 首通奖励 rewardDataList = DataSheetManager.FirstStageUnlockReward:GetDataByID(self.curCellData.FirstStageUnlockReward).Item_Table UIUtils.SetLabelText(self.txt_CompleteReward, Const_IDS.IDS_MultiplayerDungeon_Reward) self.txt_RewardTips.text = nil else --显示当前通关最远的奖励 UIUtils.SetLabelText(self.txt_CompleteReward, Const_IDS.IDS_MultiplayerDungeon_RewardTips2) local farthestData = self.levelData[self.passFarthestIndex] rewardDataList = DataSheetManager.StageUnlockReward:GetDataByID(farthestData.StageUnlockReward).Item_Table UIUtils.SetLabelText(self.txt_RewardTips,Const_IDS.IDS_MultiplayerDungeon_RewardTips1) end self.loop_RewardPreview:ClearCells() for k,v in ipairs(rewardDataList) do self.loop_RewardPreview:AddData({ItemID = v.ItemID, ItemNum = v.ItemNum, isTeamReward = false} , 0) end if GameAppInfo.IsJapanesePackage() then local teamRewardList = DataSheetManager.StageUnlockReward:GetDataByID(self.curCellData.TeamReward).Item_Table for k,v in ipairs(teamRewardList) do self.loop_RewardPreview:AddData({ItemID = v.ItemID, ItemNum = v.ItemNum, isTeamReward = true} , 0) end end -- 首次标签显隐 local passFarthesData = self.levelData[self.passFarthestIndex] if self.nextData then UIUtils.SetActive(self.group_FirstTime.gameObject, self.curCellData.Difficulty > passFarthesData.Difficulty or passFarthesData.ID == self.nextData.ID) else UIUtils.SetActive(self.group_FirstTime.gameObject, self.curCellData.Difficulty > passFarthesData.Difficulty) end self:RefreshTeamInfo() end -- 刷新通关队伍信息 function UIMultiplayerDungeonMain:RefreshTeamInfo() local teamInfo = MDL.MultiplayerDungeon.GetTeamInfoByActivitiesID(self.context.activitiesID, self.curDifficultyID) if teamInfo then self.state_Info:SetState(1) -- 队长 for i = 1, #teamInfo.firstPassTeam.memberInfo do UIUtils.SetActive(self.group_TeamInfoList[i].gameObject, true) UIUtils.SetLabel(self.group_TeamInfoList[i].txt_PlayerName, teamInfo.firstPassTeam.memberInfo[i].name) CTL.Character.SetPortraitAndFrame(self.group_TeamInfoList[i].UIHeroHead150, teamInfo.firstPassTeam.memberInfo[i].portraitId, teamInfo.firstPassTeam.memberInfo[i].frameId) end for i = #teamInfo.firstPassTeam.memberInfo + 1, #self.group_TeamInfoList do UIUtils.SetActive(self.group_TeamInfoList[i].gameObject, false) end -- 首通队伍 local timeData = os.date(UTL.Time.FormatDateEnum.YMDHMS, teamInfo.firstPassTeam.passTime) UIUtils.SetLabel(self.txt_FirstCompleteDate, timeData) for index, info in ipairs(teamInfo.firstPassTeam.memberInfo) do UIUtils.SetLabel(self.group_FirstTeam[index].txt_PlayerName, info.name) CTL.Character.SetPortraitAndFrame(self.group_FirstTeam[index].UIHeroHead150, info.portraitId, info.frameId) end for i = #teamInfo.firstPassTeam.memberInfo + 1, #self.group_FirstTeam do UIUtils.SetLabel(self.group_FirstTeam[i].txt_PlayerName, nil) CTL.Character.SetHeadEmpty(self.group_FirstTeam[i].UIHeroHead150) end -- 最快通关队伍 local timeData = os.date(UTL.Time.FormatDateEnum.MS, teamInfo.fastTeam.useTime) UIUtils.SetLabelText(self.txt_FirstCompleteTimeUse, Const_IDS["IDS_MultiplayerDungeon_UseTime"]) UIUtils.SetLabel(self.txt_FastestCompleteTime, timeData) for index, info in ipairs(teamInfo.fastTeam.memberInfo) do UIUtils.SetLabel(self.group_FastestTeam[index].txt_PlayerName, info.name) CTL.Character.SetPortraitAndFrame(self.group_FastestTeam[index].UIHeroHead150, info.portraitId, info.frameId) end for i = #teamInfo.fastTeam.memberInfo + 1, #self.group_FastestTeam do UIUtils.SetLabel(self.group_FastestTeam[i].txt_PlayerName, nil) CTL.Character.SetHeadEmpty(self.group_FastestTeam[i].UIHeroHead150) end else UIUtils.SetLabel(self.txt_FirstCompleteDate, nil) UIUtils.SetLabel(self.txt_FastestCompleteTime, nil) UIUtils.SetLabel(self.txt_FirstCompleteTimeUse, nil) self.state_Info:SetState(0) CTL.Character.SetHeadEmpty(self.UIHeroHead150) for index,State in ipairs(self.group_FirstTeam) do UIUtils.SetLabel(self.group_FirstTeam[index].txt_PlayerName, nil) CTL.Character.SetHeadEmpty(State.UIHeroHead150) end for index,State in ipairs(self.group_FastestTeam) do UIUtils.SetLabel(self.group_FastestTeam[index].txt_PlayerName, nil) CTL.Character.SetHeadEmpty(State.UIHeroHead150) end end end function UIMultiplayerDungeonMain:RefreshTab() self.minTimeRefresh = 0 self.group_DifficultyScroll:ReloadAll(self.levelData) if self.minTimeRefresh > 0 then self:StartRepeatFunc(self.RefreshTab, self.minTimeRefresh + 1, 1) end end return UIMultiplayerDungeonMain