diff --git a/lua/app/module/daily_challenge/daily_challenge_manager.lua b/lua/app/module/daily_challenge/daily_challenge_manager.lua index b133818e..9fc63a9c 100644 --- a/lua/app/module/daily_challenge/daily_challenge_manager.lua +++ b/lua/app/module/daily_challenge/daily_challenge_manager.lua @@ -10,6 +10,10 @@ function DailyChallengeManager:showBattleBuffUI() UIManager:showUI("app/ui/battle/battle_daily_challenge_buff_ui") end +function DailyChallengeManager:showBattleTaskUI() + UIManager:showUI("app/ui/daily_challenge/daily_challenge_task_ui") +end + function DailyChallengeManager:getBuffDesc(id) local desc = I18N:getText("buff_daily_challenge", id, "desc") return desc diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index 2be9b40a..f95e0769 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -33,8 +33,15 @@ end ------------------------------------------ 英雄相关的工具方法 ------------------------------ -function HeroManager:getHeroName(id) - return I18N:getConfig("hero")[id].name +function HeroManager:getHeroName(id, needColor) + local name = I18N:getConfig("hero")[id].name + if name and needColor then + local color = GConst.BattleConst.ELEMENT_COLOR[self:getHeroMatchType(id)] + if color then + name = string.format("%s", color, name) + end + end + return name end function HeroManager:getHeroIcon(heroId) @@ -47,13 +54,18 @@ function HeroManager:getHeroSmallFrame(heroId) return cfg and GConst.HERO_SMALL_FRAME_QLT[cfg.qlt] end +function HeroManager:getHeroMatchType(heroId) + local cfg = ConfigManager:getConfig("hero")[heroId] + return cfg.position +end + function HeroManager:getMatchTypeIcon(matchType) return GConst.HeroConst.MATCH_ICON_NAME[matchType] end function HeroManager:getMatchTypeName(matchType, needColor) local name = I18N:getGlobalText("ELEMENT_NAME_" .. matchType) - if needColor then + if name and needColor then local color = GConst.BattleConst.ELEMENT_COLOR[matchType] if color then name = string.format("%s", color, name) diff --git a/lua/app/ui/battle/battle_pause_ui.lua b/lua/app/ui/battle/battle_pause_ui.lua index a2b3ef91..0a2101df 100644 --- a/lua/app/ui/battle/battle_pause_ui.lua +++ b/lua/app/ui/battle/battle_pause_ui.lua @@ -119,7 +119,7 @@ function BattlePauseUI:refreshDailyChallengeNode() end uiMap["battle_pause_ui.daily_challenge_node.task"]:addClickListener(function() - + ModuleManager.DailyChallengeManager:showBattleTaskUI() end) uiMap["battle_pause_ui.daily_challenge_node.buff_title"]:setText(I18N:getGlobalText(I18N.GlobalConst.BUFF_NAME)) uiMap["battle_pause_ui.daily_challenge_node.task_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.TASK_NAME)) diff --git a/lua/app/ui/daily_challenge.meta b/lua/app/ui/daily_challenge.meta new file mode 100644 index 00000000..b00e5ead --- /dev/null +++ b/lua/app/ui/daily_challenge.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bcafa924706b47e48bf4ee4029535523 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/ui/daily_challenge/cell.meta b/lua/app/ui/daily_challenge/cell.meta new file mode 100644 index 00000000..c59bafa8 --- /dev/null +++ b/lua/app/ui/daily_challenge/cell.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1eaa9e7673eb16a44adec03f5fb489da +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/ui/daily_challenge/cell/task_cell.lua b/lua/app/ui/daily_challenge/cell/task_cell.lua new file mode 100644 index 00000000..c0a6bca0 --- /dev/null +++ b/lua/app/ui/daily_challenge/cell/task_cell.lua @@ -0,0 +1,17 @@ +local TaskCell = class("TaskCell", BaseCell) + +local ICON_BG = {"daily_bg_1", "daily_bg_2"} +local ICON = {"daily_task_1", "daily_task_2"} + +function TaskCell:refresh(taskInfo) + local complete = taskInfo.claimed + local customProgress = 0 -- todo + local uiMap = self:getUIMap() + local icon = complete and ICON_BG[2] or ICON_BG[1] + uiMap["task_cell.task_icon_bg"]:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, icon) + icon = complete and ICON[2] or ICON[1] + uiMap["task_cell.task_icon"]:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, icon) + uiMap["task_cell.desc"]:setText(DataManager.DailyChallengeData:getTaskDesc(taskInfo.task_id, true, customProgress)) +end + +return TaskCell \ No newline at end of file diff --git a/lua/app/ui/daily_challenge/cell/task_cell.lua.meta b/lua/app/ui/daily_challenge/cell/task_cell.lua.meta new file mode 100644 index 00000000..4e4c11ff --- /dev/null +++ b/lua/app/ui/daily_challenge/cell/task_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f2d8d4941e76c1f438583820580f21c1 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/daily_challenge/daily_challenge_task_ui.lua b/lua/app/ui/daily_challenge/daily_challenge_task_ui.lua new file mode 100644 index 00000000..3633dfdc --- /dev/null +++ b/lua/app/ui/daily_challenge/daily_challenge_task_ui.lua @@ -0,0 +1,44 @@ +local DailyChallengeTaskUI = class("DailyChallengeTaskUI", BaseUI) + +local TASK_CELL = "app/ui/daily_challenge/cell/task_cell" + +function DailyChallengeTaskUI:isFullScreen() + return false +end + +function DailyChallengeTaskUI:getPrefabPath() + return "assets/prefabs/ui/daily_challenge/daily_challenge_task_ui.prefab" +end + +function DailyChallengeTaskUI:onLoadRootComplete() + self:_display() + self:_addListeners() +end + +function DailyChallengeTaskUI:_display() + local uiMap = self.root:genAllChildren() + if not self.taskCells then + self.taskCells = {} + for i = 1, 3 do + self.taskCells[i] = CellManager:addCellComp(uiMap["daily_challenge_task_ui.bg.task_cell_" .. i], TASK_CELL) + end + end + + local tasks = DataManager.DailyChallengeData:getTasks() + for i, cell in ipairs(self.taskCells) do + if tasks[i] then + cell:refresh(tasks[i]) + end + end + + uiMap["daily_challenge_task_ui.bg.title_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.TASK_NAME)) +end + +function DailyChallengeTaskUI:_addListeners() + local uiMap = self.root:genAllChildren() + uiMap["daily_challenge_task_ui.bg.close_btn"]:addClickListener(function() + self:closeUI() + end) +end + +return DailyChallengeTaskUI \ No newline at end of file diff --git a/lua/app/ui/daily_challenge/daily_challenge_task_ui.lua.meta b/lua/app/ui/daily_challenge/daily_challenge_task_ui.lua.meta new file mode 100644 index 00000000..243f3b08 --- /dev/null +++ b/lua/app/ui/daily_challenge/daily_challenge_task_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 93fab2f021a2d56439090e264047b043 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/daily_challenge/daily_challenge_data.lua b/lua/app/userdata/daily_challenge/daily_challenge_data.lua index 1cafa0ff..676d2949 100644 --- a/lua/app/userdata/daily_challenge/daily_challenge_data.lua +++ b/lua/app/userdata/daily_challenge/daily_challenge_data.lua @@ -1,5 +1,9 @@ local DailyChallengeData = class("DailyChallengeData", BaseData) local TASK_CFG = ConfigManager:getConfig("task_daily_challenge") +local PER_TASK = {[7] = true, [8] = true} +local FIXED_HERO_TASK = {[2] = true, [7] = true} +local MATCH_TYPE_TASK = {[5] = true, [8] = true} +local NEED_PROGRESS_TASK = {[3] = true, [4] = true, [5] = true, [7] = true, [8] = true} function DailyChallengeData:init(data) data = data or {} @@ -21,7 +25,7 @@ function DailyChallengeData:init(data) claimed = false }, { - task_id = 8, + task_id = 7, param = 12001, progress = 0, claimed = false @@ -154,6 +158,10 @@ function DailyChallengeData:isTaskFinish(index) return self.tasks[index].claim end +function DailyChallengeData:getTasks() + return self.tasks +end + function DailyChallengeData:getTaskById(taskId) for index, taskInfo in ipairs(self.tasks) do if taskInfo.task_id == taskId then @@ -192,7 +200,7 @@ end function DailyChallengeData:getTaskTotalNumber(taskId) if self:getTaskCfgInfo(taskId) then - return self:getTaskCfgInfo(taskId).number + return self:getTaskCfgInfo(taskId).param else return 1 -- 容错,防止报错 end @@ -211,25 +219,35 @@ function DailyChallengeData:getTaskDesc(taskId, needProgress, customProgress) return desc end local taskNum = self:getTaskTotalNumber(taskId) - if taskId == 7 or taskId == 8 then - taskNum = taskNum * 100 // GConst.DEFAULT_FACTOR + if PER_TASK[taskId] then + taskNum = taskNum * 100 // GConst.BattleConst.DEFAULT_FACTOR + end + local taskInfo = self:getTaskById(taskId) + if not taskInfo then + return desc end - desc = I18N:getText("task_daily_challenge", taskId, "desc", taskNum) - if needProgress then - local progress = customProgress - if not progress then - progress = 0 - local taskInfo = self:getTaskById(taskId) - if taskInfo then - progress = taskInfo.progress or 0 - end - end - if taskId == 7 or taskId == 8 then - progress = progress * 100 // GConst.DEFAULT_FACTOR + local conditionStr + if FIXED_HERO_TASK[taskId] then -- 具体英雄 + conditionStr = ModuleManager.HeroManager:getHeroName(taskInfo.param, true) + elseif MATCH_TYPE_TASK[taskId] then -- 颜色英雄 + conditionStr = ModuleManager.HeroManager:getMatchTypeName(taskInfo.param, true) + end + + if conditionStr then + desc = I18N:getText("task_daily_challenge", taskId, "desc", conditionStr, taskNum) + else + desc = I18N:getText("task_daily_challenge", taskId, "desc", taskNum) + end + + if needProgress and NEED_PROGRESS_TASK[taskId] then + local progress = customProgress or taskInfo.progress + if PER_TASK[taskId] then + progress = progress * 100 // GConst.BattleConst.DEFAULT_FACTOR .. "%" + taskNum = taskNum .. "%" end - local progressStr = string.format("(%s%%/%s%%)", progress, taskNum) - desc = desc + progressStr + local progressStr = string.format("(%s/%s)", progress, taskNum) + desc = desc .. progressStr end return desc end