local UIThreeTeamFightChallenge = UIViewClass() local DelayTime = 0.1 local ConstShowParams = { [1] = { posX = 1.8, posY = 0.16, scale = 0.7 }, [2] = { posX = 0.8, posY = 0.16, scale = 0.7 }, [3] = { posX = -0.2, posY = 0.16, scale = 0.7 }, [4] = { posX = -1.2, posY = 0.1, scale = 0.7 }, [5] = { posX = -2.4, posY = 0.02, scale = 0.7 }, } local ConstShowParams_RatioPad4_3 = { [1] = { posX = 1.4, posY = 0.16, scale = 0.7 }, [2] = { posX = 0.6, posY = 0.16, scale = 0.7 }, [3] = { posX = -0.2, posY = 0.16, scale = 0.7 }, [4] = { posX = -1, posY = 0.1, scale = 0.7 }, [5] = { posX = -1.8, posY = 0.02, scale = 0.7 }, } local ConstShowParams_RatioPadOther = { [1] = { posX = 1.6, posY = 0.16, scale = 0.7 }, [2] = { posX = 0.7, posY = 0.16, scale = 0.7 }, [3] = { posX = -0.2, posY = 0.16, scale = 0.7 }, [4] = { posX = -1.2, posY = 0.1, scale = 0.7 }, [5] = { posX = -2.3, posY = 0.02, scale = 0.7 }, } local ConstLightPath = ConstAssetPathConfig.LightLeft function UIThreeTeamFightChallenge:OnOpened(context) UIManager.ActiveUIModle(false, "UIThreeTeamFightChallenge") UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_3TeamsPK_3TeamsPK) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) -- GMS self:RegistSystemEvent(EventID.UI_ThreeTeamFight_RefreshBasic, self.RefreshTimes) self:RegistSystemEvent(EventID.UI_ThreeTeamFight_RefreshChallengeInfo, self.RefreshChallengeInfo) self:RegistSystemEvent(EventID.UI_ThreeTeamFight_UpdateMyRank, self.UpdateMyRank) self:RegistSystemEvent(EventID.UI_ThreeTeamFight_OnSeasonFinish, self.OnSeasonFinish) self:RegistSystemEvent(EventID.EnterFuben_RespError,self.OnTargetPlayerRankChange) self:RefreshTimes() self:UpdateMyRank() self:UpdateAttckFightScore() self:InitScene() self.acidTab = {} self.rankTab = {} self.showInfos = {} MDL.ThreeTeamFight.ThreeTeamsPKChallengeInfoReq(false) end function UIThreeTeamFightChallenge:OnTargetPlayerRankChange() UIManager.CloseView(Const_UI_Lua.UIEnum.UIThreeTeamFightPopUp) self:OnButtonClicked(self.btn_Refresh) end function UIThreeTeamFightChallenge:InitScene() self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.obj_Model) UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, ConstAssetPathConfig.Common2DScenePrefab, 1600, 0, 1600, ConstAssetPathConfig.BGPath_1, false) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0.16, -1.2, 0) -- 设置模型位移信息 UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) -- 设置模型位移信息 end function UIThreeTeamFightChallenge:RefreshChallengeInfo(info) self.refreshEndTime = info.refreshCDEndTime self:UpdateRefreshState() self:UpdateChallenge(info.challenge) end function UIThreeTeamFightChallenge:UpdateChallenge(infoArray) table.clearArray(self.acidTab) table.clearArray(self.rankTab) table.clearArray(self.showInfos) for i, v in ipairs(self.group_Position) do local data = infoArray[i] if data then UIUtils.SetActive(v.gameObject, true) self:SetPlayerInfo(v, data.ShowInfo, data.rank) self.acidTab[i] = data.ShowInfo.acid self.rankTab[i] = data.rank UIUtils.SetActive(v.btn_Challenge, data.ShowInfo.acid ~= BattleDataGetter.GetAcID()) else UIUtils.SetActive(v.gameObject, false) end end for i, v in ipairs(infoArray) do self.showInfos[i] = v.ShowInfo end self:UpdateModel() end function UIThreeTeamFightChallenge:UpdateModel() if self.modelComponentDataHandle then UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) end self.loadModelIndex = 0 self:StartRepeatFunc(self.LoadHeroModel, DelayTime, -1) end function UIThreeTeamFightChallenge:LoadHeroModel() self.loadModelIndex = self.loadModelIndex + 1 local showInfo = self.showInfos[self.loadModelIndex] if showInfo then local resolutionRatio = UIUtils.GetScreenResolutionRatio() if resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPad4_3 then UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, showInfo, ConstShowParams_RatioPad4_3[self.loadModelIndex], ConstLightPath) elseif resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPadOther then UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, showInfo, ConstShowParams_RatioPadOther[self.loadModelIndex], ConstLightPath) else UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, showInfo, ConstShowParams[self.loadModelIndex], ConstLightPath) end else self:StopRepeatFunc(self.LoadHeroModel) end end function UIThreeTeamFightChallenge:SetPlayerInfo(comp, showInfo, rankIndex) comp.lab_Name.text = showInfo.name UIUtils.SetActive(comp.btn_Details, UTL.String.IsRobotByAcid(showInfo.acid)) comp.lab_Server.text = string.format("[S.%s]", showInfo.ShowServerId) comp.lab_Rank.text = CTL.ThreeTeamFight.GetRankDesc(rankIndex, true, true) comp.txt_CE.text = showInfo.gsSum if string.isNilOrEmpty(showInfo.guildName) then comp.state_BG:SetState(1) else comp.state_BG:SetState(0) end CTL.Guild.SetGuildEmblem(comp.img_Guild, comp.txt_Guild, showInfo.EmblemFrame, showInfo.EmblemContent) comp.txt_Name.text = showInfo.guildName end function UIThreeTeamFightChallenge:RefreshTimes() UIUtils.SetLabel(self.txt_Times, CTL.ThreeTeamFight.GetChallengeTimesDesc()) end function UIThreeTeamFightChallenge:UpdateMyRank() CTL.ThreeTeamFight.FormatMyRankDesc(self.txt_Rank) end function UIThreeTeamFightChallenge:UpdateAttckFightScore() local lineUpList = MDL.FreeLineUp.GetLineUpInfoByFunctionType(MDL.FreeLineUp.FuncType.ThreeTeamFight) local totalPower = 0 if lineUpList and #lineUpList > 0 then for i = CTL.ThreeTeamFight.LineNumberType.Attack_1, CTL.ThreeTeamFight.LineNumberType.Attack_3 do for _, v in ipairs(lineUpList) do if v.lineNumber == i then totalPower = totalPower + v.TotalGs break end end end end UIUtils.SetLabel(self.txt_CE, totalPower) end function UIThreeTeamFightChallenge:UpdateRefreshState() self:StopRepeatFunc(self.UpdateRefreshState) local offset = self.refreshEndTime - UTL.Time.GetServerTimestamp() if offset > 0 then self.btn_Refresh:SetGray(true) self.timer_Refresh:ResetAndBeginCustomTimer(false, offset, 0, "({0}s)", 1) self:StartRepeatFunc(self.UpdateRefreshState, offset, 1) else self.btn_Refresh:SetGray(false) self.timer_Refresh:EndTimer() end end function UIThreeTeamFightChallenge:OnClosed() UIManager.ActiveUIModle(true, "UIThreeTeamFightChallenge") if self.modelComponentDataHandle then UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end end function UIThreeTeamFightChallenge:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIThreeTeamFightChallenge: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.UITemplateTitlePanel.btn_Info then CTL.ThreeTeamFight.OpenNote() elseif comp == self.btn_Click then CTL.ThreeTeamFight.TryOpenTimeUp() elseif comp == self.btn_Refresh then if self.refreshEndTime > UTL.Time.GetServerTimestamp() then return end MDL.ThreeTeamFight.ThreeTeamsPKChallengeInfoReq(true) else for i, v in ipairs(self.group_Position) do if v.btn_Challenge == comp then CTL.ThreeTeamFight.TryChallenge(self.acidTab[i], self.rankTab[i]) break end if v.btn_Details == comp then if string.isNilOrEmpty(self.acidTab[i]) == false then CTL.PlayerInteract.OpenFriendInteractView(self.acidTab[i]) end break end end end end function UIThreeTeamFightChallenge:CheckIfFuncUnlock(funcId, isUnlock) if funcId and funcId == MDL.Unlock.FunctionType.ThreeTeamFight then self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end end function UIThreeTeamFightChallenge:OnSeasonFinish() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end return UIThreeTeamFightChallenge