From 87cacec30c66f6b754b2eb81b09ea0d767a1ed97 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Tue, 4 Jul 2023 15:03:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E5=9C=BA=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localization_global_const.lua | 5 + lua/app/config/strings/cn/global.lua | 6 + lua/app/global/global_const.lua | 1 + lua/app/module/battle/battle_manager.lua | 6 +- lua/app/ui/battle/battle_arena_pause_ui.lua | 132 ++++++++++++++++++ .../ui/battle/battle_arena_pause_ui.lua.meta | 10 ++ 6 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 lua/app/ui/battle/battle_arena_pause_ui.lua create mode 100644 lua/app/ui/battle/battle_arena_pause_ui.lua.meta diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index de44797f..dc113cd9 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -1,5 +1,10 @@ local LocalizationGlobalConst = { + ["ARENA_BATTLE_DESC_6"] = "ARENA_BATTLE_DESC_6", + ["ARENA_BATTLE_DESC_7"] = "ARENA_BATTLE_DESC_7", + ["ARENA_BATTLE_DESC_8"] = "ARENA_BATTLE_DESC_8", + ["ARENA_BATTLE_DESC_9"] = "ARENA_BATTLE_DESC_9", + ["ARENA_BATTLE_DESC_10"] = "ARENA_BATTLE_DESC_10", SHOP_DESC_40 = "SHOP_DESC_40", MAIN_BTN_1 = "MAIN_BTN_1", QLT_DESC_1 = "QLT_DESC_1", diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index bb363836..5deb850e 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -310,6 +310,12 @@ local localization_global = ["RATE_DESC_1"] = "您喜欢我们的游戏吗?", ["RATE_DESC_2"] = "稍后再说", ["ARENA_DESC_32"] = "购买入场券", + + ["ARENA_BATTLE_DESC_6"] = "竞技场暂停描述1", + ["ARENA_BATTLE_DESC_7"] = "竞技场暂停描述2", + ["ARENA_BATTLE_DESC_8"] = "竞技场暂停描述3", + ["ARENA_BATTLE_DESC_9"] = "上一页", + ["ARENA_BATTLE_DESC_10"] = "下一页", } return localization_global \ No newline at end of file diff --git a/lua/app/global/global_const.lua b/lua/app/global/global_const.lua index d706ccab..206fadad 100644 --- a/lua/app/global/global_const.lua +++ b/lua/app/global/global_const.lua @@ -111,6 +111,7 @@ GConst.TYPEOF_UNITY_CLASS = { TEXT_ASSET = typeof(CS.UnityEngine.TextAsset), LINE_RENDERER = typeof(CS.UnityEngine.LineRenderer), UI_RECT_MASK_2D = typeof(CS.UnityEngine.UI.RectMask2D), + VIDEO_PLAYER = typeof(CS.UnityEngine.Video.VideoPlayer), -- spine组件 SKELETON_GRAPHIC = typeof(CS.Spine.Unity.SkeletonGraphic), SKELETON_ANIMATION = typeof(CS.Spine.Unity.SkeletonAnimation), diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index cb08f457..95fb01ec 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -15,7 +15,11 @@ local BATTLE_CONTROLLER = { } function BattleManager:showPauseUI(battleType) - UIManager:showUI("app/ui/battle/battle_pause_ui", {battleType = battleType}) + if battleType == BattleConst.BATTLE_TYPE.ARENA then + UIManager:showUI("app/ui/battle/battle_arena_pause_ui", {battleType = battleType}) + else + UIManager:showUI("app/ui/battle/battle_pause_ui", {battleType = battleType}) + end end function BattleManager:showBattleResultUI(battleType, rewards, combatReport, mysteryBoxIdx) diff --git a/lua/app/ui/battle/battle_arena_pause_ui.lua b/lua/app/ui/battle/battle_arena_pause_ui.lua new file mode 100644 index 00000000..ed41c7d9 --- /dev/null +++ b/lua/app/ui/battle/battle_arena_pause_ui.lua @@ -0,0 +1,132 @@ +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 +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.BATTLE_DESC_1), + 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() + ModuleManager.BattleManager:endBattleAndExit(true) + 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 + uiMap["battle_arena_pause_ui.skill_node.desc"]:setText(str) + 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 \ No newline at end of file diff --git a/lua/app/ui/battle/battle_arena_pause_ui.lua.meta b/lua/app/ui/battle/battle_arena_pause_ui.lua.meta new file mode 100644 index 00000000..294f1500 --- /dev/null +++ b/lua/app/ui/battle/battle_arena_pause_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 16244a6f9da15d546a1c57c430de857e +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}