local ATM_Title={} local this = ATM_Title --初始化组件(用于子类重写) function ATM_Title:InitComponent(root) this.spLoader = SpriteLoader.New() -- 标题数据 this.stagePanel = Util.GetGameObject(root.transform, "ImgName") this.matchName = Util.GetGameObject(this.stagePanel, "name"):GetComponent("Text") this.freshTime = Util.GetGameObject(this.stagePanel, "time"):GetComponent("Text") this.timeType = Util.GetGameObject(this.stagePanel, "timelab"):GetComponent("Text") this.freshTimeGo = Util.GetGameObject(this.stagePanel, "time") this.timeTypeGO = Util.GetGameObject(this.stagePanel, "timelab") this.integralPanel = Util.GetGameObject(root.transform, "ImgIntegral") this.score = Util.GetGameObject(this.integralPanel, "integral"):GetComponent("Text") this.rankPanel = Util.GetGameObject(root.transform, "ImgRank") this.myRank = Util.GetGameObject(this.rankPanel, "rankImg/myRank"):GetComponent("Text") this.imgBig = Util.GetGameObject(root.transform, "ImgBig") this.imgSmall = Util.GetGameObject(root.transform, "ImgSmall") this.btnHelp = Util.GetGameObject(root.transform, "helpBtn") this.helpPosition= this.btnHelp:GetComponent("RectTransform").localPosition end --绑定事件(用于子类重写) function ATM_Title:BindEvent() Util.AddClick(this.btnHelp, function () if ArenaTopMatchManager.GetCurTabIndex() == 2 then UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.ArenaGuess, this.helpPosition.x, this.helpPosition.y) else UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.TopMatch, this.helpPosition.x, this.helpPosition.y + 90) end end) end --添加事件监听(用于子类重写) function ATM_Title:AddListener() Game.GlobalEvent:AddEvent(GameEvent.TopMatch.OnTopMatchDataUpdate, this.RefreshBaseShow) Game.GlobalEvent:AddEvent(GameEvent.TopMatch.CommonInfoRefreshTitle, this.RefreshBaseShow) end --移除事件监听(用于子类重写) function ATM_Title:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.TopMatch.OnTopMatchDataUpdate, this.RefreshBaseShow) Game.GlobalEvent:RemoveEvent(GameEvent.TopMatch.CommonInfoRefreshTitle, this.RefreshBaseShow) end --界面打开时调用(用于子类重写) function ATM_Title:OnOpen(...) -- 默认都不显示 this:SetTitleType(0) end function ATM_Title:OnShow() end function ATM_Title:OnSortingOrderChange() end -- 0 都不显示 1 都显示 2 只显示name function ATM_Title:SetTitleType(type) if type == 0 then this.stagePanel:SetActive(false) this.integralPanel:SetActive(false) this.rankPanel:SetActive(false) this.imgBig:SetActive(false) this.imgSmall:SetActive(false) this.btnHelp:SetActive(false) elseif type == 1 then this.stagePanel:SetActive(true) this.integralPanel:SetActive(true) this.rankPanel:SetActive(true) this.imgBig:SetActive(true) this.imgSmall:SetActive(false) this.btnHelp:SetActive(true) elseif type == 2 then this.stagePanel:SetActive(true) this.integralPanel:SetActive(false) this.rankPanel:SetActive(false) this.imgBig:SetActive(false) this.imgSmall:SetActive(true) this.btnHelp:SetActive(true) end -- 刷新显示 this.RefreshBaseShow() end -- 刷新基础显示 function this.RefreshBaseShow() local isOpen = ArenaTopMatchManager.IsTopMatchActive() local tmData = ArenaTopMatchManager.GetBaseData() local isJoin = tmData.joinState == 1 local titleName, stageName, stateName = ArenaTopMatchManager.GetCurTopMatchName() this.freshTimeGo:SetActive(true) this.timeTypeGO:SetActive(true) if ArenaTopMatchManager.panelType <= 2 then this.freshTimeGo:SetActive(not ArenaTopMatchManager.GetIsBattleEndState(ArenaTopMatchManager.panelType)) this.timeTypeGO:SetActive(not ArenaTopMatchManager.GetIsBattleEndState(ArenaTopMatchManager.panelType)) end if not isOpen then if tmData.progress == -2 then this.matchName.text = " "..titleName this.timeType.text = Language[10165] -- 排名显示 this.myRank.text = ArenaTopMatchManager.GetRankNameByRank(tmData.myrank) -- 判断积分显示 if isJoin then -- 判断是否被淘汰 this.score.text = tmData.myscore * ArenaTopMatchManager.GetMatchDeltaIntegral() else this.score.text = Language[10166] end else this.matchName.text = " "..titleName this.timeType.text = Language[10167] this.myRank.text = Language[10036] this.score.text = Language[10117] end else -- 标题显示 if tmData.progress == -1 then this.matchName.text = " "..titleName this.timeType.text = Language[10167] elseif tmData.progress == -2 then this.matchName.text = " "..titleName this.timeType.text = Language[10165] else this.matchName.text = titleName .. "·" .. stageName this.timeType.text = stateName .. ":" end -- 排名显示 this.myRank.text = ArenaTopMatchManager.GetRankNameByRank(tmData.myrank) -- 判断积分显示 if isJoin then -- 判断是否被淘汰 this.score.text = tmData.myscore * ArenaTopMatchManager.GetMatchDeltaIntegral() else this.score.text = Language[10166] end end -- 计时器 if not this.timer then local function _UpdateTime() local isOpen = ArenaTopMatchManager.IsTopMatchActive() local baseData = ArenaTopMatchManager.GetBaseData() if baseData.progress == -2 then this.freshTime.text = "" return end if isOpen then local leftTime = baseData.endTime - PlayerManager.serverTime leftTime = leftTime < 0 and 0 or leftTime this.freshTime.text = TimeToHMS(leftTime) else local startTime = ArenaTopMatchManager.GetTopMatchTime() local during = startTime - PlayerManager.serverTime during = during <= 0 and 0 or during local timeStr = TimeToHMS(during) this.freshTime.text = timeStr end end _UpdateTime() this.timer = Timer.New(_UpdateTime, 1 , -1, true) this.timer:Start() end end --界面关闭时调用(用于子类重写) function ATM_Title:OnClose() if this.timer then this.timer:Stop() this.timer = nil end end --界面销毁时调用(用于子类重写) function ATM_Title:OnDestroy() this.spLoader:Destroy() end return ATM_Title