From d1c95c89799fba7a71d140f53781a70f6588bda6 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Fri, 14 Apr 2023 15:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97=E6=9A=82=E5=81=9C=E3=80=81?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E9=80=89=E6=8B=A9=E3=80=81=E6=88=98=E6=96=97?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E3=80=81=E9=80=9A=E7=94=A8=E5=A5=96=E5=8A=B1?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=AD=89=E7=95=8C=E9=9D=A2=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/bi_report.lua | 15 +- lua/app/common/sdk_manager.lua | 2 +- .../localization_global_const.lua | 11 ++ lua/app/config/strings/cn/global.lua | 12 +- lua/app/global/global_func.lua | 14 ++ lua/app/module/battle/battle_manager.lua | 8 + lua/app/module/hero/hero_manager.lua | 89 +++++++----- lua/app/module/tips/tips_manager.lua | 31 ++-- lua/app/ui/battle/battle_pause_ui.lua | 78 ++++++++++ lua/app/ui/battle/battle_pause_ui.lua.meta | 10 ++ lua/app/ui/battle/battle_result_ui.lua | 137 ++++++++++++++++++ lua/app/ui/battle/battle_result_ui.lua.meta | 10 ++ lua/app/ui/battle/battle_skill_select_ui.lua | 34 +++++ lua/app/ui/battle/battle_ui.lua | 11 +- .../battle/cell/battle_select_skill_cell.lua | 6 + lua/app/ui/battle/cell/select_skill_cell.lua | 14 ++ .../ui/battle/cell/select_skill_cell.lua.meta | 10 ++ .../battle/cell/unit_result_report_cell.lua | 14 ++ .../cell/unit_result_report_cell.lua.meta | 10 ++ lua/app/ui/common/cell/reward_cell.lua | 2 +- lua/app/ui/hero/hero_detail_ui.lua | 3 +- lua/app/ui/tips/desc_tips.lua | 55 +++++++ lua/app/ui/tips/desc_tips.lua.meta | 10 ++ lua/app/ui/tips/reward_box.lua | 60 ++++---- lua/app/userdata/battle/battle_data.lua | 4 + 25 files changed, 529 insertions(+), 121 deletions(-) create mode 100644 lua/app/ui/battle/battle_pause_ui.lua create mode 100644 lua/app/ui/battle/battle_pause_ui.lua.meta create mode 100644 lua/app/ui/battle/battle_result_ui.lua create mode 100644 lua/app/ui/battle/battle_result_ui.lua.meta create mode 100644 lua/app/ui/battle/cell/select_skill_cell.lua create mode 100644 lua/app/ui/battle/cell/select_skill_cell.lua.meta create mode 100644 lua/app/ui/battle/cell/unit_result_report_cell.lua create mode 100644 lua/app/ui/battle/cell/unit_result_report_cell.lua.meta create mode 100644 lua/app/ui/tips/desc_tips.lua create mode 100644 lua/app/ui/tips/desc_tips.lua.meta diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index b36f4b59..e16ecad0 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -120,18 +120,7 @@ BIReport.ITEM_GET_TYPE = { } BIReport.ADS_CLICK_TYPE = { - SUMMON = "Summon", - MINING = "Mine", - RESEARCH = "Research", - DUNGEON = "Dungeon", - ARENA = "Arena", - DAILY_TASK = "DailyTask", - QUICK_PASS = "QuickPass", - GIFT = "Gift", - BATTLE_SPEEDUP = "BattleSpeedup", - BLESSING = "Blessing", - IDLE_EXT_REWARDS = "IdleExtRewards", - MAIL = "Mail", + BATTLE_SKILL_REFRESH = "BattleSkillRefresh" } -- BIReport.OPEN_STORE_TYPE = { @@ -734,7 +723,7 @@ function BIReport:postGemGet(bigNum, getType, itemId) coin_type = BIReport.COIN_TYPE[itemId], } if itemId == GConst.ItemConst.ITEM_ID_GEM then - args.coin_value = BigNumOpt.bigNum2Num(bigNum) + -- args.coin_value = BigNumOpt.bigNum2Num(bigNum) args.coin_unit = 0 else args.coin_value = bigNum.value diff --git a/lua/app/common/sdk_manager.lua b/lua/app/common/sdk_manager.lua index f4b8e9de..49987680 100644 --- a/lua/app/common/sdk_manager.lua +++ b/lua/app/common/sdk_manager.lua @@ -332,7 +332,7 @@ function SDKManager:adRewradAd(noReport) Logger.logHighlight("-------------------") ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_WATCH_AD) if not noReport then - DataManager.PlayerData:addAdCount() + -- DataManager.PlayerData:addAdCount() -- BIReport:postAdEvent() end end diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index 934df81e..f6ea9134 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -11,6 +11,17 @@ local LocalizationGlobalConst = BTN_TEXT_CANCEL = "BTN_TEXT_CANCEL", BTN_TEXT_OK = "BTN_TEXT_OK", BATTLE_DESC_1 = "BATTLE_DESC_1", + + GET_REWARDS_DESC = "GET_REWARDS_DESC", + CLICK_CLOSE_DESC = "CLICK_CLOSE_DESC", + ["REWARD_DESC"] = "REWARD_DESC", + ["CONTINUE_DESC"] = "CONTINUE_DESC", + ["BATTLE_DESC_2"] = "BATTLE_DESC_2", + ["BATTLE_DESC_3"] = "BATTLE_DESC_3", + ["BATTLE_DESC_4"] = "BATTLE_DESC_4", + ["BATTLE_DESC_5"] = "BATTLE_DESC_5", + ["BATTLE_DESC_6"] = "BATTLE_DESC_6", + ["BATTLE_DESC_7"] = "BATTLE_DESC_7" } return LocalizationGlobalConst \ No newline at end of file diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index 3b16bbb2..1c55dfb0 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -24,9 +24,19 @@ local localization_global = ["HERO_DESC_3"] = "攻击力", ["HERO_DESC_4"] = "升级", ["HERO_DESC_5"] = "激活", - ["HERO_DESC_6"] = "已解锁", ["HERO_DESC_7"] = "未解锁", + + ["GET_REWARDS_DESC"] = "获得奖励", + ["CLICK_CLOSE_DESC"] = "点击关闭", + ["REWARD_DESC"] = "奖励", + ["CONTINUE_DESC"] = "继续", + ["BATTLE_DESC_2"] = "暂停", + ["BATTLE_DESC_3"] = "刷新", + ["BATTLE_DESC_4"] = "达到", + ["BATTLE_DESC_5"] = "胜利", + ["BATTLE_DESC_6"] = "失败", + ["BATTLE_DESC_7"] = "累计造成总伤害:{0}", } return localization_global \ No newline at end of file diff --git a/lua/app/global/global_func.lua b/lua/app/global/global_func.lua index 4d561162..7353d4ef 100644 --- a/lua/app/global/global_func.lua +++ b/lua/app/global/global_func.lua @@ -727,6 +727,20 @@ function GFunc.showRewardBox(rewards, extParams, callback) ModuleManager.TipsManager:showRewardsBox(params) end +function GFunc.mergeRewards2(rewards, newRewards) + local items = {} + for i,v in ipairs(rewards) do + if v.type == GConst.REWARD_TYPE.ITEM then + items[v.item.cfg_id] = (items[v.item.cfg_id] or 0) + v.item.count + elseif v.type == GConst.REWARD_TYPE.EQUIP then + table.insert(newRewards, v) + end + end + for k,v in pairs(items) do + table.insert(newRewards, {type = GConst.REWARD_TYPE.ITEM, item = {cfg_id = k, count = v}}) + end +end + -- reward 结构为 type id num 配置中结构 function GFunc.mergeRewards(rewards) local items = {} diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index 37af2c1e..1d34a7a0 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -10,10 +10,18 @@ local BATTLE_CONTROLLER = { [BattleConst.BATTLE_TYPE.STAGE] = "app/module/battle/controller/battle_controller_stage" } +function BattleManager:showPauseUI() + UIManager:showUI("app/ui/battle/battle_pause_ui") +end + function BattleManager:showSelectSkillUI(skillList) UIManager:showUI("app/ui/battle/battle_skill_select_ui", {skillList = skillList}) end +function BattleManager:showBattleResultUI(rewards, combatReport) + UIManager:showUI("app/ui/battle/battle_result_ui", {rewards = rewards, combatReport}) +end + function BattleManager:playBattle(battleType, params, returnFunc) if self.battleController then -- 同一时间只能有一场战斗 self:clear() diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index b56c90c4..4117364e 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -4,45 +4,6 @@ function HeroManager:showHeroDetailUI(heroId) UIManager:showUI("app/ui/hero/hero_detail_ui", {heroId = heroId}) end -function HeroManager:getMatchTypeIcon(matchType) - return GConst.HeroConst.MATCH_ICON_NAME[matchType] -end - -function HeroManager:getMatchTypeName(matchType) - return I18N:getGlobalText("ELEMENT_NAME_" .. matchType) -end - -function HeroManager:getSkillDesc(skillId) - return I18N:getConfig("skill")[skillId].desc -end - -function HeroManager:getSkillIcon(skillId) - return ConfigManager:getConfig("skill")[skillId].icon -end - -function HeroManager:getSkillRogueDesc(skillId) - return I18N:getConfig("skill_rogue")[skillId].desc -end - -function HeroManager:getSkillRogueIcon(skillId) - return ConfigManager:getConfig("skill_rogue")[skillId].icon -end - -function HeroManager:getActiveRogueLvs() - if not self.activeRogueLvs then - self.activeRogueLvs = {} - local lvMap = {} - for lv, info in ipairs(ConfigManager:getConfig("hero_level")) do - if not lvMap[info.unlock_skill] then - table.insert(self.activeRogueLvs, lv) - lvMap[info.unlock_skill] = true - end - end - end - - return self.activeRogueLvs -end - function HeroManager:upgradeHero(heroId, heroEntity) local heroEntity = heroEntity or DataManager.HeroData:getHeroById(heroId) if not heroEntity then @@ -72,4 +33,54 @@ function HeroManager:upgradeHero(heroId, heroEntity) end) end + +------------------------------------------ 英雄相关的工具方法 ------------------------------ +function HeroManager:getHeroIcon(heroId) + local cfg = ConfigManager:getConfig("hero")[heroId] + return cfg and tostring(cfg.icon) +end + +function HeroManager:getMatchTypeIcon(matchType) + return GConst.HeroConst.MATCH_ICON_NAME[matchType] +end + +function HeroManager:getMatchTypeName(matchType) + return I18N:getGlobalText("ELEMENT_NAME_" .. matchType) +end + +function HeroManager:getSkillDesc(skillId) + local cfg = I18N:getConfig("skill")[skillId] + return cfg and cfg.desc +end + +function HeroManager:getSkillIcon(skillId) + local cfg = ConfigManager:getConfig("skill")[skillId] + return cfg and cfg.icon +end + +function HeroManager:getSkillRogueDesc(skillId) + local cfg = I18N:getConfig("skill_rogue")[skillId] + return cfg and cfg.desc +end + +function HeroManager:getSkillRogueIcon(skillId) + local cfg = ConfigManager:getConfig("skill_rogue")[skillId] + return cfg and tostring(cfg.icon) +end + +function HeroManager:getActiveRogueLvs() + if not self.activeRogueLvs then + self.activeRogueLvs = {} + local lvMap = {} + for lv, info in ipairs(ConfigManager:getConfig("hero_level")) do + if not lvMap[info.unlock_skill] then + table.insert(self.activeRogueLvs, lv) + lvMap[info.unlock_skill] = true + end + end + end + + return self.activeRogueLvs +end + return HeroManager \ No newline at end of file diff --git a/lua/app/module/tips/tips_manager.lua b/lua/app/module/tips/tips_manager.lua index 8dafc306..30847614 100644 --- a/lua/app/module/tips/tips_manager.lua +++ b/lua/app/module/tips/tips_manager.lua @@ -76,31 +76,18 @@ function TipsManager:showEquipTips(entity, id, params) UIManager:showUI("app/ui/tips/equip_tips", params) end -function TipsManager:showSkillTips(params) - params = params or {} - params.aniType = UIManager.ANI_TYPE.NONE - if params.tarPrefabObj then - local tarCornerScreenPos, location = self:getCornerScreenPosition(params.tarPrefabObj, TipsManager.ALIGN_TYPE.TOP_CENTER) +function TipsManager:showDescTips(desc, tarPrefabObj, alignType) + local params = { + desc = desc, + 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/skill_tips", params) -end - -function TipsManager:showLegacyUpTips(params) - params = params or {} - UIManager:showUI("app/ui/tips/legacy_up_tips", params) -end - -function TipsManager:showLegacyTips(id) - local params = {} - params.id = id - UIManager:showUI("app/ui/tips/legacy_tips", params) -end - -function TipsManager:showGetRuneTips(params) - params = params or {} - UIManager:showUI("app/ui/tips/get_rune_tips", params) + UIManager:showUI("app/ui/tips/desc_tips", params) end function TipsManager:getCornerScreenPosition(tarPrefabObj, alignType) diff --git a/lua/app/ui/battle/battle_pause_ui.lua b/lua/app/ui/battle/battle_pause_ui.lua new file mode 100644 index 00000000..6780acc6 --- /dev/null +++ b/lua/app/ui/battle/battle_pause_ui.lua @@ -0,0 +1,78 @@ +local BattlePauseUI = class("BattlePauseUI", BaseUI) + +local SELECT_SKILL_CELL = "app/ui/battle/cell/select_skill_cell" + +function BattlePauseUI:isFullScreen() + return false +end + +function BattlePauseUI:showCommonBG() + return false +end + +function BattlePauseUI:getPrefabPath() + return "assets/prefabs/ui/battle/battle_pause_ui.prefab" +end + +function BattlePauseUI:ctor(params) + local map = DataManager.BattleData:getSelectSkillMap() + self.skillList = {} + for skillId, count in pairs(map) do + table.insert(self.skillList, {skillId = skillId, count = count}) + end +end + +function BattlePauseUI:onLoadRootComplete() + self:_display() + self:_addListeners() +end + +function BattlePauseUI:_display() + local uiMap = self.root:genAllChildren() + uiMap["battle_pause_ui.skill_node.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_2)) + self:_refreshScrollRect() +end + +function BattlePauseUI:_addListeners() + local uiMap = self.root:genAllChildren() + uiMap["battle_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() + end, + } + GFunc.showMessageBox(params) + end) + + uiMap["battle_pause_ui.continue_btn"]:addClickListener(function() + self:closeUI() + end) +end + +function BattlePauseUI:_refreshScrollRect() + if self.scrollRect then + self.scrollRect:updateAllCell() + return + end + + local uiMap = self.root:genAllChildren() + self.scrollRect = uiMap["battle_pause_ui.skill_node.scrollrect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) + self.scrollRect:addInitCallback(function() + return SELECT_SKILL_CELL + end) + self.scrollRect:addRefreshCallback(function(index, cell) + local skillId = self.skillList[index].skillId + cell:refresh(skillId, self.skillList[index].count) + cell:addClickListener(function() + ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId), cell:getBaseObject()) + end) + end) + self.scrollRect:clearCells() + self.scrollRect:refillCells(#self.skillList) +end + +return BattlePauseUI \ No newline at end of file diff --git a/lua/app/ui/battle/battle_pause_ui.lua.meta b/lua/app/ui/battle/battle_pause_ui.lua.meta new file mode 100644 index 00000000..ec4c206c --- /dev/null +++ b/lua/app/ui/battle/battle_pause_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 089a33bad203bc0429435ef47096169f +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/battle/battle_result_ui.lua b/lua/app/ui/battle/battle_result_ui.lua new file mode 100644 index 00000000..bcd76cbe --- /dev/null +++ b/lua/app/ui/battle/battle_result_ui.lua @@ -0,0 +1,137 @@ +local BattleResultUI = class("BattleResultUI", BaseUI) + +local UNIT_RESULT_RERPORT_CELL = "app/ui/battle/cell/unit_result_report_cell" + +function BattleResultUI:getPrefabPath() + return "assets/prefabs/ui/battle/battle_result_ui.prefab" +end + +function BattleResultUI:ctor(params) + self.rewards = params.rewards + self.combatReport = params.combatReport + ---- 假数据 + -- self.combatReport = { + -- battleType = GConst.BattleConst.BATTLE_TYPE.STAGE, + -- victory = false, + -- wave = 3, + -- atkReport = { + -- { + -- heroId = 12001, + -- dmg = 237800, + -- }, + -- { + -- heroId = 12001, + -- dmg = 23700, + -- } + -- } + -- } + + self.totalDmg = 0 + if self.combatReport.atkReport then + for _, info in ipairs(self.combatReport.atkReport) do + self.totalDmg = self.totalDmg + info.dmg + end + end +end + +function BattleResultUI:onLoadRootComplete() + self:_display() + self:_addListeners() +end + +function BattleResultUI:_display() + local uiMap = self.root:genAllChildren() + + if self.combatReport.victory then + self:refreshVictoryNode() + else + self:refreshDefeatNode() + end + + self:refreshFixedInfo() + self:refreshRewards() + self:refreshUnitInfo() +end + +function BattleResultUI:_addListeners() + local uiMap = self.root:genAllChildren() + uiMap["battle_result_ui.mask_v"]:addClickListener(function() + ModuleManager.BattleManager:endBattleAndExit() + end) + + uiMap["battle_result_ui.mask_d"]:addClickListener(function() + ModuleManager.BattleManager:endBattleAndExit() + end) +end + +function BattleResultUI:refreshFixedInfo() + local uiMap = self.root:genAllChildren() + local icon = uiMap["battle_result_ui.icon"] + local desc1 = uiMap["battle_result_ui.desc_1"] + local desc2 = uiMap["battle_result_ui.desc_2"] + local desc3 = uiMap["battle_result_ui.desc_3"] + local rewardTitle = uiMap["battle_result_ui.reward_title"] + local continue = uiMap["battle_result_ui.continue"] + desc1:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_4)) + desc2:setText(self.combatReport.wave) + desc3:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_7, GFunc.num2Str(self.totalDmg))) + rewardTitle:setText(I18N:getGlobalText(I18N.GlobalConst.REWARD_DESC)) + continue:setText(I18N:getGlobalText(I18N.GlobalConst.CONTINUE_DESC)) + GFunc.centerImgAndTx(icon, desc2, 7) +end + +function BattleResultUI:refreshVictoryNode() + local uiMap = self.root:genAllChildren() + uiMap["battle_result_ui.mask_v"]:setActive(true) + uiMap["battle_result_ui.mask_d"]:setActive(false) + uiMap["battle_result_ui.defeat_node"]:setActive(false) + uiMap["battle_result_ui.victory_node"]:setActive(true) + uiMap["battle_result_ui.victory_node.title_bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_6)) +end + +function BattleResultUI:refreshDefeatNode() + local uiMap = self.root:genAllChildren() + uiMap["battle_result_ui.mask_v"]:setActive(true) + uiMap["battle_result_ui.mask_d"]:setActive(false) + uiMap["battle_result_ui.defeat_node"]:setActive(true) + uiMap["battle_result_ui.victory_node"]:setActive(false) + uiMap["battle_result_ui.defeat_node.title_bg.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_6)) +end + +function BattleResultUI:refreshRewards() + if self.scrollRect then + self.scrollRect:updateAllCell() + return + end + + local uiMap = self.root:genAllChildren() + self.scrollRect = uiMap["battle_result_ui.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) + self.scrollRect:addInitCallback(function() + return GConst.TYPEOF_LUA_CLASS.REWARD_CELL + end) + self.scrollRect:addRefreshCallback(function(index, cell) + cell:refreshByConfig(self.rewards[index]) + end) + self.scrollRect:clearCells() + self.scrollRect:refillCells(#self.rewards) +end + +function BattleResultUI:refreshUnitInfo() + local uiMap = self.root:genAllChildren() + if not self.unitResultReportCells then + self.unitResultReportCells = {} + for index = 1, 5 do + self.unitResultReportCells[index] = CellManager:addCellComp(uiMap["battle_result_ui.unit_result_report_cell_" .. index], UNIT_RESULT_RERPORT_CELL) + end + end + + for index, cell in ipairs(self.unitResultReportCells) do + local info = self.combatReport.atkReport[index] + cell:getBaseObject():setVisible(info ~= nil) + if info then + cell:refresh(info, self.totalDmg) + end + end +end + +return BattleResultUI \ No newline at end of file diff --git a/lua/app/ui/battle/battle_result_ui.lua.meta b/lua/app/ui/battle/battle_result_ui.lua.meta new file mode 100644 index 00000000..7f067c6c --- /dev/null +++ b/lua/app/ui/battle/battle_result_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 37b31518d6e1a28449c6711ebab7a7de +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/battle/battle_skill_select_ui.lua b/lua/app/ui/battle/battle_skill_select_ui.lua index 795b06f0..313ca0ed 100644 --- a/lua/app/ui/battle/battle_skill_select_ui.lua +++ b/lua/app/ui/battle/battle_skill_select_ui.lua @@ -19,6 +19,40 @@ function BattleSkillSelectUI:ctor(params) end function BattleSkillSelectUI:onLoadRootComplete() + self:_display() + self:_addListeners() +end + +function BattleSkillSelectUI:_display() + local uiMap = self.root:genAllChildren() + uiMap["battle_skill_select_ui.skill_node.ad_btn.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_3)) + self:refreshRogueSkill() +end + +function BattleSkillSelectUI:_addListeners() + local uiMap = self.root:genAllChildren() + uiMap["battle_skill_select_ui.skill_node.ad_btn"]:addClickListener(function() + if not ModuleManager.BattleManager.battleController then + return + end + + SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.BATTLE_SKILL_REFRESH, function() + self.skillList = ModuleManager.BattleManager.battleController:getRandomSkillList() + self:refreshRogueSkill() + end) + end) + + self.canvasGroup = uiMap["battle_skill_select_ui.skill_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP) + uiMap["battle_skill_select_ui.look_btn"]:addTouchListener(function(eventType, x, y) + if eventType == GConst.TOUCH_EVENT.DOWN or eventType == GConst.TOUCH_EVENT.DRAG then + self.canvasGroup.alpha = 0.3 + else + self.canvasGroup.alpha = 1 + end + end) +end + +function BattleSkillSelectUI:refreshRogueSkill() local uiMap = self.root:genAllChildren() if not self.selectSkillCells then self.selectSkillCells = {} diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index b46dbe7f..63e47f32 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -41,16 +41,7 @@ end function BattleUI:_addListeners() local uiMap = self.root:genAllChildren() uiMap["battle_ui.close_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() - end, - } - GFunc.showMessageBox(params) + ModuleManager.BattleManager:showPauseUI() end) end diff --git a/lua/app/ui/battle/cell/battle_select_skill_cell.lua b/lua/app/ui/battle/cell/battle_select_skill_cell.lua index bee3bd43..f52667fb 100644 --- a/lua/app/ui/battle/cell/battle_select_skill_cell.lua +++ b/lua/app/ui/battle/cell/battle_select_skill_cell.lua @@ -1,5 +1,7 @@ local BattleSelectSkillCell = class("BattleSelectSkillCell", BaseCell) +local SELECT_SKILL_CELL = "app/ui/battle/cell/select_skill_cell" + function BattleSelectSkillCell:refresh(skillId, func) local cfg = ConfigManager:getConfig("skill_rogue")[skillId] local i18Cfg = I18N:getConfig("skill_rogue")[skillId] @@ -10,6 +12,10 @@ function BattleSelectSkillCell:refresh(skillId, func) local uiMap = self:getUIMap() uiMap["skill_select_cell.desc"]:setText(i18Cfg.desc) self:getBaseObject():addClickListener(func) + if not self.selectSkillCell then + self.selectSkillCell = CellManager:addCellComp(uiMap["skill_select_cell.skill_select_cell"], SELECT_SKILL_CELL) + end + self.selectSkillCell:refresh(skillId) end return BattleSelectSkillCell \ No newline at end of file diff --git a/lua/app/ui/battle/cell/select_skill_cell.lua b/lua/app/ui/battle/cell/select_skill_cell.lua new file mode 100644 index 00000000..bb275938 --- /dev/null +++ b/lua/app/ui/battle/cell/select_skill_cell.lua @@ -0,0 +1,14 @@ +local SelectSkillCell = class("SelectSkillCell", BaseCell) + +function SelectSkillCell:refresh(skillId, count) + local uiMap = self:getUIMap() + uiMap["skill_select_cell.icon"]:setSprite(GConst.ATLAS_PATH.ICON_SKILL_BUFF, ModuleManager.HeroManager:getSkillRogueIcon(skillId)) + -- uiMap["skill_select_cell.value"]:setText() + uiMap["skill_select_cell.count"]:setText(count or GConst.EMPTY_STRING) +end + +function SelectSkillCell:addClickListener(func) + self.baseObject:addClickListener(func) +end + +return SelectSkillCell \ No newline at end of file diff --git a/lua/app/ui/battle/cell/select_skill_cell.lua.meta b/lua/app/ui/battle/cell/select_skill_cell.lua.meta new file mode 100644 index 00000000..ac7a80cc --- /dev/null +++ b/lua/app/ui/battle/cell/select_skill_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5e1b8b33c9b220d468787a59d4da5032 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/battle/cell/unit_result_report_cell.lua b/lua/app/ui/battle/cell/unit_result_report_cell.lua new file mode 100644 index 00000000..5d1e6029 --- /dev/null +++ b/lua/app/ui/battle/cell/unit_result_report_cell.lua @@ -0,0 +1,14 @@ +local UnitResultReportCell = class("UnitResultReportCell", BaseCell) + +function UnitResultReportCell:refresh(info, maxValue) + local uiMap = self:getUIMap() + local icon = ModuleManager.HeroManager:getHeroIcon(info.heroId) + if icon then + uiMap["unit_result_report_cell.icon"]:setSprite(GConst.ATLAS_PATH.ICON_HERO, icon) + end + + uiMap["unit_result_report_cell.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = info.dmg / maxValue + uiMap["unit_result_report_cell.value"]:setText(GFunc.num2Str(info.dmg)) +end + +return UnitResultReportCell \ No newline at end of file diff --git a/lua/app/ui/battle/cell/unit_result_report_cell.lua.meta b/lua/app/ui/battle/cell/unit_result_report_cell.lua.meta new file mode 100644 index 00000000..db325db3 --- /dev/null +++ b/lua/app/ui/battle/cell/unit_result_report_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5e1970606b22de9479625d399f4b8e64 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/common/cell/reward_cell.lua b/lua/app/ui/common/cell/reward_cell.lua index aabd6c9b..dcc5eee8 100644 --- a/lua/app/ui/common/cell/reward_cell.lua +++ b/lua/app/ui/common/cell/reward_cell.lua @@ -14,7 +14,7 @@ function RewardCell:refresh(reward) local id if reward.type == GConst.REWARD_TYPE.ITEM then self:_refreshItem(reward.item) - id = reward.item.id + id = reward.item.cfg_id -- elseif reward.type == GConst.REWARD_TYPE.EQUIP then -- self:_refreshEquip(reward.equip) -- id = reward.equip.id diff --git a/lua/app/ui/hero/hero_detail_ui.lua b/lua/app/ui/hero/hero_detail_ui.lua index 2427eb28..82e932bc 100644 --- a/lua/app/ui/hero/hero_detail_ui.lua +++ b/lua/app/ui/hero/hero_detail_ui.lua @@ -49,8 +49,7 @@ function HeroDetailUI:_display() local skillIcon = uiMap["hero_detail_ui.bg.skill_up_" .. i] local skillLv = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".desc"] skillIcon:addClickListener(function() - -- ModuleManager.TipsManager:show - GFunc.showToast(ModuleManager.HeroManager:getSkillRogueDesc(skillId)) + ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId), skillIcon) end) skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_BUFF, ModuleManager.HeroManager:getSkillRogueIcon(skillId)) diff --git a/lua/app/ui/tips/desc_tips.lua b/lua/app/ui/tips/desc_tips.lua new file mode 100644 index 00000000..f0143d00 --- /dev/null +++ b/lua/app/ui/tips/desc_tips.lua @@ -0,0 +1,55 @@ +local BaseTips = require "app/ui/tips/base_tips" +local DescTips = class("DescTips", BaseTips) + +function DescTips:ctor(params) + self.desc = (params.desc or GConst.EMPTY_STRING) + self.tarCornerScreenPos = params.tarCornerScreenPos + self.location = params.location +end + +function DescTips:getPrefabPath() + return "assets/prefabs/ui/tips/desc_tips.prefab" +end + +function DescTips:init() + local uiMap = self.root:genAllChildren() + self.bg = uiMap["item_tips.bg1.bg"] + self.bg1 = uiMap["item_tips.bg1"] + self.descTx = uiMap["item_tips.bg1.bg.desc_tx"] +end + +function DescTips:onLoadRootComplete() + self:init() + local tipsBgTransform = self.bg:getTransform() + self.originSizeDelta = tipsBgTransform.sizeDelta + self.originPivot = tipsBgTransform.pivot + self.originAnchoredPosition = tipsBgTransform.anchoredPosition + self.originLocalPosition = tipsBgTransform.localPosition +end + +function DescTips:onRefresh() + self.root:addClickListener(function () + self:closeUI() + end) + + self.descTx:setText(self.desc) + -- 这里原来是用preferredHeight,但是在中英文混合的时候这个值可能不准,只有改用renderedHeight + -- renderedHeight必须要先调用下ForceMeshUpdate强制刷新才有效 + self.descTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO):ForceMeshUpdate() + self.bg:setSizeDeltaY(self.descTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).renderedHeight + 18) + if self.tarCornerScreenPos then + self:locate(self.location, self.originSizeDelta, self.bg, self.tarCornerScreenPos) + end +end + +function DescTips: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 DescTips \ No newline at end of file diff --git a/lua/app/ui/tips/desc_tips.lua.meta b/lua/app/ui/tips/desc_tips.lua.meta new file mode 100644 index 00000000..f14b9a4f --- /dev/null +++ b/lua/app/ui/tips/desc_tips.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8f2b0732a3cc14d4db78c59d932e5777 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/tips/reward_box.lua b/lua/app/ui/tips/reward_box.lua index e4314b28..a60cf920 100644 --- a/lua/app/ui/tips/reward_box.lua +++ b/lua/app/ui/tips/reward_box.lua @@ -1,13 +1,13 @@ local BaseTips = require "app/ui/tips/base_tips" local RewardBox = class("RewardBox", BaseTips) -local CELL_WIDTH = 138 +local CELL_WIDTH = 151 local CELL_NUM = 5 local MIN_SIZE_Y = 426 local MAX_SIZE_Y = 966 local MAX_SIZE_X = 690 -local MIN_TITLE_POS_Y = 370 +local MIN_TITLE_POS_Y = 264 local MAX_TITLE_POS_Y = 540 function RewardBox:ctor(params) @@ -15,8 +15,8 @@ function RewardBox:ctor(params) self.params.rewards = params.rewards or {} self.customTitleStr = params.customTitleStr self.callback = params.callback - -- self.flyPos = {} - -- self.showFly = false + self.flyPos = {} + self.showFly = false self.actionStatus = {} if #self.params.rewards > 35 then self.showAction = true @@ -44,46 +44,42 @@ function RewardBox:onLoadRootComplete() self.root:addClickListener(function() self:closeUI() - -- if self.showFly then - -- local pos = clone(self.flyPos) - -- self:showCurrencyAction(pos) - -- end + if self.showFly then + local pos = clone(self.flyPos) + -- self:showCurrencyAction(pos) + end if self.callback then self.callback() end end) - self.titleTx = uiMap["reward_box.title_tx"] - self.titleTx:setText(self.customTitleStr or I18N:getGlobalText(I18N.GlobalConst.GET_REWARDS)) + self.titleTx = uiMap["reward_box.reward_title"] + self.titleTx:setText(self.customTitleStr or I18N:getGlobalText(I18N.GlobalConst.REWARD_DESC)) uiMap["reward_box.continue_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_CLOSE_DESC)) - AudioManager:playEffect(AudioManager.EFFECT_ID.REWARD) + -- AudioManager:playEffect(AudioManager.EFFECT_ID.REWARD) self:_refreshScrollRect() end function RewardBox:_refreshScrollRect(onlyRefresh) - -- for i,v in ipairs(self.params.rewards) do - -- if self.params.rewards[i].type == GConst.REWARD_TYPE.ITEM then - -- if self.params.rewards[i].item.id == GConst.ItemConst.ITEM_ID_GOLD or - -- self.params.rewards[i].item.id == GConst.ItemConst.ITEM_ID_GEM or - -- self.params.rewards[i].item.id == GConst.ItemConst.ITEM_ID_VIT - -- then - -- self.showFly = true - -- local allPos = {} - -- for i = 1, 4 do - -- local posX, posY = GFunc.randomPos(i, {x = 0, y = 0}) - -- allPos[i] = {x = posX, y = posY} - -- end - -- self.flyPos[self.params.rewards[i].item.id] = allPos - -- end - -- end - -- end + for i,v in ipairs(self.params.rewards) do + if self.params.rewards[i].type == GConst.REWARD_TYPE.ITEM then + local id = self.params.rewards[i].item.id or self.params.rewards[i].item.cfg_id + if id == GConst.ItemConst.ITEM_ID_GOLD or + id == GConst.ItemConst.ITEM_ID_GEM or + id == GConst.ItemConst.ITEM_ID_VIT + then + self.showFly = true + local allPos = {} + for i = 1, 4 do + local posX, posY = GFunc.randomPos(i, {x = 0, y = 0}) + allPos[i] = {x = posX, y = posY} + end + self.flyPos[id] = allPos + end + end + end - -- local offset = 0 - -- if #self.params.rewards < 4 then - -- offset = (4 - #self.params.rewards) * CELL_WIDTH / 2 - -- end - -- self.scrollView:setAnchoredPositionX(offset) if #self.params.rewards <= 5 then self.scrollView:setSizeDelta(#self.params.rewards*CELL_WIDTH, MIN_SIZE_Y) self.scrollRect:setPerLineNum(#self.params.rewards) diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 1efffafb..39c7e0fe 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -255,6 +255,10 @@ function BattleData:getSkillCount(skillId) return self.selectSkillMap[skillId] or 0 end +function BattleData:getSelectSkillMap() + return self.selectSkillMap +end + function BattleData:getSkillPool() return self.skillPool end