local UISyncSoloBattlePanel = UIViewClass() function UISyncSoloBattlePanel:OnOpened(context) self.context = {} self.context.PlayerUIType = MDL.HomeMain.PlayerUIType.EnemyPlayer self.context.buffType = LuaConst.UIBuffShowType.PlayerOthers for i, v in ipairs(BattleDataGetter.GetRoomPlayerIDList()) do if v ~= BattleDataGetter.GetCurPlayerID() then self.context.playerId = v end end self.subView_EnemyPlayerView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISyncSoloEnemyPlayerView), self.context) self:StartRepeatFunc(self.OnUpdateFun, 1) self:SetPushStyle(LuaConst.PushStyleEnum.HIDE) if BattleDataGetter.IsReplayBattle() then self.state_Replay:SetState(1) local myPlayerID = BattleDataGetter.GetCurPlayerID() local otherPlayerID = myPlayerID == 1 and 2 or 1 self.txt_blueName.text = BattleDataGetter.GetPlayerNameByPlayerID(myPlayerID) -- 1v1默认的玩家id就是1和2 ,回放时我初次进入时是1视角 if BattleDataGetter.IsPracticeRobot(otherPlayerID) then local acid = BattleDataGetter.GetPlayerInfo(otherPlayerID).acid self.txt_redName.text = CTL.Character.GetRobotName(acid) else self.txt_redName.text = BattleDataGetter.GetPlayerNameByPlayerID(otherPlayerID) end else self.state_Replay:SetState(0) end if BattleDataGetter.IsInLevelWatchBattle() or BattleDataGetter.IsReplayBattle() then UIUtils.SetActive(self.btn_Exit, false) UIUtils.SetActive(self.btn_Setting, false) else UIUtils.SetActive(self.btn_Exit, true) UIUtils.SetActive(self.btn_Setting, true) end end function UISyncSoloBattlePanel:OnButtonClicked(comp) if comp == self.btn_Exit then CTL.Setting.BackToTown() elseif comp == self.btn_Setting then UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) end end function UISyncSoloBattlePanel:OnUpdateFun(deltaTime, timeSinceUpdate) local curTimer = BattleDataGetter.GetRemainTime() UIUtils.SetLabel(self.txt_Time, UTL.Time.FormatTimeBySeconds(curTimer)) local floorTimer = math.floor(curTimer) if floorTimer > 0 and floorTimer < 6 then UIUtils.SetActive(self.CountDown, true) self.number.text = floorTimer elseif curTimer <= 0 then UIUtils.SetActive(self.CountDown, false) end end return UISyncSoloBattlePanel