local HeroMatch3v3_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local TimerString = string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_StartInMinutes, "{0}:{1}:{2}") local BattleTimerString = UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroMatch1v1_SkipBattleTime) .. "{0}:{1}:{2}" local SelfNameColor = "fff08b" HeroMatch3v3_Controller.RoundTitle = { Const_IDS.IDS_HeroMatch1v1_Round1, Const_IDS.IDS_HeroMatch1v1_Round2, Const_IDS.IDS_HeroMatch1v1_Round3 } function HeroMatch3v3_Controller.OnStartup() private.checkWorshipDistanceTimer = nil -- 膜拜检测计时器 private.statueInfoDic = {} -- 雕像的信息字典 private.statueList = {} -- 雕像的entityID EventSystem.Regist(EventID.New_Day_Refresh, private.OnNewDayChanged) EventSystem.Regist(EventID.UI_HeroMatch3v3_RefreshInfo, private.OnStateChange) EventSystem.Regist(EventID.HeroMatch3v3_WorshipClick, HeroMatch3v3_Controller.TryStartWorshipAction) EventSystem.Regist(EventID.TimerWheelStartTimeOver, private.OnHeroMatch3v3ActivityStart) EventSystem.Regist(EventID.DeepLink_Event,private.OnDeepLink) EventSystem.Regist(EventID.VoiceRoom_OnServerRoomInitStateResp, private.OnServerRoomInitStateResp) end function HeroMatch3v3_Controller.GetStatueConfig(levelID) if levelID == CTL.Level.GetMainCityId() then local isSuccess, statueData = DataSheetManager.TownHomeStatues:TryGetDataByLevelID_GamePlayID(levelID, 3) if isSuccess then return statueData end end return nil end function private.OnDeepLink(key) if key ~= LuaConst.Deeplink.WarbandTournament then return end --强制引导时,不打开界面,清掉deeplink存储 if CTL.PlayerGuide.IsForceGuiding() then return end --没有参数,只要判断判断活动开启 if MDL.HeroMatch3v3.IsShowHeroMatch3v3Entry() then --在城镇里,尝试打开 if BattleDataGetter.IsOnlineTownLevel() then if MDL.HeroMatch3v3.GetCurStageID() > MDL.HeroMatch3v3.Stage.Join then HeroMatch3v3_Controller.OpenHeroMatch3v3MainView() elseif not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIPushInterfaceHeroMatch3v3) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIPushInterfaceHeroMatch3v3) end end end end ---@public 打开天地群雄主界面 function HeroMatch3v3_Controller.OpenHeroMatch3v3MainView() local curMatchTimeID = MDL.HeroMatch3v3.GetCurMatchTimeID() if curMatchTimeID >= MDL.HeroMatch3v3.Enum_BigStage.Screening and curMatchTimeID <= MDL.HeroMatch3v3.Enum_BigStage.Finals then local MatchTime = DataSheetManager.TeamMatchTime:GetDataByID(curMatchTimeID) if UTL.Time.IsServerInOpeningTime(MatchTime.StartTime, MatchTime.EndTime) then MDL.HeroMatch3v3.IsOpenMainPanel = true else MDL.HeroMatch3v3.IsOpenMainPanel = false end end CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.HeroMatch3v3_Login) if MDL.HeroMatch3v3.IsShowHeroMatch3v3Entry() and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroMatch3v3) and MDL.HeroMatch3v3.GetCurStageID() > MDL.HeroMatch3v3.Stage.Join then if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIHeroMatch3v3Base) then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHeroMatch3v3Base) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Formation_RelationShip_Closed) end end -- 活动未开启处于匹配大厅场景回到洛阳5 function HeroMatch3v3_Controller.CheckQuitMatchLobby() local curTitle = MDL.HeroMatch3v3.GetCurMatchTimeID() if (curTitle < MDL.HeroMatch3v3.Enum_BigStage.Screening or curTitle > MDL.HeroMatch3v3.Enum_BigStage.Finals) and BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown3V3) then HeroMatch3v3_Controller.QuitFromMatchLobby(true) end end --活动时间开始 function private.OnHeroMatch3v3ActivityStart(timeId, activityId, timeIndex) if activityId == LuaConst.ActivityType.HeroMatch3v3 then if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.HeroMatch3v3) and MDL.HeroMatch3v3.CheckIsBattleStage() then private.TryOpenRemind() end end end function private.TryOpenRemind() if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown3V3) then return end if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIHeroMatch3v3Base) then return end --筛选赛期间&没有战团玩家&战团人数不足的玩家特殊提示 if HeroMatch3v3_Controller.IsInFiltration() and MDL.SpecialTeam.HasTeam() == false and MDL.SpecialTeam.IsTeamFull() == false then if CTL.Activities.IsInActivitySpecificLevel() then private.OpenRemind(false) else CTL.HomeMain.AddTownHomeDelayFuncNoUI(private.OpenRemind, false) end else if CTL.Activities.IsInActivitySpecificLevel() then private.OpenRemind(true) else CTL.HomeMain.AddTownHomeDelayFuncNoUI(private.OpenRemind, true) end end end function private.OpenRemind(isActivityRemind) if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown3V3) then return end if isActivityRemind then UIManager.OpenView(Const_UI_Lua.UIEnum.UIActivitiesRemind, { LuaConst.ActivityType.HeroMatch3v3 }) else CTL.FunctionNotice.ShowTownMiddleRemind(Const_IDS.IDS_HeroMatch3v3_BeginNoTeamTip, Const_IDS.IDS_HeroMatch3v3_GoOn, HeroMatch3v3_Controller.EnterBattleMatchLobby, Const_IDS.IDS_HeroMatch3v3_GoOnCreate, CTL.SpecialTeam.OpenMain) end end --region ********************************** 赛制阶段通用UI设置 ****************************************** -- 8进4、2进1阶段对战组 function HeroMatch3v3_Controller.SetBattleGroupPlayerInfo(array, lineArray, stageInfo, groupInfos, curRound, isLeft) lineArray:SetState(0) for k, v in ipairs(array) do UIUtils.SetActive(v.group_Player.gameObject, false) UIUtils.SetActive(v.group_Player3v3.gameObject, true) v.cdTimer:EndTimer() v.state_BtnLeft:SetState(2) v.state_BtnRight:SetState(2) v.state_NumLeft:SetState(3) v.state_NumRight:SetState(3) if k <= 2 then v.state_Match:SetState(2) local havePlayerInfo = groupInfos.teamInfos[k].teamId ~= "" private.SetHeroMatch3v3PlayerInfo(v.group_Player3v3, havePlayerInfo and MDL.HeroMatch3v3.GetPlayerInfoByACID(groupInfos.teamInfos[k].acids[1]) or nil, groupInfos.teamInfos[k].teamName, groupInfos.teamInfos[k].teamId) -- 已竞猜 local isGuess = MDL.HeroMatch3v3.CheckIsGuessByGroupID_TeamID(groupInfos.groupId, groupInfos.teamInfos[k].teamId) UIUtils.SetActive(v.group_Player3v3.img_Bet, havePlayerInfo and isGuess or false) local state_Btn = isLeft and v.state_BtnLeft or v.state_BtnRight local lab_WinNum = isLeft and v.txt_WinLeftNum or v.txt_WinRightNum local state_WinNum = isLeft and v.state_NumLeft or v.state_NumRight if curRound > 1 then private.SetWinNum(state_WinNum, lab_WinNum, groupInfos.teamInfos, curRound, k == 1, stageInfo.stageId) end if stageInfo.state == MDL.HeroMatch3v3.Enum_State.Ready then -- 准备中 private.SetBattleReadyState(isGuess, havePlayerInfo, state_Btn, curRound) elseif stageInfo.state == MDL.HeroMatch3v3.Enum_State.Battle then -- 战斗中 if groupInfos.groupState == MDL.HeroMatch3v3.Enum_GroupState.Battle then state_Btn:SetState(0) else private.SetWinNum(state_WinNum, lab_WinNum, groupInfos.teamInfos, curRound, k == 1, stageInfo.stageId) end elseif stageInfo.state == MDL.HeroMatch3v3.Enum_State.Matching then -- 匹配中 private.SetBattleReadyState(isGuess, havePlayerInfo, state_Btn, curRound) end else v.group_Player3v3.state_Info:SetState(2) if stageInfo.state == MDL.HeroMatch3v3.Enum_State.Ready then -- 准备中 private.SetFinishReadyState(v, stageInfo, curRound) elseif stageInfo.state == MDL.HeroMatch3v3.Enum_State.Battle then -- 战斗中 if groupInfos.groupState == MDL.HeroMatch3v3.Enum_GroupState.Battle then v.state_Match:SetState(1) UIUtils.SetLabelText(v.txt_Round, HeroMatch3v3_Controller.RoundTitle[curRound]) else if curRound == 3 then private.SetFinishState(v, lineArray, groupInfos, curRound) else private.SetFinishReadyState(v, stageInfo, curRound, true) end end elseif stageInfo.state == MDL.HeroMatch3v3.Enum_State.Matching then -- 匹配中 private.SetFinishReadyState(v, stageInfo, curRound) else private.SetFinishState(v, lineArray, groupInfos, curRound) end UIUtils.SetActive(v.group_Player3v3.img_Bet, false) end end end function private.SetFinishReadyState(player_Cell, stageInfo, curRound, isBattleTips) player_Cell.state_Match:SetState(0) UIUtils.SetLabelText(player_Cell.txt_Round, HeroMatch3v3_Controller.RoundTitle[curRound]) local timer = stageInfo.stateEndTime - UTL.Time.GetServerTimestamp() if isBattleTips then player_Cell.cdTimer:ResetAndBeginCustomTimer(false, timer, 0, BattleTimerString) else player_Cell.cdTimer:ResetAndBeginCustomTimer(false, timer, 0, TimerString) end end function private.SetWinNum(state_WinNum, lab_WinNum, teamInfos, curRound, isLeft, stageId) state_WinNum:SetState(3) local headInfo_1 = teamInfos[1].teamId ~= "" and teamInfos[1] or nil local headInfo_2 = teamInfos[2].teamId ~= "" and teamInfos[2] or nil if isLeft then if stageId == MDL.HeroMatch3v3.Stage.match_4T2 then state_WinNum:SetState(2) else state_WinNum:SetState(0) end if headInfo_1 then local leftWin = headInfo_1.winNum or 0 if headInfo_2 then local rightWin = headInfo_2.winNum or 0 if leftWin > rightWin and curRound == 3 then UIUtils.SetLabel(lab_WinNum, UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, leftWin)) else UIUtils.SetLabel(lab_WinNum, UTL.Color.FormatWhiteColor(leftWin)) end else UIUtils.SetLabel(lab_WinNum, curRound == 3 and UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, leftWin) or UTL.Color.FormatWhiteColor(leftWin)) end else UIUtils.SetLabel(lab_WinNum, UTL.Color.FormatWhiteColor(0)) end else if stageId == MDL.HeroMatch3v3.Stage.match_4T2 then state_WinNum:SetState(2) else state_WinNum:SetState(1) end if headInfo_2 then local rightWin = headInfo_2.winNum or 0 if headInfo_1 then local leftWin = headInfo_1.winNum or 0 if leftWin < rightWin and curRound == 3 then UIUtils.SetLabel(lab_WinNum, UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, rightWin)) else UIUtils.SetLabel(lab_WinNum, UTL.Color.FormatWhiteColor(rightWin)) end else UIUtils.SetLabel(lab_WinNum, curRound == 3 and UTL.Color.FormatTextByColor(MDL.HeroMatch1v1.WinColor, rightWin) or UTL.Color.FormatWhiteColor(rightWin)) end else UIUtils.SetLabel(lab_WinNum, UTL.Color.FormatWhiteColor(0)) end end end function private.SetBattleReadyState(isGuess, havePlayerInfo, state_Btn, round) if round > 1 or isGuess or not havePlayerInfo then state_Btn:SetState(2) else state_Btn:SetState(1) end end function private.SetFinishState(player_Cell, lineArray, groupInfos, curRound) lineArray:SetState(0) player_Cell.state_Match:SetState(2) player_Cell.group_Player3v3.state_Info:SetState(0) local headInfo_1 = groupInfos.teamInfos[1].teamId ~= "" and groupInfos.teamInfos[1] or nil local headInfo_2 = groupInfos.teamInfos[2].teamId ~= "" and groupInfos.teamInfos[2] or nil if headInfo_1 and headInfo_2 then local leftWin = headInfo_1.winNum or 0 local rightWin = headInfo_2.winNum or 0 local isLeft = leftWin > rightWin local teamId = isLeft and groupInfos.teamInfos[1].teamId or groupInfos.teamInfos[2].teamId local teamName = isLeft and groupInfos.teamInfos[1].teamName or groupInfos.teamInfos[2].teamName local winHeadInfo = isLeft and MDL.HeroMatch3v3.GetPlayerInfoByACID(headInfo_1.acids[1]) or MDL.HeroMatch3v3.GetPlayerInfoByACID(headInfo_2.acids[1]) private.SetHeroMatch3v3PlayerInfo(player_Cell.group_Player3v3, winHeadInfo, teamName, teamId) -- 已竞猜 UIUtils.SetActive(player_Cell.group_Player3v3.img_Bet, MDL.HeroMatch3v3.CheckIsGuessByGroupID_TeamID(groupInfos.groupId, teamId)) lineArray:SetState(leftWin > rightWin and 1 or 2) elseif headInfo_1 and not headInfo_2 then private.SetHeroMatch3v3PlayerInfo(player_Cell.group_Player3v3, MDL.HeroMatch3v3.GetPlayerInfoByACID(headInfo_1.acids[1]), groupInfos.teamInfos[1].teamName, groupInfos.teamInfos[1].teamId) -- 已竞猜 UIUtils.SetActive(player_Cell.group_Player3v3.img_Bet, MDL.HeroMatch3v3.CheckIsGuessByGroupID_TeamID(groupInfos.groupId, groupInfos.teamInfos[1].teamId)) lineArray:SetState(1) elseif headInfo_2 and not headInfo_1 then private.SetHeroMatch3v3PlayerInfo(player_Cell.group_Player3v3, MDL.HeroMatch3v3.GetPlayerInfoByACID(headInfo_2.acids[1]), groupInfos.teamInfos[2].teamName, groupInfos.teamInfos[2].teamId) -- 已竞猜 UIUtils.SetActive(player_Cell.group_Player3v3.img_Bet, MDL.HeroMatch3v3.CheckIsGuessByGroupID_TeamID(groupInfos.groupId, groupInfos.teamInfos[2].teamId)) lineArray:SetState(2) else player_Cell.group_Player3v3.state_Info:SetState(1) end end function private.SetHeroMatch3v3PlayerInfo(player_Cell, headInfo, teamName, teamId) player_Cell.state_Info:SetState(headInfo and 0 or 1) if headInfo then -- 设置名字 local name = UTL.Color.FormatTextByColor(SelfNameColor, teamName) if teamId == MDL.SpecialTeam.GetMyTeamId() then UIUtils.SetActive(player_Cell.img_Self, true) else UIUtils.SetActive(player_Cell.img_Self, false) end UIUtils.SetLabel(player_Cell.txt_Name, name) -- 设置服务器名 UIUtils.SetLabel(player_Cell.txt_Server, CTL.CrossServer.GetFormatServerShow(headInfo.ShowServerId)) end end --endregion ********************************** 赛制阶段通用UI设置 ****************************************** local FILTER_CONST_REWARD_ID = DataSheetManager.ConstData:GetDataByID("HeroMatch3v3JoinReward").IntValue function HeroMatch3v3_Controller.GetRankRewardsDataByMatchTimeID(ID, isFilter) local stageConfig = DataSheetManager.TeamMatchTime:GetDataByID(ID) local rewardConfigs = {} if isFilter then table.insert(rewardConfigs, { RankIndex = 0, RewardID = FILTER_CONST_REWARD_ID }) local stageID = stageConfig.IncludeStage[1] local rc = DataSheetManager.TeamMatchStageRankReward:GetDataByID(stageID) for index = #rc.RankRewardID, 1, -1 do local tb = { ID = stageID, RankIndex = index, RewardID = rc.RankRewardID[index], } table.insert(rewardConfigs, tb) end else for __, stageID in ipairs(stageConfig.IncludeStage) do local rc = DataSheetManager.TeamMatchStageRankReward:GetDataByID(stageID) for _, subID in ipairs(rc.RankRewardID) do local tb = { ID = stageID, RewardID = subID } table.insert(rewardConfigs, tb) end end end return rewardConfigs end ---@return 第一天胜场数 int, 第二天胜场数 int function HeroMatch3v3_Controller.GetFiltrationWinCount() local myMatchInfo = MDL.HeroMatch3v3.GetMyMatchInfo() local curMatchStage = MDL.HeroMatch3v3.GetCurStageID() local myBestStage = MDL.HeroMatch3v3.GetMyHighestStage() if (myBestStage == 0 or curMatchStage >= MDL.HeroMatch3v3.Stage.Join) == 0 or myBestStage <= MDL.HeroMatch3v3.Stage.Filtration_2 then return myMatchInfo.winNum, myMatchInfo.winNum - myMatchInfo.firstDayWinNum end end local FILTRATION_TOTAL_ROUND = DataSheetManager.ConstData:GetDataByID("HeroMatch3v3Race2").IntValue -- 当前比赛阶段描述 ---@return 当前比赛阶段名称描述 string, 当前比赛进程轮次描述 string, 当前轮次次 int function HeroMatch3v3_Controller.GetCurStageDesc() local curStageID = MDL.HeroMatch3v3.GetCurStageID() local curStageInfo = MDL.HeroMatch3v3.GetMatchStageInfo(curStageID) local myMatchInfo = MDL.HeroMatch3v3.GetMyMatchInfo() local config = DataSheetManager.TeamMatchStage:GetDataByID(curStageID) local progressDesc, roundDesc, curFightRound if curStageID == MDL.HeroMatch3v3.Stage.Filtration_1 or curStageID == MDL.HeroMatch3v3.Stage.Filtration_2 then -- 筛选赛 local roundRemain = myMatchInfo.todayNum and FILTRATION_TOTAL_ROUND - myMatchInfo.todayNum or FILTRATION_TOTAL_ROUND local des = DataSheetManager.TeamMatchStage:GetDataByID(curStageID).SceneDes progressDesc = UIUtils.GetLocalizedTxt(Const_IDS[des]) roundDesc = roundRemain .. "/" .. FILTRATION_TOTAL_ROUND elseif curStageID >= MDL.HeroMatch3v3.Stage.match_32T16 then --16强, 32强、64强 roundDesc = UIUtils.GetLocalizedTxt(Const_IDS[config.SceneNextDes]) progressDesc = UIUtils.GetLocalizedTxt(Const_IDS[config.SceneDes]) elseif curStageID >= MDL.HeroMatch3v3.Stage.match_16T8 then --8强 roundDesc = string.FormatByIdsId(Const_IDS[config.SceneNextDes], 1) progressDesc = UIUtils.GetLocalizedTxt(Const_IDS[config.SceneDes]) elseif curStageID >= MDL.HeroMatch3v3.Stage.match_4T2 then -- 4强赛, 2强, 冠军 -- 4进2第几回合 local curTurn = curStageInfo.groupInfos[1].turn roundDesc = curTurn == 3 and string.FormatByIdsId(Const_IDS[config.SceneNextDes], 1) or string.FormatByIdsId(Const_IDS[config.SceneDes], curTurn + 1) progressDesc = string.FormatByIdsId(Const_IDS[config.SceneDes], curTurn) curFightRound = curTurn elseif curStageID == MDL.HeroMatch3v3.Stage.match_2T1 then local curTurn = curStageInfo.groupInfos[1].turn roundDesc = curTurn == 3 and UIUtils.GetLocalizedTxt(Const_IDS[config.SceneNextDes]) or string.FormatByIdsId(Const_IDS[config.SceneDes], curTurn + 1) progressDesc = string.FormatByIdsId(Const_IDS[config.SceneDes], curTurn) curFightRound = curTurn end return progressDesc, roundDesc, curFightRound end function HeroMatch3v3_Controller.GetMyCurRankInfoDesc() local bestStage = MDL.HeroMatch3v3.GetMyHighestStage() local myInfo = MDL.HeroMatch3v3.GetMyMatchInfo() local rankDes if bestStage >= MDL.HeroMatch3v3.Stage.ShowHero then -- 排名赛 - 冠军赛极端ID 递增 if bestStage >= MDL.HeroMatch3v3.Stage.match_64T32 then -- 32 local num = DataSheetManager.TeamMatchStage:GetDataByID(MDL.HeroMatch3v3.Stage.match_64T32).PlayerNum * 2 rankDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_NowResult2"], num) elseif bestStage >= MDL.HeroMatch3v3.Stage.match_32T16 then -- 16 local num = DataSheetManager.TeamMatchStage:GetDataByID(MDL.HeroMatch3v3.Stage.match_32T16).PlayerNum * 2 rankDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_NowResult2"], num) elseif bestStage >= MDL.HeroMatch3v3.Stage.match_16T8 then -- 8 local num = DataSheetManager.TeamMatchStage:GetDataByID(MDL.HeroMatch3v3.Stage.match_16T8).PlayerNum * 2 rankDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_NowResult2"], num) elseif bestStage >= MDL.HeroMatch3v3.Stage.match_8T4 then -- 4 local num = DataSheetManager.TeamMatchStage:GetDataByID(MDL.HeroMatch3v3.Stage.match_8T4).PlayerNum * 2 rankDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_NowResult2"], num) elseif bestStage >= MDL.HeroMatch3v3.Stage.match_4T2 then -- 2 local num = DataSheetManager.TeamMatchStage:GetDataByID(MDL.HeroMatch3v3.Stage.match_4T2).PlayerNum * 2 rankDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_NowResult2"], num) elseif bestStage >= MDL.HeroMatch3v3.Stage.match_2T1 then -- 亚军 rankDes = UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch3v3_NowResult3"]) else -- 冠军 rankDes = UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch3v3_NowResult4"]) end else if bestStage < 0 then rankDes = UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch3v3_NoRaceRank"]) elseif bestStage <= MDL.HeroMatch3v3.Stage.Filtration_1 then -- 筛选赛中ing rankDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_FirstDayWin"], myInfo.winNum) elseif bestStage <= MDL.HeroMatch3v3.Stage.Filtration_2 then -- 筛选赛中ing rankDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_SecondtDayWin"], myInfo.firstDayWinNum, myInfo.winNum - myInfo.firstDayWinNum) end end return rankDes, bestStage end --是否当前在筛选赛期间 function HeroMatch3v3_Controller.IsInFiltration() local curStageID = MDL.HeroMatch3v3.GetCurStageID() return curStageID == MDL.HeroMatch3v3.Stage.Filtration_1 or curStageID == MDL.HeroMatch3v3.Stage.Filtration_2 end function HeroMatch3v3_Controller.IfCanEnterBattleMatchLobby(ignoreBox) local showBox = ignoreBox == nil or ignoreBox == false for k, v in ipairs(MDL.Player.GetHeroLinUpIds()) do if v == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_NationClimbTower_MinSix) return false end end if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown3V3) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch3v3_BeInScene) return false end if showBox then if HeroMatch3v3_Controller.IsInFiltration() then --是否有战团 if MDL.SpecialTeam.HasTeam() == false then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_HeroMatch3v3_TeamMust, CTL.SpecialTeam.OpenMain, HeroMatch3v3_Controller.EnterBattleMatchLobby, Const_IDS.IDS_HeroMatch3v3_GoOnCreate, Const_IDS.IDS_HeroMatch3v3_GoOn) return false end --是否满人 if MDL.SpecialTeam.IsTeamFull() == false then UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_HeroMatch3v3_TeamMust2, CTL.SpecialTeam.OpenMain, HeroMatch3v3_Controller.EnterBattleMatchLobby, Const_IDS.IDS_HeroMatch3v3_GoOnCreate, Const_IDS.IDS_HeroMatch3v3_GoOn) return false end end end return true end --- 进入天地群雄匹配大厅 local MATCH_LOBBY_MAP_ID = 380031 function HeroMatch3v3_Controller.EnterBattleMatchLobby() EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIHeroMatch3v3Base) CTL.MiniMap.GoToMap(MATCH_LOBBY_MAP_ID) end ---匹配大厅退出 function HeroMatch3v3_Controller.QuitFromMatchLobby(isDirectQuit) if isDirectQuit then CTL.Level.ConveyLevelByLevelID(CTL.Level.GetMainCityId()) else UTL.MessageBox.ShowOKCancelBox(nil, UIUtils.GetLocalizedTxt(Const_IDS["IDS_HeroMatch3v3_ConfirmQuit"]), private.TransportQuit) end end function private.TransportQuit() CTL.MiniMap.GoToMap(CTL.Level.GetMainCityId()) end --- 战斗回合信息图标 function HeroMatch3v3_Controller.ShowBattleRoundIcon(curRound) if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIHeroMatch1v1InBattleRound) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIHeroMatch1v1InBattleRound) end local _, _, curFightRound = HeroMatch3v3_Controller.GetCurStageDesc() -- 比赛阶段的第几场 local matchStageRoundDes = curFightRound and string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_Round5"], curFightRound) or nil -- 第几回合 local curRoundDes = string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_Round4"], curRound) UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1InBattleRound, { curRoundDes = curRoundDes, matchRoundDes = matchStageRoundDes }) end function HeroMatch3v3_Controller.GetLeftHpPercentStr(hp, totalVal, IDS) local percentVal = hp / totalVal local percentStr = math.getPreciseDecimal(percentVal * 100, 2) if hp > 0 and percentVal <= 0.01 then -- 无敌情况下血量为1 显示出最要求最小精度 percentStr = 0.01 end return percentVal, IDS and string.FormatByIdsId(Const_IDS[IDS], percentStr) or percentStr .. "%" end --region ********************************** 膜拜 ****************************************** function HeroMatch3v3_Controller.GoWorshipEvent() CTL.Task.OnStopAutoTask() local statuesData = HeroMatch3v3_Controller.GetStatueConfig(CTL.Level.GetMainCityId()) local randomIndex = math.random(#statuesData.WorshipPoint) local itemID = statuesData.WorshipPoint[randomIndex] local levelItem = BattleDataGetter.GetLevelItemByMapID_LevelItemID(statuesData.LevelID, itemID) if levelItem then NotSyncBattleSetter.FindPathByLevelItem(statuesData.LevelID, levelItem, NotSyncBattleSetter.OffHorse, nil, true) end return true end -- 膜拜点点击膜拜按钮 function HeroMatch3v3_Controller.TryStartWorshipAction() if MDL.HeroMatch3v3.GetCurDayWorshipCount() <= 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_HeroMatch3v3_NoSeeTime"]) return end MDL.HeroMatch3v3.GetWorShipRewardReq() end function HeroMatch3v3_Controller.RefreshWorshipRed() if MDL.HeroMatch3v3.GetCurStageID() == MDL.HeroMatch3v3.Stage.ShowHero and MDL.HeroMatch3v3.GetCurDayWorshipCount() > 0 then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.HeroMatch3v3_WorshipReward) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.HeroMatch3v3_WorshipReward) end end --endregion ********************************** 膜拜相关 *************************************** --region 雕像相关 function HeroMatch3v3_Controller.RefreshStatueList(roleList, withWorship) -- roleList 是协议结构 common.RoleSceneBasic local statueData = HeroMatch3v3_Controller.GetStatueConfig(BattleDataGetter.GetLevelID()) if statueData then for i, info in ipairs(roleList) do local itemID = statueData.StatuesPoint[i] local levelItem = BattleDataGetter.GetLevelItemByID(itemID) if levelItem then local itemData = levelItem.ItemData private.statueInfoDic[info.accid] = info local entityID, entity = SyncMoveManager.AddStatueByRoleSceneBasic(info, itemData.ItemPos, itemData.ItemDir, statueData.TitleIDs[i]) if entityID then table.insert(private.statueList, entityID) if withWorship then NotSyncBattleSetter.AddInteract(entity, LuaConst.InteractSpecialID.HeroMatch3V3_Worship) end end end end end end -- 清理雕像 function HeroMatch3v3_Controller.ClearStatues(clearEntity) if clearEntity then for i, entityID in ipairs(private.statueList) do local entity = BattleDataGetter.GetEntityByEntityID(entityID) if entity then NotSyncBattleSetter.DeadQuitEntity(entity) -- 不需要再单独写一句删除膜拜交互功能,entity消失自动删除所有交互功能 end end end table.clear(private.statueInfoDic) table.clearArray(private.statueList) end -- 删除膜拜碰撞盒(膜拜交互功能) function HeroMatch3v3_Controller.ClearStatuesWorshipCollider(clearEntity) if clearEntity then for i, entityID in ipairs(private.statueList) do local entity = BattleDataGetter.GetEntityByEntityID(entityID) if entity then NotSyncBattleSetter.DeleteInteract(entity, LuaConst.InteractSpecialID.HeroMatch3V3_Worship) end end end end function HeroMatch3v3_Controller.GetStatueInfoByAcid(acid) return private.statueInfoDic[acid] end function private.OnStateChange() if MDL.HeroMatch3v3.GetCurStageID() ~= MDL.HeroMatch3v3.Stage.ShowHero then HeroMatch3v3_Controller.ClearStatuesWorshipCollider(true) end end function private.OnNewDayChanged() if MDL.HeroMatch3v3.GetCurStageID() ~= MDL.HeroMatch3v3.Stage.ShowHero then local curLevelID = BattleDataGetter.GetLevelID() local statueData = HeroMatch3v3_Controller.GetStatueConfig(curLevelID) if statueData then CTL.HeroMatch3v3.ClearStatues(true) MDL.HeroMatch3v3.GetStatueReq() end end end function private.OnServerRoomInitStateResp(roomType) if roomType == MDL.VoiceRoom.VoiceRoomType.Room_HeroMatch3V3 then local listenerState, microState = MDL.VoiceRoom.GetVoiceRoomInitState(roomType) local roomId = BattleDataGetter.GetBattleChatChannel() CTL.VoiceRoom.EnterVoiceRoom(roomType, roomId, listenerState, microState) end end --endregion return HeroMatch3v3_Controller