每日挑战

This commit is contained in:
kai 2025-07-16 21:57:10 +08:00
parent a6245691d7
commit ed7bb362f0
3 changed files with 70 additions and 60 deletions

View File

@ -1,68 +1,68 @@
local BattleDailyChallengeBuffUI = class("BattleDailyChallengeBuffUI", BaseUI)
function BattleDailyChallengeBuffUI:isFullScreen()
return false
return false
end
function BattleDailyChallengeBuffUI:getPrefabPath()
return "assets/prefabs/ui/battle/battle_daily_challenge_buff_ui.prefab"
return "assets/prefabs/ui/battle/battle_daily_challenge_buff_ui.prefab"
end
function BattleDailyChallengeBuffUI:ctor()
self.buffDescs = {}
for _, id in ipairs(DataManager.DailyChallengeData:getTodayBuffIds()) do
local cfg = ConfigManager:getConfig("buff_daily_challenge")[id]
if cfg then
self.buffDescs[cfg.buff_type] = ModuleManager.DailyChallengeManager:getBuffDesc(id)
end
end
self.buffDescs = {}
for _, id in ipairs(DataManager.DailyChallengeData:getTodayBuffIds()) do
local cfg = ConfigManager:getConfig("buff_daily_challenge")[id]
if cfg then
self.buffDescs[cfg.buff_type] = ModuleManager.DailyChallengeManager:getBuffDesc(id)
end
end
end
function BattleDailyChallengeBuffUI:onClose()
if self.txSeq then
self.txSeq:Kill()
self.txSeq = nil
end
if self.txSeq then
self.txSeq:Kill()
self.txSeq = nil
end
end
function BattleDailyChallengeBuffUI:onLoadRootComplete()
self:_display()
self:_addListeners()
self:_display()
self:_addListeners()
end
function BattleDailyChallengeBuffUI:_display()
local uiMap = self.root:genAllChildren()
local buffDescs = {
uiMap["battle_daily_challenge_buff_ui.raw_img.desc_1"],
uiMap["battle_daily_challenge_buff_ui.raw_img.desc_2"]
}
for index, obj in ipairs(buffDescs) do
obj:setText(self.buffDescs[index])
end
local txNode = uiMap["battle_daily_challenge_buff_ui.raw_img"]:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
txNode.alpha = 0
local spineObj = uiMap["battle_daily_challenge_buff_ui.ui_spine_obj"]
spineObj:setVisible(false)
local uiMap = self.root:genAllChildren()
local buffDescs = {
uiMap["battle_daily_challenge_buff_ui.raw_img.desc_1"],
uiMap["battle_daily_challenge_buff_ui.raw_img.desc_2"]
}
for index, obj in ipairs(buffDescs) do
obj:setText(self.buffDescs[index])
end
local txNode = uiMap["battle_daily_challenge_buff_ui.raw_img"]:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS_GROUP)
txNode.alpha = 0
local spineObj = uiMap["battle_daily_challenge_buff_ui.ui_spine_obj"]
spineObj:setVisible(false)
if self.txSeq then
self.txSeq:Kill()
self.txSeq = nil
end
self.txSeq = self.root:createBindTweenSequence()
self.txSeq:AppendInterval(0.2)
self.txSeq:AppendCallback(function()
spineObj:setVisible(true)
spineObj:playAnim("idle", false, true)
end)
self.txSeq:AppendInterval(0.2)
self.txSeq:Append(txNode:DOFade(1, 0.2))
if self.txSeq then
self.txSeq:Kill()
self.txSeq = nil
end
self.txSeq = self.root:createBindTweenSequence()
self.txSeq:AppendInterval(0.2)
self.txSeq:AppendCallback(function()
spineObj:setVisible(true)
spineObj:playAnim("idle", false, true)
end)
self.txSeq:AppendInterval(0.2)
self.txSeq:Append(txNode:DOFade(1, 0.2))
end
function BattleDailyChallengeBuffUI:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["battle_daily_challenge_buff_ui.mask"]:addClickListener(function()
self:closeUI()
end)
local uiMap = self.root:genAllChildren()
uiMap["battle_daily_challenge_buff_ui.mask"]:addClickListener(function()
self:closeUI()
end)
end
return BattleDailyChallengeBuffUI

View File

@ -4,14 +4,24 @@ local ICON_BG = {"common_board_131", "common_board_132"}
local ICON = {"daily_task_1", "daily_task_2"}
function TaskCell:refresh(taskInfo, customProgress)
local complete = taskInfo.claimed
customProgress = customProgress or 0
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.COMMON, 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))
local complete = taskInfo.claimed
customProgress = customProgress or 0
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.COMMON, 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))
for i = 1, 3 do
local cell = uiMap["daily_challenge_task_ui.bg.task_cell_" .. i]
if taskInfo.reward[i] then
cell:setVisible(true)
cell:refresh(taskInfo.reward[i])
else
cell:setVisible(false)
end
end
end
return TaskCell

View File

@ -30,18 +30,18 @@ function DailyChallengeUI:onLoadRootComplete()
uiMap["daily_challenge_ui.close_btn"]:addClickListener(function ()
self:closeUI()
end)
uiMap["daily_challenge_ui.challenge.info.title.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE))
uiMap["daily_challenge_ui.challenge.info.record_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.DailyChallengeData:getMaxWave()))
uiMap["daily_challenge_ui.title.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE))
uiMap["daily_challenge_ui.record_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.DailyChallengeData:getMaxWave()))
self.tasks = GFunc.getTable()
table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task1"])
table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task2"])
table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task3"])
table.insert(self.tasks, uiMap["daily_challenge_ui.task.icon_task1"])
table.insert(self.tasks, uiMap["daily_challenge_ui.task.icon_task2"])
table.insert(self.tasks, uiMap["daily_challenge_ui.task.icon_task3"])
self.buffObj = uiMap["daily_challenge_ui.challenge.buffs.buff.btn_buff"]
self.debuffObj = uiMap["daily_challenge_ui.challenge.buffs.debuff.btn_debuff"]
self.bossSpine = uiMap["daily_challenge_ui.challenge.spine_node"]
self.countdownTx = uiMap["daily_challenge_ui.challenge.info.countdown.time_tx"]
self.buffObj = uiMap["daily_challenge_ui.buffs.buff.btn_buff"]
self.debuffObj = uiMap["daily_challenge_ui.buffs.debuff.btn_debuff"]
self.bossSpine = uiMap["daily_challenge_ui.spine_node"]
self.countdownTx = uiMap["daily_challenge_ui.countdown.time_tx"]
self.fightBtn = uiMap["daily_challenge_ui.fight_btn"]
-- 体力消耗