From 8d131457f66464765931d055ac8b2f35bb045965 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Mon, 22 May 2023 10:57:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BE=8E=E6=9C=AF=E8=A1=A8=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/battle/battle_skill_select_comp.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/app/ui/battle/battle_skill_select_comp.lua b/lua/app/ui/battle/battle_skill_select_comp.lua index 6d143a9a..98220432 100644 --- a/lua/app/ui/battle/battle_skill_select_comp.lua +++ b/lua/app/ui/battle/battle_skill_select_comp.lua @@ -20,6 +20,8 @@ end function BattleSkillSelectComp:_display() local uiMap = self:getUIMap() uiMap["battle_select_skill_comp.skill_node.ad_btn.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_3)) + local bg2 = uiMap["battle_select_skill_comp.bg_2"] + bg2:setVisible(self.onlyCommonSkill) local bg = uiMap["battle_select_skill_comp.bg_1"] if ModuleManager.BattleManager.battleController then bg:setVisible(false) From 528ac6a89b17b85d8c60d922ace04d1059cf089c Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Mon, 22 May 2023 15:59:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8A=80=E8=83=BDtips?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../localization_global_const.lua | 2 + lua/app/config/strings/cn/global.lua | 3 + lua/app/global/global_const.lua | 1 + lua/app/module/hero/hero_manager.lua | 4 + lua/app/module/tips/tips_manager.lua | 14 +++ lua/app/ui/battle/battle_ui.lua | 3 + lua/app/ui/battle/cell/skill_node_cell.lua | 6 + lua/app/ui/tips/battle_board_skill_tips.lua | 115 ++++++++++++++++++ .../ui/tips/battle_board_skill_tips.lua.meta | 10 ++ lua/app/userdata/battle/battle_data.lua | 2 - lua/app/userdata/hero/hero_entity.lua | 2 +- 11 files changed, 159 insertions(+), 3 deletions(-) create mode 100644 lua/app/ui/tips/battle_board_skill_tips.lua create mode 100644 lua/app/ui/tips/battle_board_skill_tips.lua.meta diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index e0c6cac9..d9daef9e 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -1,5 +1,7 @@ local LocalizationGlobalConst = { + BATTLE_DESC_9 = "BATTLE_DESC_9", + BATTLE_DESC_10 = "BATTLE_DESC_10", MAIN_BTN_1 = "MAIN_BTN_1", QLT_DESC_1 = "QLT_DESC_1", QLT_DESC_2 = "QLT_DESC_2", diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index 47180099..c6622ebb 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -116,6 +116,9 @@ local localization_global = ["BTN_DELETE_ALL_READ_MAIL"] = "删除已读邮件", ["BTN_CLAIM_ALL"] = "领取所有", ["BTN_READ"] = "读取", + + ["BATTLE_DESC_9"] = "{0}攻击力:{1}", + ["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 43eb0d24..16d3beab 100644 --- a/lua/app/global/global_const.lua +++ b/lua/app/global/global_const.lua @@ -135,6 +135,7 @@ GConst.TYPEOF_UNITY_CLASS = { BF_TUTORIAL_CLICKAREA = typeof(CS.BF.TutorialClickArea), BF_CAMERA_HELPER = typeof(CS.BF.CameraHelper), BF_HORIZONTAL_OR_VERTICAL_LAYOUT = typeof(CS.BF.BFHorizontalOrVerticalLayout), + BF_GRID_LAYOUT = typeof(CS.BF.BFGridLayout), BF_SCROLL_RECT_CENTER = typeof(CS.BF.ScrollRectCenterController), BF_SCROLL_RECT_CENTER_CORE = typeof(CS.BF.ScrollRectCenter), BF_GRAPHIC_FLIP = typeof(CS.BF.BFGraphicFlip), diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index 768f6bb4..9ffcfcad 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -26,6 +26,10 @@ end ------------------------------------------ 英雄相关的工具方法 ------------------------------ +function HeroManager:getHeroName(id) + return I18N:getConfig("hero")[id].name +end + function HeroManager:getHeroIcon(heroId) local cfg = ConfigManager:getConfig("hero")[heroId] return cfg and tostring(cfg.icon) diff --git a/lua/app/module/tips/tips_manager.lua b/lua/app/module/tips/tips_manager.lua index 312fb2de..df326294 100644 --- a/lua/app/module/tips/tips_manager.lua +++ b/lua/app/module/tips/tips_manager.lua @@ -111,6 +111,20 @@ function TipsManager:getRewardDesc(rewardId, rewardType) return GConst.EMPTY_STRING end +function TipsManager:showBattleBoardSkillTips(elementType, tarPrefabObj, alignType) + local params = { + elementType = elementType, + aniType = UIManager.ANI_TYPE.NONE, + } + if tarPrefabObj then + alignType = alignType or TipsManager.ALIGN_TYPE.TOP_CENTER + local tarCornerScreenPos, location = self:getCornerScreenPosition(tarPrefabObj, alignType) + params.tarCornerScreenPos = tarCornerScreenPos + params.location = location + end + UIManager:showUI("app/ui/tips/battle_board_skill_tips", params) +end + function TipsManager:getCornerScreenPosition(tarPrefabObj, alignType) local uiCamera = UIManager:getUICameraComponent() local rectTransform = tarPrefabObj:getComponent(GConst.TYPEOF_UNITY_CLASS.RECTTRANSFORM) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index d0712443..f2580feb 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -134,6 +134,9 @@ function BattleUI:initSkill() self.skillNodeCells[elementType]:refresh(skillEntity) end self.skillNodeCells[elementType]:getBaseObject():setActive(skillEntity ~= nil) + self.skillNodeCells[elementType]:addClickListener(function() + ModuleManager.TipsManager:showBattleBoardSkillTips(elementType) + end) end end diff --git a/lua/app/ui/battle/cell/skill_node_cell.lua b/lua/app/ui/battle/cell/skill_node_cell.lua index 72a484c5..0a6c75eb 100644 --- a/lua/app/ui/battle/cell/skill_node_cell.lua +++ b/lua/app/ui/battle/cell/skill_node_cell.lua @@ -57,4 +57,10 @@ function SkillNodeCell:refresh(skillEntity, elementMap, showSfx) self.lastValue = value end +function SkillNodeCell:addClickListener(func) + local uiMap = self:getUIMap() + local iconNode = uiMap["skill_node_cell.icon_node"] + iconNode:addClickListener(func) +end + return SkillNodeCell \ No newline at end of file diff --git a/lua/app/ui/tips/battle_board_skill_tips.lua b/lua/app/ui/tips/battle_board_skill_tips.lua new file mode 100644 index 00000000..427500df --- /dev/null +++ b/lua/app/ui/tips/battle_board_skill_tips.lua @@ -0,0 +1,115 @@ +local BaseTips = require "app/ui/tips/base_tips" +local BattleBoardSkillTips = class("BattleBoardSkillTips", BaseTips) + +local SELECT_SKILL_CELL = "app/ui/battle/cell/select_skill_cell" +local MIN_HEIGHT = 248 +local MAX_HEIGHT = 348 +local NO_SKILL_HRIGHT = 136 + +function BattleBoardSkillTips:ctor(params) + local elementType = params.elementType + self.params = params + self.boardSkillEntity = DataManager.BattleData:getSkillEntityByElement(elementType) + self.battleUnitEntity = DataManager.BattleData:getAtkTeam():getAllMembers()[elementType] + self.tarCornerScreenPos = params.tarCornerScreenPos + self.location = params.location +end + +function BattleBoardSkillTips:getPrefabPath() + return "assets/prefabs/ui/tips/battle_skill_tips.prefab" +end + +function BattleBoardSkillTips:onLoadRootComplete() + local uiMap = self.root:genAllChildren() + self.bg = uiMap["battle_skill_tips.bg_1"] + self.mask = uiMap["battle_skill_tips.mask"] + self.atkDesc = uiMap["battle_skill_tips.bg_1.atk_desc"] + self.skillDesc = uiMap["battle_skill_tips.bg_1.skill_desc"] + self.validEffectDesc = uiMap["battle_skill_tips.bg_1.valid_effect_desc"] + self.gridLayout = uiMap["battle_skill_tips.bg_1.grid_layout"] + if not self.selectSkillCells then + self.selectSkillCells = {} + for i = 1, 7 do + self.selectSkillCells[i] = CellManager:addCellComp(uiMap["battle_skill_tips.bg_1.grid_layout.skill_select_cell_" .. i], SELECT_SKILL_CELL) + end + end + + local tipsBgTransform = self.bg:getTransform() + self.originSizeDelta = tipsBgTransform.sizeDelta + self.originPivot = tipsBgTransform.pivot + self.originAnchoredPosition = tipsBgTransform.anchoredPosition + self.originLocalPosition = tipsBgTransform.localPosition +end + +function BattleBoardSkillTips:onRefresh() + self.mask:addClickListener(function () + self:closeUI() + end) + + local heroId = self.battleUnitEntity:getId() + local heroEntity = DataManager.HeroData:getHeroById(heroId) + if not heroEntity then + return + end + local heroNmae = ModuleManager.HeroManager:getHeroName(heroId) + local atk = self.battleUnitEntity:getAtk() + self.atkDesc:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_9, heroNmae, atk)) + self.skillDesc:setText(ModuleManager.HeroManager:getSkillDesc(heroEntity:getBaseSkill())) + self.validEffectDesc:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_10)) + + local addY = self.skillDesc:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredHeight - self.skillDesc:fastGetSizeDeltaY() + if addY < 0 then + addY = 0 + end + + local count = 0 + local rougeSkillList = heroEntity:getRogueSkillList() + for index, cell in ipairs(self.selectSkillCells) do + local rogueSkillId = rougeSkillList[index] + cell:getBaseObject():setActive(rogueSkillId ~= nil) + if rogueSkillId then + local selectedCount = DataManager.BattleData:getSkillCount(rogueSkillId) + if selectedCount > 0 then + count = count + 1 + local skillId = rogueSkillId + local count = selectedCount + local value = DataManager.BattleData:getSelectSkillMap()[skillId].value or 0 + cell:refresh(skillId, count) + cell:addClickListener(function() + ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId, value), cell:getBaseObject()) + end) + else + cell:getBaseObject():setActive(false) + end + end + end + + self.gridLayout:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_GRID_LAYOUT):RefreshLayout() + + if count > 5 then + addY = addY + MAX_HEIGHT + elseif count >= 1 then + addY = addY + MIN_HEIGHT + else + addY = addY + NO_SKILL_HRIGHT + self.validEffectDesc:setText(GConst.EMPTY_STRING) + end + + self.bg:setSizeDeltaY(addY) + + if self.tarCornerScreenPos then + self:locate(self.location, self.originSizeDelta, self.bg, self.tarCornerScreenPos) + end +end + +function BattleBoardSkillTips:onClose() + if self.originSizeDelta then + local tipsBgTransform = self.bg:getTransform() + tipsBgTransform.sizeDelta = self.originSizeDelta + tipsBgTransform.pivot = self.originPivot + tipsBgTransform.anchoredPosition = self.originAnchoredPosition + tipsBgTransform.localPosition = self.originLocalPosition + end +end + +return BattleBoardSkillTips \ No newline at end of file diff --git a/lua/app/ui/tips/battle_board_skill_tips.lua.meta b/lua/app/ui/tips/battle_board_skill_tips.lua.meta new file mode 100644 index 00000000..3671db90 --- /dev/null +++ b/lua/app/ui/tips/battle_board_skill_tips.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7c2687668f1925246a6f78bf3b8defd1 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 37f274c0..c5ce9c2c 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -521,11 +521,9 @@ end function BattleData:addCommonSelectSkillCount(count) self.commonSelectSkillCount = self.commonSelectSkillCount + (count or 1) - Logger.logHighlight("self.commonSelectSkillCount " .. self.commonSelectSkillCount) end function BattleData:useCommonSelectSkillCount() - Logger.logHighlight("useCommonSelectSkillCount " .. self.commonSelectSkillCount) if self.commonSelectSkillCount <= 0 then self.commonSelectSkillCount = 0 return false diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index 9ca5cf43..dd477907 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -222,7 +222,7 @@ function HeroEntity:getHurtNum() end function HeroEntity:getName() - return I18N:getConfig("hero")[self:getCfgId()].name + return ModuleManager.HeroManager:getHeroName(self:getCfgId()) end function HeroEntity:getActiveRogueCount()