From ef1b59db6780722e6f5a13ae9abb356e6b3706c7 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Thu, 20 Jul 2023 20:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E7=BA=BF=E5=89=AF=E6=9C=AC=E6=88=98?= =?UTF-8?q?=E6=96=97=E4=B8=AD=E7=9A=84=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dungeon_armor/dungeon_armor_manager.lua | 4 + lua/app/ui/battle/battle_ui.lua | 5 ++ lua/app/ui/dungeon_armor/cell/task_cell.lua | 16 ++++ .../ui/dungeon_armor/cell/task_cell.lua.meta | 10 +++ .../dungeon_armor/dungeon_armor_main_ui.lua | 2 + .../dungeon_armor/dungeon_armor_task_ui.lua | 55 ++++++++++++++ .../dungeon_armor_task_ui.lua.meta | 10 +++ .../userdata/dungeon/dungeon_armor_entity.lua | 73 +++++++++++++++++++ 8 files changed, 175 insertions(+) create mode 100644 lua/app/ui/dungeon_armor/cell/task_cell.lua create mode 100644 lua/app/ui/dungeon_armor/cell/task_cell.lua.meta create mode 100644 lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua create mode 100644 lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua.meta diff --git a/lua/app/module/dungeon_armor/dungeon_armor_manager.lua b/lua/app/module/dungeon_armor/dungeon_armor_manager.lua index c9f99c07..36387ec1 100644 --- a/lua/app/module/dungeon_armor/dungeon_armor_manager.lua +++ b/lua/app/module/dungeon_armor/dungeon_armor_manager.lua @@ -16,6 +16,10 @@ function DungeonArmorManager:showStarRewardUI() UIManager:showUI("app/ui/dungeon_armor/dungeon_armor_star_reward_ui") end +function DungeonArmorManager:showBattleTaskUI() + UIManager:showUI("app/ui/dungeon_armor/dungeon_armor_task_ui") +end + function DungeonArmorManager:reqFight(chapterId) if not DataManager.FormationData:formationIsFull(GConst.BattleConst.FORMATION_TYPE.DUNGEON_ARMOR) then GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8)) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index d1547222..0cd99008 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -455,6 +455,11 @@ function BattleUI:refreshTaskBtn() taskBtn:addClickListener(function() ModuleManager.DailyChallengeManager:showBattleTaskUI() end) + elseif self.battleController.battleType == GConst.BattleConst.BATTLE_TYPE.DUNGEON_ARMOR then + taskBtn:setActive(true) + taskBtn:addClickListener(function() + ModuleManager.DungeonArmorManager:showBattleTaskUI() + end) else taskBtn:setActive(false) end diff --git a/lua/app/ui/dungeon_armor/cell/task_cell.lua b/lua/app/ui/dungeon_armor/cell/task_cell.lua new file mode 100644 index 00000000..ce019987 --- /dev/null +++ b/lua/app/ui/dungeon_armor/cell/task_cell.lua @@ -0,0 +1,16 @@ +local TaskCell = class("TaskCell", BaseCell) + +local ICON_BG = {"dungeon_armor_bg_9", "dungeon_armor_bg_10"} +local ICON = {"dungeon_armor_star_2", "dungeon_armor_star_1"} + +function TaskCell:refresh(desc, over) + local uiMap = self:getUIMap() + local icon = over and ICON_BG[2] or ICON_BG[1] + uiMap["task_cell.task_icon_bg"]:setSprite(GConst.ATLAS_PATH.UI_DUGEON_ARMOR, icon) + icon = over and ICON[2] or ICON[1] + uiMap["task_cell.task_icon"]:setSprite(GConst.ATLAS_PATH.UI_DUGEON_ARMOR, icon) + uiMap["task_cell.desc"]:setText(desc) + uiMap["task_cell.check"]:setVisible(over) +end + +return TaskCell \ No newline at end of file diff --git a/lua/app/ui/dungeon_armor/cell/task_cell.lua.meta b/lua/app/ui/dungeon_armor/cell/task_cell.lua.meta new file mode 100644 index 00000000..e8db3fe4 --- /dev/null +++ b/lua/app/ui/dungeon_armor/cell/task_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5f0e420201dbebf48b3a42345380a006 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua b/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua index 7b070cf5..aa6ca83c 100644 --- a/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua +++ b/lua/app/ui/dungeon_armor/dungeon_armor_main_ui.lua @@ -52,6 +52,8 @@ function DungeonArmorMainUI:_display() uiMap["dungeon_armor_main_ui.banner.btn_formation.tx_ok"]:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_WEAPON_DESC_4)) self.bg1 = uiMap["dungeon_armor_main_ui.scrollrect.viewport.content.bg_1"] self.bg2 = uiMap["dungeon_armor_main_ui.scrollrect.viewport.content.bg_2"] + self.bg1:setAnchoredPositionY(-1) + self.bg2:setAnchoredPositionY(-1) self:refreshScrollrect() self:refreshFormation() diff --git a/lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua b/lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua new file mode 100644 index 00000000..0af14a62 --- /dev/null +++ b/lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua @@ -0,0 +1,55 @@ +local DungeonArmorTaskUI = class("DungeonArmorTaskUI", BaseUI) + +local TASK_CELL = "app/ui/dungeon_armor/cell/task_cell" + +function DungeonArmorTaskUI:isFullScreen() + return false +end + +function DungeonArmorTaskUI:getPrefabPath() + return "assets/prefabs/ui/dungeon_armor/dungeon_armor_task_ui.prefab" +end + +---- 构建数据 +function DungeonArmorTaskUI:ctor() + local battleController = ModuleManager.BattleManager.battleController + if not battleController then + self.taskCurProgress = {} + return + end + self.armorData = DataManager.DungeonData:getDungeonDataByType(ModuleManager.MODULE_KEY.DUNGEON_ARMOR) + self.chapterId = battleController.chapterId + self.taskProgrees = self.armorData:formatTaskByController(battleController, self.chapterId) +end + +function DungeonArmorTaskUI:onLoadRootComplete() + self:_display() + self:_addListeners() +end + +function DungeonArmorTaskUI:_display() + local uiMap = self.root:genAllChildren() + if not self.taskCells then + self.taskCells = {} + for i = 1, 3 do + self.taskCells[i] = CellManager:addCellComp(uiMap["dungeon_armor_task_ui.bg.task_cell_" .. i], TASK_CELL) + end + end + + for index, cell in ipairs(self.taskCells) do + local desc, over = self.armorData:getTaskDescByIndex(self.chapterId, index, nil, self.taskProgrees) + print(desc) + cell:refresh(desc, over) + end + + uiMap["dungeon_armor_task_ui.bg.title_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.TASK_NAME)) +end + +function DungeonArmorTaskUI:_addListeners() + local uiMap = self.root:genAllChildren() + uiMap["dungeon_armor_task_ui.bg.close_btn"]:addClickListener(function() + self:closeUI() + end) +end + +return DungeonArmorTaskUI \ No newline at end of file diff --git a/lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua.meta b/lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua.meta new file mode 100644 index 00000000..7547af0a --- /dev/null +++ b/lua/app/ui/dungeon_armor/dungeon_armor_task_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 435821f2a3c024445a78df73d06107fe +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/dungeon/dungeon_armor_entity.lua b/lua/app/userdata/dungeon/dungeon_armor_entity.lua index f494252c..901e5736 100644 --- a/lua/app/userdata/dungeon/dungeon_armor_entity.lua +++ b/lua/app/userdata/dungeon/dungeon_armor_entity.lua @@ -299,4 +299,77 @@ function DungeonArmorEntity:getMinLowThreeStarId() return self.maxPassedId end +function DungeonArmorEntity:formatTaskByController(battleBaseController, chapterId) + local taskProgress = {} + if not battleBaseController then + return taskProgress + end + local pass = self:getPassedMaxId() >= chapterId and 1 or 0 + local hpp = math.floor(battleBaseController.battleData:getAtkTeam():getHpPercent() * 100 + 0.0001) + local bossRoundCount = 0 + if battleBaseController.waveIndex >= battleBaseController.maxWaveIndex then -- 最后一波 + bossRoundCount = battleBaseController.waveRoundCount[battleBaseController.waveIndex] or 0 + end + local totalRound = 0 + for wave, round in pairs(battleBaseController.waveRoundCount) do + totalRound = totalRound + round + end + + taskProgress = { + [0] = pass, + [1] = hpp, + [2] = bossRoundCount, + [3] = totalRound, + } + + return taskProgress +end + +function DungeonArmorEntity:getTaskDesc(chapterId, taskId, progress) + local config = ConfigManager:getConfig("task_dungeon_armor")[taskId] + if not config then + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_ARMOR_DESC_7), self:getPassedMaxId() >= chapterId + end + + local desc = I18N:getConfig("task_dungeon_armor")[taskId].desc + + progress = progress or 0 + local taskNum = config.param + local over = false + if taskId == 1 then -- 特殊处理 + over = progress >= taskNum + progress = progress .. "%" + taskNum = taskNum .. "%" + elseif taskId == 2 then + over = progress <= taskNum + elseif taskId == 3 then + over = progress <= taskNum + end + local color = "#FF4949" + if over then + color = "#49FF49" + end + local progressStr = string.format("(%s/%s)", color, progress, taskNum) + return desc .. progressStr, over +end + +function DungeonArmorEntity:getTaskDescByIndex(chapterId, index, battleBaseController, taskProgress) + taskProgress = taskProgress or self:formatTaskByController(battleBaseController, chapterId) + + if not self.taskList then + self.taskList = {} + end + if not self.taskList[chapterId] then + self.taskList[chapterId] = GFunc.getTable(self:getConfig(chapterId).star_task) + table.insert(self.taskList[chapterId], 1, 0) -- 首位添加默认任务 + end + + local taskId = self.taskList[chapterId][index] + if not taskId then + return GConst.EMPTY_STRING + end + + return self:getTaskDesc(chapterId, taskId, taskProgress[taskId]) +end + return DungeonArmorEntity \ No newline at end of file