local BattleArenaPauseUI = class("BattleArenaPauseUI", BaseUI) -- 响应安卓后退事件 function BattleArenaPauseUI:onPressBackspace() self:closeUI() end function BattleArenaPauseUI:isFullScreen() return false end function BattleArenaPauseUI:showCommonBG() return false end function BattleArenaPauseUI:getPrefabPath() return "assets/prefabs/ui/battle/battle_arena_pause_ui.prefab" end function BattleArenaPauseUI:ctor(params) self.battleType = params.battleType self.battleController = params.battleController end function BattleArenaPauseUI:onClose() self:unloadRenderTexture() end function BattleArenaPauseUI:onLoadRootComplete() self:_display() self:_addListeners() end function BattleArenaPauseUI:_display() local uiMap = self.root:genAllChildren() self.videoNode = uiMap["battle_arena_pause_ui.skill_node.video_node"] uiMap["battle_arena_pause_ui.skill_node.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_2)) uiMap["battle_arena_pause_ui.skill_node.last_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_9)) uiMap["battle_arena_pause_ui.skill_node.next_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_10)) self:loadRenderTexture() self.curIndex = 1 self:showArenaTips() end function BattleArenaPauseUI:_addListeners() local uiMap = self.root:genAllChildren() uiMap["battle_arena_pause_ui.home_btn"]:addClickListener(function() local params = { content = I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_11), boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL, okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), cancelText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CANCEL), okFunc = function() self.battleController:battleEnd() end, } GFunc.showMessageBox(params) end) uiMap["battle_arena_pause_ui.continue_btn"]:addClickListener(function() self:closeUI() end) uiMap["battle_arena_pause_ui.skill_node.last_btn"]:addClickListener(function() self.curIndex = math.max(1, self.curIndex - 1) self:showArenaTips() end) uiMap["battle_arena_pause_ui.skill_node.next_btn"]:addClickListener(function() self.curIndex = math.min(3, self.curIndex + 1) self:showArenaTips() end) end function BattleArenaPauseUI:showArenaTips() local uiMap = self.root:genAllChildren() for i = 1, 3 do local obj = uiMap["battle_arena_pause_ui.skill_node.video_node.pause_video_0" .. i] obj:setActive(i == self.curIndex) local comp = obj:getComponent(GConst.TYPEOF_UNITY_CLASS.VIDEO_PLAYER) if i == self.curIndex then comp.targetTexture = self.renderTexture comp:Play() else comp.targetTexture = nil comp:Stop() end end local lastBtn = uiMap["battle_arena_pause_ui.skill_node.last_btn"] local nextBtn = uiMap["battle_arena_pause_ui.skill_node.next_btn"] local str if self.curIndex == 1 then str = I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_6) lastBtn:setActive(false) nextBtn:setActive(true) nextBtn:setAnchoredPositionX(0) elseif self.curIndex == 2 then str = I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_7) lastBtn:setActive(true) nextBtn:setActive(true) lastBtn:setAnchoredPositionX(-137.5) nextBtn:setAnchoredPositionX(137.5) else str = I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_8) lastBtn:setActive(true) nextBtn:setActive(false) lastBtn:setAnchoredPositionX(0) end local descObj = uiMap["battle_arena_pause_ui.skill_node.desc"] descObj:setText(str) descObj:setSizeDeltaY(descObj:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredHeight) descObj:setAnchoredPositionY(0) self.videoNode:setVisible(true) end function BattleArenaPauseUI:loadRenderTexture() if not self.renderTexture then local descriptor = CS.UnityEngine.RenderTextureDescriptor(589, 522) descriptor.depthBufferBits = GConst.DEPTH_BUFFER self.renderTexture = CS.UnityEngine.RenderTexture.GetTemporary(descriptor) self.renderTexture.antiAliasing = 4 self.videoNode:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RAW_IMAGE).texture = self.renderTexture end end function BattleArenaPauseUI:unloadRenderTexture() if self.renderTexture then CS.UnityEngine.RenderTexture.ReleaseTemporary(self.renderTexture) self.renderTexture = nil end end return BattleArenaPauseUI