This commit is contained in:
xiekaidong 2023-05-12 10:55:48 +08:00
commit 16ab6b1296
6 changed files with 91 additions and 15 deletions

View File

@ -70,6 +70,7 @@ BIReport.ADS_CLICK_TYPE = {
BATTLE_SKILL_REFRESH = "BattleSkillRefresh",
AD_ENERGY = "AdEnergy",
TASK_DAILY_REFRESH = "TaskDailyRefresh",
TASK_DAILY_TASK = "TaskDailyTask"
}
BIReport.FIGHT_OPT_TYPE = {

View File

@ -20,7 +20,8 @@ TaskConst.TASK_TYPE = {
X_COMBO_TEN = 17,
X_USE_SKILL = 18,
X_BATTLE_PASS_WAVE = 19,
COMPLETED_DALY_TASK = 20
COMPLETED_DALY_TASK = 20,
DAILY_TASK_WATCH_AD_SPECIAL = 21
}
return TaskConst

View File

@ -63,6 +63,18 @@ function TaskManager:onResetDailyTask(result)
end
end
function TaskManager:watchTaskSpecialAd()
SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.TASK_DAILY_TASK, function()
self:sendMessage(ProtoMsgType.FromMsgEnum.TaskDailyAdReq, {}, {}, self.onWatchTaskSpecialAd, BIReport.ITEM_GET_TYPE.NONE)
end)
end
function TaskManager:onWatchTaskSpecialAd(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.DAILY_TASK_WATCH_AD_SPECIAL)
end
end
function TaskManager:registerTask(moduleName, taskType, callback)
if not self.registerTaskInfo then
self.registerTaskInfo = {}
@ -117,6 +129,9 @@ function TaskManager:addTaskProgress(type, ...)
end
function TaskManager:dispatchTask(type, count)
if DataManager.DailyTaskData:getIfCanReset() then -- 跨天了
ModuleManager.TaskManager:resetDailyTask()
end
if not self.registerTaskInfo then
return
end
@ -177,6 +192,10 @@ function TaskManager:xHeroFragmentGot(count)
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_HERO_FRAGMENT_GOT, count)
end
function TaskManager:dailyTaskWatchAdSpecial()
self:dispatchTask(GConst.TaskConst.TASK_TYPE.DAILY_TASK_WATCH_AD_SPECIAL, 1)
end
---- 没有特殊说明,方法均返回任务增量
TaskManager.TYPE_DEAL_FUNC = {
[GConst.TaskConst.TASK_TYPE.X_WATCH_AD] = TaskManager.xWatchAd,
@ -188,6 +207,7 @@ TaskManager.TYPE_DEAL_FUNC = {
[GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP] = TaskManager.xHeroLvUp,
[GConst.TaskConst.TASK_TYPE.X_HERO_FRAGMENT_GOT] = TaskManager.xHeroFragmentGot,
[GConst.TaskConst.TASK_TYPE.COMPLETED_DALY_TASK] = TaskManager.completeDailyTask,
[GConst.TaskConst.TASK_TYPE.DAILY_TASK_WATCH_AD_SPECIAL] = TaskManager.dailyTaskWatchAdSpecial,
-- [GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER] = TaskManager.xKillMonster,
}

View File

@ -23,6 +23,13 @@ function DailyTaskCell:init()
ModuleManager.TaskManager:refreshDailyTask(self.taskId)
end
end)
self.adBtnRoot = uiMap["task_cell.ad_btn"]
local adBtn = uiMap["task_cell.ad_btn.btn"]
adBtn:addClickListener(function()
if self.taskId then
ModuleManager.TaskManager:watchTaskSpecialAd()
end
end)
self.refreshBtnTx = uiMap["task_cell.refresh_btn.btn.text"]
self.refreshBtnTx:setText("临时文本:刷新")
self.rewardCellComp = uiMap["task_cell.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
@ -53,6 +60,7 @@ function DailyTaskCell:refresh(task)
self.progressBg:setVisible(false)
self.refreshBtnRoot:setVisible(false)
self.getBtnRoot:setVisible(false)
self.adBtnRoot:setVisible(false)
self.completeNode:setVisible(false)
else
if task.lock == nil then
@ -68,6 +76,7 @@ function DailyTaskCell:refresh(task)
self.completeNode:setVisible(true)
self.getBtnRoot:setVisible(false)
self.refreshBtnRoot:setVisible(false)
self.adBtnRoot:setVisible(false)
if count >= needCount then
count = needCount
end
@ -77,8 +86,15 @@ function DailyTaskCell:refresh(task)
count = needCount
self.getBtnRoot:setVisible(true)
self.refreshBtnRoot:setVisible(false)
self.adBtnRoot:setVisible(false)
else
self.getBtnRoot:setVisible(false)
local isAdType = DataManager.DailyTaskData:getDailyTaskIsAdType(task.id)
if isAdType then
self.adBtnRoot:setVisible(true)
self.refreshBtnRoot:setVisible(false)
else
self.adBtnRoot:setVisible(false)
local canRefresh = DataManager.DailyTaskData:getDailyTaskCanRefresh(task.id)
if canRefresh then
if task.refresh then -- 刷过了
@ -91,6 +107,7 @@ function DailyTaskCell:refresh(task)
end
end
end
end
self.progressTx:setText(count .. "/" .. needCount)
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = count/needCount
end

View File

@ -86,7 +86,7 @@ function TaskMainUI:onLoadRootComplete()
self:bindData()
self:scheduleGlobal(function()
self:updateTime()
end)
end, 1)
end
function TaskMainUI:initTitle()
@ -132,7 +132,10 @@ function TaskMainUI:initDailyTaskAdCell()
self.dailyTaskAdCellProgressTx = self.uiMap["task_main_ui.bg.daily.task_ad_cell.progress_tx"]
self.dailyTaskAdCellBox = self.uiMap["task_main_ui.bg.daily.task_ad_cell.box"]
self.dailyTaskAdCellBox:addClickListener(function()
local taskId = DataManager.DailyTaskData:getDailyTaskAdId()
if DataManager.DailyTaskData:getDailyTaskCanClaimTask(taskId) then
ModuleManager.TaskManager:claimDailyTask(taskId)
end
end)
self.dailyTaskAdCellBoxInfo = self.uiMap["task_main_ui.bg.daily.task_ad_cell.box.info"]
end
@ -143,7 +146,10 @@ function TaskMainUI:initDailyTaskFinalCell()
self.dailyTaskFinalCellProgressTx = self.uiMap["task_main_ui.bg.daily.task_final_cell.progress_tx"]
self.dailyTaskFinalCellBox = self.uiMap["task_main_ui.bg.daily.task_final_cell.box"]
self.dailyTaskFinalCellBox:addClickListener(function()
local taskId = DataManager.DailyTaskData:getDailyTaskFinalId()
if DataManager.DailyTaskData:getDailyTaskCanClaimTask(taskId) then
ModuleManager.TaskManager:claimDailyTask(taskId)
end
end)
self.dailyTaskFinalCellBoxInfo = self.uiMap["task_main_ui.bg.daily.task_final_cell.box.info"]
end
@ -244,9 +250,16 @@ function TaskMainUI:refreshDailyTaskAdCell()
local taskDesc = DataManager.DailyTaskData:getDailyTaskDesc(taskId)
self.dailyTaskAdCellNameTx:setText(taskDesc)
local count, needCount = DataManager.DailyTaskData:getDailyTaskProgress(taskId)
if count > needCount then
if count >= needCount then
count = needCount
end
if DataManager.DailyTaskData:getDailyTaskCanClaimTask(taskId) then
self.dailyTaskAdCellBoxInfo:setVisible(false)
self.dailyTaskAdCellBox:addRedPoint(40, 28, 0.7)
else
self.dailyTaskAdCellBoxInfo:setVisible(true)
self.dailyTaskAdCellBox:removeRedPoint()
end
self.dailyTaskAdCellProgressTx:setText(count .. "/" .. needCount)
self.dailyTaskAdCellProgress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = count/needCount
end
@ -259,6 +272,13 @@ function TaskMainUI:refreshDailyTaskFinalCell()
if count > needCount then
count = needCount
end
if DataManager.DailyTaskData:getDailyTaskCanClaimTask(taskId) then
self.dailyTaskFinalCellBoxInfo:setVisible(false)
self.dailyTaskFinalCellBox:addRedPoint(40, 28, 0.7)
else
self.dailyTaskFinalCellBoxInfo:setVisible(true)
self.dailyTaskFinalCellBox:removeRedPoint()
end
self.dailyTaskFinalCellProgressTx:setText(count .. "/" .. needCount)
self.dailyTaskFinalCellProgress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = count/needCount
end
@ -302,7 +322,7 @@ function TaskMainUI:updateTime()
if self.resetTime == time then
return
end
if self.resetTime and time > self.resetTime and DataManager.DailyTaskData:getIfCanReset() then -- 跨天了
if DataManager.DailyTaskData:getIfCanReset() then -- 跨天了
ModuleManager.TaskManager:resetDailyTask()
end
self.resetTime = time

View File

@ -165,6 +165,23 @@ function DailyTaskData:getDailyTaskCanRefresh(id)
return cfg.ad_refresh
end
function DailyTaskData:getDailyTaskIsAdType(id)
local task = self.dailyTasks[id]
if task == nil then
return false
end
local cfg = self:getTaskCfg()
return cfg[task.taskId].type == GConst.TaskConst.TASK_TYPE.DAILY_TASK_WATCH_AD_SPECIAL
end
function DailyTaskData:getDailyTaskCanClaimTask(id)
local task = self.dailyTasks[id]
if task == nil then
return false
end
return self:getIfCanClaimTask(task)
end
function DailyTaskData:getDailyTaskIcon(id)
local task = self.dailyTasks[id]
if task == nil then
@ -252,7 +269,7 @@ function DailyTaskData:unregisterTask(taskType)
end
function DailyTaskData:getIfCanReset()
return self.initDay ~= Time:getBeginningOfServerToday()
return self.initDay < Time:getBeginningOfServerToday()
end
function DailyTaskData:setInReset(isInReset)