local ATM_MainMatchView={} local this=ATM_MainMatchView local commonInfo = require("Modules/ArenaTopMatch/View/ATM_CommonInfo") --初始化组件(用于子类重写) function ATM_MainMatchView:InitComponent() this.btnRecord = Util.GetGameObject(self.gameObject, "record") this.btnTeamRank = Util.GetGameObject(self.gameObject, "teamRank") this.btnFightDetail = Util.GetGameObject(self.gameObject, "btnDetail") this.containPanel = Util.GetGameObject(self.gameObject, "contain") this.lockPanel = Util.GetGameObject(self.gameObject, "contain/LockBg") this.lockContext = Util.GetGameObject(this.lockPanel, "context"):GetComponent("Text") this.lockTime = Util.GetGameObject(this.lockPanel, "JoinRoot/time"):GetComponent("Text") this.lockTip = Util.GetGameObject(this.lockPanel, "JoinRoot/tip"):GetComponent("Text") this.outTip = Util.GetGameObject(this.lockPanel, "OutRoot/Text"):GetComponent("Text") this.lockIn = Util.GetGameObject(this.lockPanel, "JoinRoot") this.lockOut = Util.GetGameObject(this.lockPanel, "OutRoot") this.effect = Util.GetGameObject(self.gameObject, "bg/UI_effect_ArenaMainPanel_particle") end --绑定事件(用于子类重写) function ATM_MainMatchView:BindEvent() commonInfo.BindEvent() Util.AddClick(this.btnRecord, function () -- UIManager.OpenPanel(UIName.RecordPopup) ArenaTopMatchManager.RequestBattleHistory(function() UIManager.OpenPanel(UIName.RecordPopup) end) end) Util.AddClick(this.btnTeamRank, function () ArenaTopMatchManager.RequestMyTeamRank(function() UIManager.OpenPanel(UIName.ATMTeamRankPopup) end) end) Util.AddClick(this.btnFightDetail, function () local battleInfo = ArenaTopMatchManager.GetBattleInfo() if battleInfo.result == -1 then Log(Language[10168]) return end local nameStr = battleInfo.myInfo.name.."|"..battleInfo.enemyInfo.name ArenaTopMatchManager.RequestReplayRecord(battleInfo.result, battleInfo.fightData, nameStr, function() local blueInfo = battleInfo.myInfo local redInfo = battleInfo.enemyInfo --构建显示结果数据 local arg = {} arg.result = battleInfo.result arg.blue = {} arg.blue.uid = blueInfo.uid arg.blue.name = blueInfo.name arg.blue.head = blueInfo.head arg.blue.frame = blueInfo.headFrame arg.red = {} arg.red.uid = redInfo.uid arg.red.name = redInfo.name arg.red.head = redInfo.head arg.red.frame = redInfo.headFrame UIManager.OpenPanel(UIName.ArenaResultPopup, arg) end) end) end --添加事件监听(用于子类重写) function ATM_MainMatchView:AddListener() Game.GlobalEvent:AddEvent(GameEvent.TopMatch.OnTopMatchDataUpdate, this.OnOpen, this) end --移除事件监听(用于子类重写) function ATM_MainMatchView:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.TopMatch.OnTopMatchDataUpdate, this.OnOpen, this) end --界面打开时调用(用于子类重写) function ATM_MainMatchView:OnOpen(...) local isActive = ArenaTopMatchManager.IsTopMatchActive() this.StateChange(isActive) end -- 状态切换 function this.StateChange(isOpen) local baseData = ArenaTopMatchManager.GetBaseData() -- 没开启或者开启没参赛都属于未参赛 local isJoin = baseData.joinState == 1 local isOver = baseData.progress == -2 if isOpen then if isJoin then this.SetPlayerInfo() else this.SetNotJionInfo() end else if isOver then this.SetOverInfo() else this.SetLockInfo() end end this.containPanel:SetActive(not isOpen or not isJoin) this.btnRecord:SetActive(isOpen and isJoin) this.btnTeamRank:SetActive(isOpen and isJoin) this.btnFightDetail:SetActive(isOpen and isJoin and baseData.battleState == TOP_MATCH_TIME_STATE.OPEN_IN_END) end function this.SetPlayerInfo() this.lockIn:SetActive(false) this.lockOut:SetActive(false) local battleInfo = ArenaTopMatchManager.GetBattleInfo() local attInfo = battleInfo.myInfo local defInfo = battleInfo.enemyInfo local myResult = -1 local blueInfo = nil local redInfo = nil if attInfo.uid == PlayerManager.uid then blueInfo = attInfo redInfo = defInfo myResult = battleInfo.result elseif defInfo.uid == PlayerManager.uid then blueInfo = defInfo redInfo = attInfo if battleInfo.result ~= -1 then myResult = (battleInfo.result + 1) % 2 end end --if battleInfo.result == 0 then -- 如果进攻方失败,则如果我是进攻方则我失败,反之胜利 -- myResult = attInfo.uid == PlayerManager.uid and 0 or 1 --elseif battleInfo.result == 1 then -- 如果进攻方胜利,则如果我是进攻方则我胜利 -- myResult = attInfo.uid == PlayerManager.uid and 1 or 0 --end local baseData = ArenaTopMatchManager.GetBaseData() commonInfo.SetActive(true) commonInfo.SetInfoData(1, blueInfo, redInfo, myResult, baseData == TOP_MATCH_STAGE.CHOOSE) end function this.SetLockInfo() this.lockIn:SetActive(true) this.lockOut:SetActive(false) commonInfo.SetActive(false) this.lockContext.text = Language[10169] this.lockTip.text = Language[10170] if not this.lockTimer then local startTime = ArenaTopMatchManager.GetTopMatchTime() local during = startTime - PlayerManager.serverTime during = during <= 0 and 0 or during this.lockTime.text = TimeToHMS(during) this.lockTimer = Timer.New(function () local startTime = ArenaTopMatchManager.GetTopMatchTime() local during = startTime - PlayerManager.serverTime during = during <= 0 and 0 or during local timeStr = TimeToHMS(during) this.lockTime.text = timeStr end, 1, -1, true) this.lockTimer:Start() end end function this.SetNotJionInfo() this.lockIn:SetActive(false) this.lockOut:SetActive(true) commonInfo.SetActive(false) this.lockContext.text = Language[10171] this.outTip.text = Language[10172] end function this.SetOverInfo() this.lockIn:SetActive(false) this.lockOut:SetActive(true) commonInfo.SetActive(false) this.lockContext.text = Language[10173] this.outTip.text = Language[10174] end -- 层级改变回调 local orginLayer = 0 function ATM_MainMatchView:OnSortingOrderChange(sort) Util.AddParticleSortLayer(this.effect, sort - orginLayer) orginLayer = sort end --界面关闭时调用(用于子类重写) function ATM_MainMatchView:OnClose() if this.lockTimer then this.lockTimer:Stop() this.lockTimer = nil end commonInfo.SetEffectPopupShow(false) end --界面销毁时调用(用于子类重写) function ATM_MainMatchView:OnDestroy() end return ATM_MainMatchView