每日挑战战斗界面
This commit is contained in:
parent
da120dc0a0
commit
4b5b0cfae2
@ -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
|
||||
|
||||
@ -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("<color=%s>%s</color>", 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("<color=%s>%s</color>", color, name)
|
||||
|
||||
@ -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))
|
||||
|
||||
8
lua/app/ui/daily_challenge.meta
Normal file
8
lua/app/ui/daily_challenge.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcafa924706b47e48bf4ee4029535523
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
lua/app/ui/daily_challenge/cell.meta
Normal file
8
lua/app/ui/daily_challenge/cell.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eaa9e7673eb16a44adec03f5fb489da
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
lua/app/ui/daily_challenge/cell/task_cell.lua
Normal file
17
lua/app/ui/daily_challenge/cell/task_cell.lua
Normal file
@ -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
|
||||
10
lua/app/ui/daily_challenge/cell/task_cell.lua.meta
Normal file
10
lua/app/ui/daily_challenge/cell/task_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2d8d4941e76c1f438583820580f21c1
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
44
lua/app/ui/daily_challenge/daily_challenge_task_ui.lua
Normal file
44
lua/app/ui/daily_challenge/daily_challenge_task_ui.lua
Normal file
@ -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
|
||||
10
lua/app/ui/daily_challenge/daily_challenge_task_ui.lua.meta
Normal file
10
lua/app/ui/daily_challenge/daily_challenge_task_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93fab2f021a2d56439090e264047b043
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -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
|
||||
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
|
||||
if not taskInfo then
|
||||
return desc
|
||||
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
|
||||
local progressStr = string.format("<color=#5FFF53>(%s%%/%s%%)</color>", progress, taskNum)
|
||||
desc = desc + progressStr
|
||||
|
||||
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("<color=#5FFF53>(%s/%s)</color>", progress, taskNum)
|
||||
desc = desc .. progressStr
|
||||
end
|
||||
return desc
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user