任务
This commit is contained in:
parent
760527284d
commit
482e1a2127
@ -42,6 +42,15 @@ BIReport.CHAPTER_OPT_TYPE = {
|
|||||||
BOX_OPEN = "BoxOpen",
|
BOX_OPEN = "BoxOpen",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIReport.TASK_TYPE = {
|
||||||
|
DAILY = "Daily",
|
||||||
|
}
|
||||||
|
|
||||||
|
BIReport.TASK_OPT_TYPE = {
|
||||||
|
FINISH = "Finish",
|
||||||
|
REWARD = "Reward",
|
||||||
|
}
|
||||||
|
|
||||||
BIReport.ITEM_GET_TYPE = {
|
BIReport.ITEM_GET_TYPE = {
|
||||||
NEW_PLAYER_INITIAL = "NewPlayerInitial", -- 新玩家创号自带
|
NEW_PLAYER_INITIAL = "NewPlayerInitial", -- 新玩家创号自带
|
||||||
UPGRADE_HERO = "UpgradeHero",
|
UPGRADE_HERO = "UpgradeHero",
|
||||||
@ -111,6 +120,7 @@ local EVENT_NAME_ACCOUNT_OPT = "client_account_opt"
|
|||||||
local EVENT_NAME_CHAPTER_OPT = "client_chapter_opt" -- 章节
|
local EVENT_NAME_CHAPTER_OPT = "client_chapter_opt" -- 章节
|
||||||
local EVENT_NAME_VIT_USE = "client_vit_use"
|
local EVENT_NAME_VIT_USE = "client_vit_use"
|
||||||
local EVENT_NAME_VIT_GET = "client_vit_get"
|
local EVENT_NAME_VIT_GET = "client_vit_get"
|
||||||
|
local EVENT_NAME_TASK = "client_task"
|
||||||
|
|
||||||
function BIReport:setIsNewPlayer(isNewPlayer)
|
function BIReport:setIsNewPlayer(isNewPlayer)
|
||||||
self.isNewPlayer = isNewPlayer
|
self.isNewPlayer = isNewPlayer
|
||||||
@ -686,4 +696,15 @@ function BIReport:postGemUse(num, getType, itemId)
|
|||||||
self:report(EVENT_NAME_COIN_USE, args)
|
self:report(EVENT_NAME_COIN_USE, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BIReport:postDailyTaskFinish(taskType, cfgId, taskId, refresh)
|
||||||
|
local args = {
|
||||||
|
task_type = taskType,
|
||||||
|
task_id = taskId,
|
||||||
|
cfg_id = cfgId,
|
||||||
|
task_refresh = refresh,
|
||||||
|
event_type = BIReport.TASK_OPT_TYPE.FINISH,
|
||||||
|
}
|
||||||
|
self:report(EVENT_NAME_TASK, args)
|
||||||
|
end
|
||||||
|
|
||||||
return BIReport
|
return BIReport
|
||||||
@ -15,7 +15,7 @@ function DataManager:init()
|
|||||||
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
|
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
|
||||||
self:initManager("ActivityData", "app/userdata/activity/activity_data")
|
self:initManager("ActivityData", "app/userdata/activity/activity_data")
|
||||||
self:initManager("GodPigData", "app/userdata/activity/god_pig/god_pig_data")
|
self:initManager("GodPigData", "app/userdata/activity/god_pig/god_pig_data")
|
||||||
self:initManager("TaskData", "app/userdata/task/task_data")
|
self:initManager("DailyTaskData", "app/userdata/task/daily_task_data")
|
||||||
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
||||||
-- self:initManager("IdleData", "app/userdata/idle/idle_data")
|
-- self:initManager("IdleData", "app/userdata/idle/idle_data")
|
||||||
-- self:initManager("SevenDayData", "app/userdata/activity/seven_day/seven_day_data")
|
-- self:initManager("SevenDayData", "app/userdata/activity/seven_day/seven_day_data")
|
||||||
@ -84,7 +84,7 @@ function DataManager:clear()
|
|||||||
self.ActivityData:clear()
|
self.ActivityData:clear()
|
||||||
self.GodPigData:clear()
|
self.GodPigData:clear()
|
||||||
self.BountyData:clear()
|
self.BountyData:clear()
|
||||||
self.TaskData:clear()
|
self.DailyTaskData:clear()
|
||||||
-- self.IdleData:clear()
|
-- self.IdleData:clear()
|
||||||
-- self.SevenDayData:clear()
|
-- self.SevenDayData:clear()
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ function DataManager:initWithServerData(data)
|
|||||||
self.GodPigData:init()
|
self.GodPigData:init()
|
||||||
self.BountyData:init()
|
self.BountyData:init()
|
||||||
-- 要在BountyData之后初始化,依赖BountyData的数据
|
-- 要在BountyData之后初始化,依赖BountyData的数据
|
||||||
self.TaskData:init(data.task_daily)
|
self.DailyTaskData:init(data.task_daily)
|
||||||
-- self.IdleData:clear(data.IdleData)
|
-- self.IdleData:clear(data.IdleData)
|
||||||
-- self.SevenDayData:init(data.SevenDayData)
|
-- self.SevenDayData:init(data.SevenDayData)
|
||||||
|
|
||||||
@ -234,8 +234,6 @@ function DataManager:scheduleGlobal()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY)
|
|
||||||
end
|
end
|
||||||
end, 1)
|
end, 1)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -23,6 +23,7 @@ EventManager.CUSTOM_EVENT = {
|
|||||||
SHOW_ELIMINATION_TUTORAIL = "SHOW_ELIMINATION_TUTORAIL",
|
SHOW_ELIMINATION_TUTORAIL = "SHOW_ELIMINATION_TUTORAIL",
|
||||||
BOARD_FILL_OVER = "BOARD_FILL_OVER",
|
BOARD_FILL_OVER = "BOARD_FILL_OVER",
|
||||||
LOGIN_REQ_SUCCESS = "LOGIN_REQ_SUCCESS",
|
LOGIN_REQ_SUCCESS = "LOGIN_REQ_SUCCESS",
|
||||||
|
DAILY_TASK_ADD_PROGRESS = "DAILY_TASK_ADD_PROGRESS",
|
||||||
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
|
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
|
||||||
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
|
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ local MODULE_PATHS = {
|
|||||||
-- 引导
|
-- 引导
|
||||||
TutorialManager = "app/module/tutorial/tutorial_manager",
|
TutorialManager = "app/module/tutorial/tutorial_manager",
|
||||||
ToastManager = "app/ui/common/toast",
|
ToastManager = "app/ui/common/toast",
|
||||||
|
TaskToastManager = "app/ui/common/task_toast",
|
||||||
-- 任务
|
-- 任务
|
||||||
TaskManager = "app/module/task/task_manager",
|
TaskManager = "app/module/task/task_manager",
|
||||||
-- 战斗
|
-- 战斗
|
||||||
@ -58,7 +59,7 @@ local MODULE_METATABLE = {
|
|||||||
setmetatable(ModuleManager, MODULE_METATABLE)
|
setmetatable(ModuleManager, MODULE_METATABLE)
|
||||||
|
|
||||||
function ModuleManager:init()
|
function ModuleManager:init()
|
||||||
|
ModuleManager.TaskManager:init()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 功能是否开启
|
-- 功能是否开启
|
||||||
|
|||||||
@ -344,8 +344,8 @@ function GFunc.hideCheatingBox()
|
|||||||
CheatMessageBox:hideCheatMessageBox()
|
CheatMessageBox:hideCheatMessageBox()
|
||||||
end
|
end
|
||||||
|
|
||||||
function GFunc.showToast(tab)
|
function GFunc.showToast(params)
|
||||||
ModuleManager.ToastManager:showToast(tab)
|
ModuleManager.ToastManager:showToast(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GFunc.UiRectTransformScreenPointToLocalPointInRectangle(go, x, y)
|
function GFunc.UiRectTransformScreenPointToLocalPointInRectangle(go, x, y)
|
||||||
|
|||||||
@ -1,37 +1,26 @@
|
|||||||
local TaskConst = {}
|
local TaskConst = {}
|
||||||
|
|
||||||
TaskConst.TASK_TYPE = {
|
TaskConst.TASK_TYPE = {
|
||||||
X_KILL_MONSTER = 1,
|
X_WATCH_AD = 1,
|
||||||
PASS_CHAPTER = 2,
|
X_GOLD_GOT = 2,
|
||||||
X_SUMMON = 3,
|
X_GEM_GOT = 3,
|
||||||
X_WATCH_AD = 4,
|
X_GOLD_COST = 4,
|
||||||
COMPLETED_DALY_TASK = 5,
|
X_GEM_COST = 5,
|
||||||
X_LOGIN_DAY = 6,
|
X_OPEN_SHOP_BOX = 6,
|
||||||
X_WEAPON_SUMMON = 7,
|
X_OPEN_SHOP_EPIC_BOX = 7,
|
||||||
X_PROTECTIVE_SUMMON = 8,
|
X_SKILL_BOX_GOT_IN_BATTLE = 8,
|
||||||
X_LEGACY_SUMMON = 9,
|
X_BATTLE_VICTORY = 9,
|
||||||
COMPLETED_JEWELRY_BATTLE = 10,
|
X_HERO_LV_UP = 10,
|
||||||
COMPLETED_GOLD_BATTLE = 11,
|
X_HERO_FRAGMENT_GOT = 11,
|
||||||
COMPLETED_MITHRIL_BATTLE = 12,
|
X_KILL_BOSS = 12,
|
||||||
COMPLETED_CHARACTERISTIC_BATTLE = 13,
|
X_KILL_MONSTER = 13,
|
||||||
ARENA_TIER_ON = 14,
|
X_ELIMINATE = 14,
|
||||||
X_HOE_USE = 15,
|
X_ELIMINATE_SIX_ONCE = 15,
|
||||||
X_BORING_CROWN_USE = 16,
|
X_ELIMINATE_EIGHT_ONCE = 16,
|
||||||
X_BOOM_USE = 17,
|
X_COMBO_TEN = 17,
|
||||||
X_RESEARCH_USE = 18,
|
X_USE_SKILL = 18,
|
||||||
X_MINE_GRID = 19,
|
X_BATTLE_PASS_WAVE = 19,
|
||||||
X_MINE_DISTANCE = 20,
|
COMPLETED_DALY_TASK = 20
|
||||||
X_BLESSING_GOT = 21,
|
|
||||||
X_RUNE_GOT = 22,
|
|
||||||
X_RUNE_LV_UP = 23,
|
|
||||||
X_TRAIN_ATK = 24,
|
|
||||||
X_TRAIN_HP = 25,
|
|
||||||
X_STAGE_CHALLENGE = 26,
|
|
||||||
X_JEWELRY_BATTLE = 27,
|
|
||||||
X_GOLD_BATTLE = 28,
|
|
||||||
X_MITHRIL_BATTLE = 29,
|
|
||||||
X_CHARACTERISTIC_BATTLE = 30,
|
|
||||||
X_ARENA_CHALLENGE = 31,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TaskConst
|
return TaskConst
|
||||||
@ -1,5 +1,14 @@
|
|||||||
local TaskManager = class("TaskManager", BaseModule)
|
local TaskManager = class("TaskManager", BaseModule)
|
||||||
|
|
||||||
|
function TaskManager:init()
|
||||||
|
self:addEventListener(EventManager.CUSTOM_EVENT.DAILY_TASK_ADD_PROGRESS, function(id, taskId, from, to)
|
||||||
|
ModuleManager.TaskToastManager:showToast(id, taskId, from, to)
|
||||||
|
end)
|
||||||
|
self:addEventListener(EventManager.CUSTOM_EVENT.UI_SHOW_COMPLETE, function()
|
||||||
|
ModuleManager.TaskToastManager:checkOnOpenUI()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function TaskManager:showTaskMainUI()
|
function TaskManager:showTaskMainUI()
|
||||||
UIManager:showUI("app/ui/task/task_main_ui")
|
UIManager:showUI("app/ui/task/task_main_ui")
|
||||||
end
|
end
|
||||||
@ -16,7 +25,7 @@ end
|
|||||||
function TaskManager:onDailyTaskRefresh(result)
|
function TaskManager:onDailyTaskRefresh(result)
|
||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
if result.task then
|
if result.task then
|
||||||
DataManager.TaskData:refreshDailyTask(result.task)
|
DataManager.DailyTaskData:refreshDailyTask(result.task)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -31,7 +40,7 @@ end
|
|||||||
function TaskManager:onDailyTaskClaim(result)
|
function TaskManager:onDailyTaskClaim(result)
|
||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
if result.task then
|
if result.task then
|
||||||
DataManager.TaskData:refreshDailyTask(result.task)
|
DataManager.DailyTaskData:refreshDailyTask(result.task)
|
||||||
end
|
end
|
||||||
if result.rewards then
|
if result.rewards then
|
||||||
GFunc.showRewardBox(result.rewards)
|
GFunc.showRewardBox(result.rewards)
|
||||||
@ -117,28 +126,6 @@ function TaskManager:xKillMonster(params)
|
|||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER, num)
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER, num)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TaskManager:passChapter()
|
|
||||||
local id = DataManager.ChapterData:getHistoryChapterId()
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.PASS_CHAPTER, id)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xSummon(params)
|
|
||||||
local num = params.num
|
|
||||||
local cfgId = params.cfgId
|
|
||||||
if not num then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_SUMMON, num)
|
|
||||||
if cfgId == ModuleManager.SummonManager.WEAPON_SUMMON then
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_WEAPON_SUMMON, num)
|
|
||||||
elseif cfgId == ModuleManager.SummonManager.PROTECTIVE_SUMMON then
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_PROTECTIVE_SUMMON, num)
|
|
||||||
elseif cfgId == ModuleManager.SummonManager.LEGACY_SUMMON then
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_LEGACY_SUMMON, num)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xWatchAd(params)
|
function TaskManager:xWatchAd(params)
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_WATCH_AD, 1)
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_WATCH_AD, 1)
|
||||||
end
|
end
|
||||||
@ -147,152 +134,11 @@ function TaskManager:completeDailyTask()
|
|||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.COMPLETED_DALY_TASK, 1)
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.COMPLETED_DALY_TASK, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TaskManager:xLoginDay()
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:arenaTierOn(params)
|
|
||||||
local segement = params.segement
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.ARENA_TIER_ON, segement)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xHoeUse(params)
|
|
||||||
local num = params.num
|
|
||||||
if not num then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_HOE_USE, num)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xboringCrownUse(params)
|
|
||||||
local num = params.num
|
|
||||||
if not num then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE, num)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xBoomUse(params)
|
|
||||||
local num = params.num
|
|
||||||
if not num then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_BOOM_USE, num)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xResearchUse(params)
|
|
||||||
local count = DataManager.ResearchData:getResearchCount()
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_RESEARCH_USE, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xMineGrid(params)
|
|
||||||
local num = params.num
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_MINE_GRID, num)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xMineDistance(params)
|
|
||||||
local distance = DataManager.MiningData:getDepth()
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_MINE_DISTANCE, distance)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xBlessingGot(params)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_BLESSING_GOT, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xRuneGot(params)
|
|
||||||
local runeList = params.runeList
|
|
||||||
if not runeList then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local count = #runeList
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_RUNE_GOT, count)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xRuneLvUp(params)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_RUNE_LV_UP, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xTrainAtk(params)
|
|
||||||
local num = params.count
|
|
||||||
if not num then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_TRAIN_ATK, num)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xTrainHp(params)
|
|
||||||
local num = params.count
|
|
||||||
if not num then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_TRAIN_HP, num)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xStageChallenge(params)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_STAGE_CHALLENGE, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:onDungenBattle(params)
|
|
||||||
local id = params.id
|
|
||||||
local maxLevel = DataManager.DungeonData:getPassedMaxLevel(id)
|
|
||||||
if id == 1 then
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_GOLD_BATTLE, 1)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE, maxLevel)
|
|
||||||
elseif id == 2 then
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_JEWELRY_BATTLE, 1)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE, maxLevel)
|
|
||||||
elseif id == 3 then
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_MITHRIL_BATTLE, 1)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE, maxLevel)
|
|
||||||
elseif id == 4 then
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_CHARACTERISTIC_BATTLE, 1)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.COMPLETED_CHARACTERISTIC_BATTLE, maxLevel)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:xArenaChallenge(params)
|
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_ARENA_CHALLENGE, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
---- 没有特殊说明,方法均返回任务增量
|
---- 没有特殊说明,方法均返回任务增量
|
||||||
TaskManager.TYPE_DEAL_FUNC = {
|
TaskManager.TYPE_DEAL_FUNC = {
|
||||||
[GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER] = TaskManager.xKillMonster,
|
[GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER] = TaskManager.xKillMonster,
|
||||||
[GConst.TaskConst.TASK_TYPE.PASS_CHAPTER] = TaskManager.passChapter,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_SUMMON] = TaskManager.xSummon,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_WATCH_AD] = TaskManager.xWatchAd,
|
[GConst.TaskConst.TASK_TYPE.X_WATCH_AD] = TaskManager.xWatchAd,
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_DALY_TASK] = TaskManager.completeDailyTask,
|
[GConst.TaskConst.TASK_TYPE.COMPLETED_DALY_TASK] = TaskManager.completeDailyTask,
|
||||||
[GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY] = TaskManager.xLoginDay,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_WEAPON_SUMMON] = TaskManager.xSummon,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_PROTECTIVE_SUMMON] = TaskManager.xSummon,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_LEGACY_SUMMON] = TaskManager.xSummon,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_CHARACTERISTIC_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.ARENA_TIER_ON] = TaskManager.arenaTierOn,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_HOE_USE] = TaskManager.xHoeUse,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE] = TaskManager.xboringCrownUse,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_BOOM_USE] = TaskManager.xBoomUse,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_RESEARCH_USE] = TaskManager.xResearchUse,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_MINE_GRID] = TaskManager.xMineGrid,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_MINE_DISTANCE] = TaskManager.xMineDistance,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_BLESSING_GOT] = TaskManager.xBlessingGot,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_RUNE_GOT] = TaskManager.xRuneGot,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_RUNE_LV_UP] = TaskManager.xRuneLvUp,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_TRAIN_ATK] = TaskManager.xTrainAtk,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_TRAIN_HP] = TaskManager.xTrainHp,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_STAGE_CHALLENGE] = TaskManager.xStageChallenge,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_JEWELRY_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_GOLD_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_MITHRIL_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_CHARACTERISTIC_BATTLE] = TaskManager.onDungenBattle,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_ARENA_CHALLENGE] = TaskManager.xArenaChallenge,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function TaskManager:taskGoto(taskType)
|
function TaskManager:taskGoto(taskType)
|
||||||
@ -305,52 +151,8 @@ function TaskManager:gotoMainUI()
|
|||||||
ModuleManager.MaincityManager:showMainCityUI()
|
ModuleManager.MaincityManager:showMainCityUI()
|
||||||
end
|
end
|
||||||
|
|
||||||
function TaskManager:gotoSummonUI()
|
|
||||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = GConst.MainCityConst.BOTTOM_PAGE.SHOP, storeIdx = 1})
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:gotoSectUI()
|
|
||||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = GConst.MainCityConst.BOTTOM_PAGE.SECT})
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:gotoDungenUI()
|
|
||||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = GConst.MainCityConst.BOTTOM_PAGE.DUNGEON})
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskManager:gotoTarinUI()
|
|
||||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = GConst.MainCityConst.BOTTOM_PAGE.TRAIN})
|
|
||||||
end
|
|
||||||
|
|
||||||
TaskManager.gotoFunc = {
|
TaskManager.gotoFunc = {
|
||||||
[GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER] = TaskManager.gotoMainUI,
|
[GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER] = TaskManager.gotoMainUI,
|
||||||
[GConst.TaskConst.TASK_TYPE.PASS_CHAPTER] = TaskManager.gotoMainUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_SUMMON] = TaskManager.gotoSummonUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_WATCH_AD] = TaskManager.gotoSummonUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_WEAPON_SUMMON] = TaskManager.gotoSummonUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_PROTECTIVE_SUMMON] = TaskManager.gotoSummonUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_LEGACY_SUMMON] = TaskManager.gotoSummonUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE] = TaskManager.gotoDungenUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE] = TaskManager.gotoDungenUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE] = TaskManager.gotoDungenUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.COMPLETED_CHARACTERISTIC_BATTLE] = TaskManager.gotoDungenUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.ARENA_TIER_ON] = TaskManager.gotoDungenUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_HOE_USE] = TaskManager.gotoSectUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE] = TaskManager.gotoSectUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_BOOM_USE] = TaskManager.gotoSectUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_RESEARCH_USE] = TaskManager.gotoSectUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_MINE_GRID] = TaskManager.gotoSectUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_MINE_DISTANCE] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_BLESSING_GOT] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_RUNE_GOT] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_RUNE_LV_UP] = TaskManager.gotoMainUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_TRAIN_ATK] = TaskManager.gotoTarinUI,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_TRAIN_HP] = TaskManager.gotoTarinUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_STAGE_CHALLENGE] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_JEWELRY_BATTLE] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_GOLD_BATTLE] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_MITHRIL_BATTLE] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_CHARACTERISTIC_BATTLE] = TaskManager.gotoMainUI,
|
|
||||||
-- [GConst.TaskConst.TASK_TYPE.X_ARENA_CHALLENGE] = TaskManager.gotoMainUI,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function TaskManager:getTaskDesc(type, count, totalCount)
|
function TaskManager:getTaskDesc(type, count, totalCount)
|
||||||
@ -359,17 +161,7 @@ function TaskManager:getTaskDesc(type, count, totalCount)
|
|||||||
return GConst.EMPTY_STRING
|
return GConst.EMPTY_STRING
|
||||||
end
|
end
|
||||||
|
|
||||||
local str = GConst.EMPTY_STRING
|
local str = "(" .. count .. "/" .. totalCount .. ")"
|
||||||
if type == GConst.TaskConst.TASK_TYPE.PASS_CHAPTER or
|
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE or
|
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE or
|
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE or
|
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_CHARACTERISTIC_BATTLE
|
|
||||||
then
|
|
||||||
str = totalCount
|
|
||||||
else
|
|
||||||
str = "(" .. count .. "/" .. totalCount .. ")"
|
|
||||||
end
|
|
||||||
return I18N:getText("task", type, "desc", str)
|
return I18N:getText("task", type, "desc", str)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -379,20 +171,11 @@ function TaskManager:getTaskTutorialDesc(type, count, totalCount)
|
|||||||
return GConst.EMPTY_STRING
|
return GConst.EMPTY_STRING
|
||||||
end
|
end
|
||||||
|
|
||||||
local endStr = GConst.EMPTY_STRING
|
local endStr
|
||||||
if type == GConst.TaskConst.TASK_TYPE.PASS_CHAPTER or
|
if count then
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE or
|
endStr = "(" .. count .. "/" .. totalCount .. ")"
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE or
|
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE or
|
|
||||||
type == GConst.TaskConst.TASK_TYPE.COMPLETED_CHARACTERISTIC_BATTLE
|
|
||||||
then
|
|
||||||
endStr = totalCount
|
|
||||||
else
|
else
|
||||||
if count then
|
endStr = "(" .. totalCount .. ")"
|
||||||
endStr = "(" .. count .. "/" .. totalCount .. ")"
|
|
||||||
else
|
|
||||||
endStr = "(" .. totalCount .. ")"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local str = I18N:getText("task", type, "tutorial_desc") .. endStr
|
local str = I18N:getText("task", type, "tutorial_desc") .. endStr
|
||||||
|
|||||||
182
lua/app/ui/common/task_toast.lua
Normal file
182
lua/app/ui/common/task_toast.lua
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
local TaskToastManager = class("TaskToastManager", BaseModule)
|
||||||
|
|
||||||
|
function TaskToastManager:ctor()
|
||||||
|
self.toastList = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:checkOnOpenUI()
|
||||||
|
if #self.toastList <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local topUIObj = UIManager:getTopUIObj()
|
||||||
|
if topUIObj then
|
||||||
|
if self:checkUnshowUI(topUIObj) then
|
||||||
|
self:closeToast()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:checkUnshowUI(uiObj)
|
||||||
|
local uiIndex = uiObj:getUIIndex()
|
||||||
|
if uiIndex == UIManager.UI_PATH.BATTLE_UI then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:showToast(id, taskId, from, to)
|
||||||
|
local topUIObj = UIManager:getTopUIObj()
|
||||||
|
if topUIObj then
|
||||||
|
if self:checkUnshowUI(topUIObj) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local params = {
|
||||||
|
id = id,
|
||||||
|
taskId = taskId,
|
||||||
|
from = from,
|
||||||
|
to = to
|
||||||
|
}
|
||||||
|
table.insert(self.toastList, params)
|
||||||
|
if #self.toastList == 1 then
|
||||||
|
self:_showToast()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:_showToast()
|
||||||
|
local params = self.toastList[1]
|
||||||
|
if params == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
UIManager:getTaskToast(function(prefabObject)
|
||||||
|
local uiMap = prefabObject:genAllChildren()
|
||||||
|
local lockBg = uiMap["task_toast.lock_bg"]
|
||||||
|
local icon = uiMap["task_toast.icon"]
|
||||||
|
local nameTx = uiMap["task_toast.name_tx"]
|
||||||
|
local progressComp = uiMap["task_toast.progress_bg.progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||||
|
local progressTx = uiMap["task_toast.progress_bg.progress_tx"]
|
||||||
|
local rewardCellComp = uiMap["task_toast.reward_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||||
|
|
||||||
|
local dailyTaskInfo = ConfigManager:getConfig("task_daily")[params.id]
|
||||||
|
if dailyTaskInfo == nil then
|
||||||
|
return self:onFinish()
|
||||||
|
end
|
||||||
|
if dailyTaskInfo.bounty then
|
||||||
|
lockBg:setVisible(true)
|
||||||
|
else
|
||||||
|
lockBg:setVisible(false)
|
||||||
|
end
|
||||||
|
local taskInfo = ConfigManager:getConfig("task")[params.taskId]
|
||||||
|
if taskInfo == nil then
|
||||||
|
return self:onFinish()
|
||||||
|
end
|
||||||
|
icon:setSprite(GConst.ATLAS_PATH.ICON_TASK, taskInfo.icon)
|
||||||
|
|
||||||
|
local taskI18NInfo = I18N:getConfig("task")[params.taskId]
|
||||||
|
if taskI18NInfo == nil then
|
||||||
|
return self:onFinish()
|
||||||
|
end
|
||||||
|
nameTx:setText(taskI18NInfo.desc)
|
||||||
|
local reward = taskInfo.reward
|
||||||
|
if reward and reward[1] then
|
||||||
|
rewardCellComp:refreshByConfig(reward[1])
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.sliderSequence then
|
||||||
|
self.sliderSequence:Kill()
|
||||||
|
end
|
||||||
|
self.sliderSequence = DOTweenManager:createSeqWithIntId()
|
||||||
|
local curProgress = 0
|
||||||
|
local from = params.from
|
||||||
|
local to = params.to
|
||||||
|
local last = to - from
|
||||||
|
local startPercent = params.from / params.to
|
||||||
|
local lastPercent = 1 - startPercent
|
||||||
|
progressComp.value = from / to
|
||||||
|
progressTx:setText(from .. "/" .. to)
|
||||||
|
local tween = DOTweenManager:createDOTweenTo(
|
||||||
|
function()
|
||||||
|
return curProgress
|
||||||
|
end,
|
||||||
|
function(value)
|
||||||
|
curProgress = value
|
||||||
|
progressComp.value = startPercent + lastPercent*curProgress
|
||||||
|
progressTx:setText(from + math.floor(last*curProgress) .. "/" .. to)
|
||||||
|
end,
|
||||||
|
1, 1)
|
||||||
|
self.sliderSequence:Append(tween)
|
||||||
|
self.sliderSequence:AppendCallback(function()
|
||||||
|
self.sliderSequence = nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
local notchHeight = SafeAreaManager:getNotchScreenHeight()
|
||||||
|
prefabObject:setAnchoredPositionY(-notchHeight)
|
||||||
|
prefabObject:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = true
|
||||||
|
|
||||||
|
if self.toastSequence == nil then
|
||||||
|
self.toastSequence = DOTweenManager:createSeqWithIntId()
|
||||||
|
self.toastSequence:AppendInterval(2)
|
||||||
|
self.toastSequence:AppendCallback(function()
|
||||||
|
self:onFinish()
|
||||||
|
end)
|
||||||
|
self.toastSequence:SetAutoKill(false)
|
||||||
|
else
|
||||||
|
self.toastSequence:Restart()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:refreshText()
|
||||||
|
if #self.toastList <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.toastSequence then
|
||||||
|
self.toastSequence:Pause()
|
||||||
|
end
|
||||||
|
if self.sliderSequence then
|
||||||
|
self.sliderSequence:Kill()
|
||||||
|
self.sliderSequence = nil
|
||||||
|
end
|
||||||
|
self:onFinish()
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:closeToast()
|
||||||
|
if #self.toastList <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.toastSequence then
|
||||||
|
self.toastSequence:Pause()
|
||||||
|
end
|
||||||
|
if self.sliderSequence then
|
||||||
|
self.sliderSequence:Kill()
|
||||||
|
self.sliderSequence = nil
|
||||||
|
end
|
||||||
|
UIManager:getTaskToast(function(prefabObject)
|
||||||
|
prefabObject:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
||||||
|
end)
|
||||||
|
for i = 1, #self.toastList do
|
||||||
|
table.remove(self.toastList)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskToastManager:onFinish()
|
||||||
|
if #self.toastList <= 0 then
|
||||||
|
UIManager:getTaskToast(function(prefabObject)
|
||||||
|
prefabObject:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
table.remove(self.toastList, 1)
|
||||||
|
if #self.toastList > 0 then
|
||||||
|
self:_showToast()
|
||||||
|
else
|
||||||
|
UIManager:getTaskToast(function(prefabObject)
|
||||||
|
prefabObject:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return TaskToastManager
|
||||||
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 2a8741d6d926b6848be6dea53c501674
|
guid: 34e0461139b4c0f41a6c701479808938
|
||||||
ScriptedImporter:
|
ScriptedImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@ -453,7 +453,7 @@ function MainCityUI:refreshBounty()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MainCityUI:refreshTask()
|
function MainCityUI:refreshTask()
|
||||||
local isOpen = DataManager.TaskData:getIsOpen()
|
local isOpen = DataManager.DailyTaskData:getIsOpen()
|
||||||
if not isOpen then
|
if not isOpen then
|
||||||
self.taskBtn:setVisible(false)
|
self.taskBtn:setVisible(false)
|
||||||
return
|
return
|
||||||
|
|||||||
@ -40,9 +40,9 @@ end
|
|||||||
|
|
||||||
function DailyTaskCell:refresh(task)
|
function DailyTaskCell:refresh(task)
|
||||||
self.taskId = task.id
|
self.taskId = task.id
|
||||||
local icon = DataManager.TaskData:getDailyTaskIcon(task.id)
|
local icon = DataManager.DailyTaskData:getDailyTaskIcon(task.id)
|
||||||
self.icon:setSprite(GConst.ATLAS_PATH.ICON_TASK, icon)
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_TASK, icon)
|
||||||
local taskDesc = DataManager.TaskData:getDailyTaskDesc(task.id)
|
local taskDesc = DataManager.DailyTaskData:getDailyTaskDesc(task.id)
|
||||||
self.nameTx:setText(taskDesc)
|
self.nameTx:setText(taskDesc)
|
||||||
|
|
||||||
if task.lock then
|
if task.lock then
|
||||||
@ -77,7 +77,7 @@ function DailyTaskCell:refresh(task)
|
|||||||
self.refreshBtn:setVisible(false)
|
self.refreshBtn:setVisible(false)
|
||||||
else
|
else
|
||||||
self.getBtn:setVisible(false)
|
self.getBtn:setVisible(false)
|
||||||
local canRefresh = DataManager.TaskData:getDailyTaskCanRefresh(task.id)
|
local canRefresh = DataManager.DailyTaskData:getDailyTaskCanRefresh(task.id)
|
||||||
if canRefresh then
|
if canRefresh then
|
||||||
if task.refresh then -- 刷过了
|
if task.refresh then -- 刷过了
|
||||||
self.refreshBtn:setVisible(false)
|
self.refreshBtn:setVisible(false)
|
||||||
@ -92,7 +92,7 @@ function DailyTaskCell:refresh(task)
|
|||||||
self.progressTx:setText(count .. "/" .. needCount)
|
self.progressTx:setText(count .. "/" .. needCount)
|
||||||
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = count/needCount
|
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = count/needCount
|
||||||
end
|
end
|
||||||
local reward = DataManager.TaskData:getDailyTaskReward(task.id)
|
local reward = DataManager.DailyTaskData:getDailyTaskReward(task.id)
|
||||||
if reward and reward[1] then
|
if reward and reward[1] then
|
||||||
self.rewardCellComp:refreshByConfig(reward[1])
|
self.rewardCellComp:refreshByConfig(reward[1])
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,9 +37,9 @@ function TaskMainUI:ctor(params)
|
|||||||
self.page = params and params.page or PAGE_DAILY
|
self.page = params and params.page or PAGE_DAILY
|
||||||
self.dailyTaskList = {}
|
self.dailyTaskList = {}
|
||||||
self.challengeTaskList = {}
|
self.challengeTaskList = {}
|
||||||
local taskAdId = DataManager.TaskData:getDailyTaskAdId()
|
local taskAdId = DataManager.DailyTaskData:getDailyTaskAdId()
|
||||||
local taskFinalId = DataManager.TaskData:getDailyTaskFinalId()
|
local taskFinalId = DataManager.DailyTaskData:getDailyTaskFinalId()
|
||||||
local dailyTasks = DataManager.TaskData:getDailyTasks()
|
local dailyTasks = DataManager.DailyTaskData:getDailyTasks()
|
||||||
for k, v in pairs(dailyTasks) do
|
for k, v in pairs(dailyTasks) do
|
||||||
if k ~= taskAdId and k ~= taskFinalId then
|
if k ~= taskAdId and k ~= taskFinalId then
|
||||||
if v.type == TASK_TYPE_DAILY then
|
if v.type == TASK_TYPE_DAILY then
|
||||||
@ -172,7 +172,7 @@ function TaskMainUI:initCountDown()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TaskMainUI:bindData()
|
function TaskMainUI:bindData()
|
||||||
self:bind(DataManager.TaskData, "dailyTaskDirty", function()
|
self:bind(DataManager.DailyTaskData, "dailyTaskDirty", function()
|
||||||
self:onRefresh()
|
self:onRefresh()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -209,10 +209,10 @@ function TaskMainUI:refreshDaily()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TaskMainUI:refreshDailyTaskAdCell()
|
function TaskMainUI:refreshDailyTaskAdCell()
|
||||||
local taskId = DataManager.TaskData:getDailyTaskAdId()
|
local taskId = DataManager.DailyTaskData:getDailyTaskAdId()
|
||||||
local taskDesc = DataManager.TaskData:getDailyTaskDesc(taskId)
|
local taskDesc = DataManager.DailyTaskData:getDailyTaskDesc(taskId)
|
||||||
self.dailyTaskAdCellNameTx:setText(taskDesc)
|
self.dailyTaskAdCellNameTx:setText(taskDesc)
|
||||||
local count, needCount = DataManager.TaskData:getDailyTaskProgress(taskId)
|
local count, needCount = DataManager.DailyTaskData:getDailyTaskProgress(taskId)
|
||||||
if count > needCount then
|
if count > needCount then
|
||||||
count = needCount
|
count = needCount
|
||||||
end
|
end
|
||||||
@ -221,10 +221,10 @@ function TaskMainUI:refreshDailyTaskAdCell()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TaskMainUI:refreshDailyTaskFinalCell()
|
function TaskMainUI:refreshDailyTaskFinalCell()
|
||||||
local taskId = DataManager.TaskData:getDailyTaskFinalId()
|
local taskId = DataManager.DailyTaskData:getDailyTaskFinalId()
|
||||||
local taskDesc = DataManager.TaskData:getDailyTaskDesc(taskId)
|
local taskDesc = DataManager.DailyTaskData:getDailyTaskDesc(taskId)
|
||||||
self.dailyTaskFinalCellNameTx:setText(taskDesc)
|
self.dailyTaskFinalCellNameTx:setText(taskDesc)
|
||||||
local count, needCount = DataManager.TaskData:getDailyTaskProgress(taskId)
|
local count, needCount = DataManager.DailyTaskData:getDailyTaskProgress(taskId)
|
||||||
if count > needCount then
|
if count > needCount then
|
||||||
count = needCount
|
count = needCount
|
||||||
end
|
end
|
||||||
@ -259,7 +259,7 @@ function TaskMainUI:showHelp()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TaskMainUI:updateTime()
|
function TaskMainUI:updateTime()
|
||||||
local time = DataManager.TaskData:getDailyResetTime()
|
local time = DataManager.DailyTaskData:getDailyResetTime()
|
||||||
if self.resetTime == time then
|
if self.resetTime == time then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@ -710,23 +710,36 @@ function UIManager:getToast(callback)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function UIManager:getTaskToast(callback)
|
||||||
|
if self.taskToast == nil then
|
||||||
|
UIPrefabManager:loadUIWidgetAsync("assets/prefabs/ui/common/task_toast.prefab", self.toastNode, function (_prefabObject)
|
||||||
|
_prefabObject:initPrefabHelper()
|
||||||
|
self.taskToast = _prefabObject
|
||||||
|
callback(_prefabObject)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
callback(self.taskToast)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function UIManager:getAllToast()
|
function UIManager:getAllToast()
|
||||||
return self.toastPool
|
return self.toastPool
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIManager:hideToast()
|
function UIManager:hideToast()
|
||||||
if not self.toastPool then
|
if self.toastPool then
|
||||||
return
|
ModuleManager.ToastManager:clear()
|
||||||
end
|
for i, toastObj in ipairs(self.toastPool) do
|
||||||
|
if toastObj._toastSequence then
|
||||||
ModuleManager.ToastManager:clear()
|
toastObj._toastSequence:Kill()
|
||||||
for i, toastObj in ipairs(self.toastPool) do
|
toastObj._toastSequence = nil
|
||||||
if toastObj._toastSequence then
|
end
|
||||||
toastObj._toastSequence:Kill()
|
toastObj._using = false
|
||||||
toastObj._toastSequence = nil
|
toastObj:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
||||||
end
|
end
|
||||||
toastObj._using = false
|
end
|
||||||
toastObj:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
if self.taskToast then
|
||||||
|
ModuleManager.ToastManager:clear()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1145,6 +1158,7 @@ function UIManager:refreshOnChangeLanguage()
|
|||||||
MessageBox:refreshText(true)
|
MessageBox:refreshText(true)
|
||||||
end
|
end
|
||||||
ModuleManager.ToastManager:refreshText()
|
ModuleManager.ToastManager:refreshText()
|
||||||
|
ModuleManager.TaskToastManager:refreshText()
|
||||||
end
|
end
|
||||||
|
|
||||||
if EDITOR_MODE then
|
if EDITOR_MODE then
|
||||||
|
|||||||
@ -368,131 +368,6 @@ function SevenDayData:showRedPoint(day)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SevenDayData:initTaskListener()
|
function SevenDayData:initTaskListener()
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.PASS_CHAPTER, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.PASS_CHAPTER)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:setTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_WATCH_AD, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_WATCH_AD)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_WEAPON_SUMMON, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_WEAPON_SUMMON)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_PROTECTIVE_SUMMON, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_PROTECTIVE_SUMMON)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_LEGACY_SUMMON, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_LEGACY_SUMMON)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.COMPLETED_JEWELRY_BATTLE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:setTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.COMPLETED_GOLD_BATTLE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:setTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.COMPLETED_MITHRIL_BATTLE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:setTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_HOE_USE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_HOE_USE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_BOOM_USE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_BOOM_USE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_RESEARCH_USE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_RESEARCH_USE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_MINE_DISTANCE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_MINE_DISTANCE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:setTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_BLESSING_GOT, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_BLESSING_GOT)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_RUNE_GOT, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_RUNE_GOT)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_TRAIN_ATK, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_TRAIN_ATK)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:setTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("SevenDayData", GConst.TaskConst.TASK_TYPE.X_TRAIN_HP, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_TRAIN_HP)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:setTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return SevenDayData
|
return SevenDayData
|
||||||
@ -362,61 +362,6 @@ function BountyData:getTaskCanCaimed(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BountyData:initTaskListener()
|
function BountyData:initTaskListener()
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_SUMMON, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_SUMMON)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_HOE_USE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_HOE_USE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_JEWELRY_BATTLE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_JEWELRY_BATTLE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_GOLD_BATTLE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_GOLD_BATTLE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_MITHRIL_BATTLE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_MITHRIL_BATTLE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_ARENA_CHALLENGE, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_ARENA_CHALLENGE)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModuleManager.TaskManager:registerTask("BountyData", GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY, function(count)
|
|
||||||
local list = self:getTaskListByType(GConst.TaskConst.TASK_TYPE.X_LOGIN_DAY)
|
|
||||||
for _, id in ipairs(list) do
|
|
||||||
self:addTaskProgress(id, count)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BountyData:getTaskRp()
|
function BountyData:getTaskRp()
|
||||||
|
|||||||
238
lua/app/userdata/task/daily_task_data.lua
Normal file
238
lua/app/userdata/task/daily_task_data.lua
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
local DailyTaskData = class("DailyTaskData", BaseData)
|
||||||
|
|
||||||
|
local DAILY_TASK_AD_ID = 1
|
||||||
|
local DAILY_TASK_FINAL_ID = 2
|
||||||
|
local DATA_NAME = "DailyTaskData"
|
||||||
|
|
||||||
|
function DailyTaskData:ctor()
|
||||||
|
self.data.dailyTaskDirty = false
|
||||||
|
self.taskTypeMap = {}
|
||||||
|
self.dailyTasks = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:init(data)
|
||||||
|
local tasks = data and data.tasks
|
||||||
|
local cfg = self:getDailyTaskCfg()
|
||||||
|
local taskCfg = self:getTaskCfg()
|
||||||
|
for k, v in pairs(self.dailyTasks) do
|
||||||
|
self.dailyTasks[k] = nil
|
||||||
|
end
|
||||||
|
for k, v in pairs(self.taskTypeMap) do
|
||||||
|
for i = 1, #v do
|
||||||
|
table.remove(v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for k, v in pairs(cfg) do
|
||||||
|
local task = tasks and tasks[k] or GConst.EMPTY_TABLE
|
||||||
|
local taskInfo = taskCfg[task.task_id]
|
||||||
|
if taskInfo then
|
||||||
|
local dailyTaskObj = {
|
||||||
|
id = k,
|
||||||
|
taskId = task.task_id,
|
||||||
|
progress = task.progress,
|
||||||
|
needProgress = taskInfo.number,
|
||||||
|
refresh = task.refresh,
|
||||||
|
claimed = task.claimed,
|
||||||
|
type = v.type
|
||||||
|
}
|
||||||
|
if v.bounty then
|
||||||
|
dailyTaskObj.lock = true
|
||||||
|
end
|
||||||
|
self.dailyTasks[k] = dailyTaskObj
|
||||||
|
local list = self.taskTypeMap[taskInfo.type]
|
||||||
|
if list == nil then
|
||||||
|
list = {}
|
||||||
|
self.taskTypeMap[taskInfo.type] = list
|
||||||
|
end
|
||||||
|
table.insert(list, dailyTaskObj)
|
||||||
|
if #list == 1 then
|
||||||
|
self:registerTask(taskInfo.type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:refreshDailyTask(task)
|
||||||
|
local id = task.id
|
||||||
|
local dailyTaskObj = self.dailyTasks[id]
|
||||||
|
if dailyTaskObj == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local taskInfo = self:getTaskCfg()[task.task_id]
|
||||||
|
if taskInfo == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local originTaskInfo = self:getTaskCfg()[dailyTaskObj.taskId]
|
||||||
|
if originTaskInfo == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
dailyTaskObj.id = task.id
|
||||||
|
dailyTaskObj.taskId = task.task_id
|
||||||
|
dailyTaskObj.progress = task.progress
|
||||||
|
dailyTaskObj.needProgress = taskInfo.number
|
||||||
|
dailyTaskObj.refresh = task.refresh
|
||||||
|
dailyTaskObj.claimed = task.claimed
|
||||||
|
local originTaskType = originTaskInfo.type
|
||||||
|
if originTaskType ~= taskInfo.type then -- 任务类型变了
|
||||||
|
local originTaskList = self.taskTypeMap[originTaskType]
|
||||||
|
if originTaskList then
|
||||||
|
for k, v in ipairs(originTaskList) do
|
||||||
|
if v.id == id then
|
||||||
|
table.remove(originTaskList, k)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #originTaskList == 0 then
|
||||||
|
self:unregisterTask(originTaskType)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local newTaskList = self.taskTypeMap[taskInfo.type]
|
||||||
|
if newTaskList == nil then
|
||||||
|
newTaskList = {}
|
||||||
|
self.taskTypeMap[taskInfo.type] = newTaskList
|
||||||
|
end
|
||||||
|
table.insert(newTaskList, dailyTaskObj)
|
||||||
|
if #newTaskList == 1 then
|
||||||
|
self:registerTask(taskInfo.type)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:markDailyTaskDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getIsOpen()
|
||||||
|
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.TASK, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyResetTime()
|
||||||
|
return 86400 - Time:getServerTime() % 86400
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskAdId()
|
||||||
|
return DAILY_TASK_AD_ID
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskFinalId()
|
||||||
|
return DAILY_TASK_FINAL_ID
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:markDailyTaskDirty()
|
||||||
|
self.data.dailyTaskDirty = not self.data.dailyTaskDirty
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskProgress(id)
|
||||||
|
local task = self.dailyTasks[id]
|
||||||
|
if task == nil then
|
||||||
|
return 0, 1
|
||||||
|
end
|
||||||
|
return task.progress, task.needProgress
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskDesc(id)
|
||||||
|
local task = self.dailyTasks[id]
|
||||||
|
if task == nil then
|
||||||
|
return GConst.EMPTY_STRING
|
||||||
|
end
|
||||||
|
local cfg = self:getTaskI18NCfg()
|
||||||
|
return cfg[task.taskId].desc
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskIsLock(id)
|
||||||
|
local task = self.dailyTasks[id]
|
||||||
|
if task == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return task.lock
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskCanRefresh(id)
|
||||||
|
local cfg = self:getDailyTaskCfg()[id]
|
||||||
|
if cfg == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return cfg.ad_refresh
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskIcon(id)
|
||||||
|
local task = self.dailyTasks[id]
|
||||||
|
if task == nil then
|
||||||
|
return GConst.EMPTY_STRING
|
||||||
|
end
|
||||||
|
local cfg = self:getTaskCfg()
|
||||||
|
return cfg[task.taskId].icon
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskReward(id)
|
||||||
|
local task = self.dailyTasks[id]
|
||||||
|
if task == nil then
|
||||||
|
return GConst.EMPTY_STRING
|
||||||
|
end
|
||||||
|
local cfg = self:getTaskCfg()
|
||||||
|
return cfg[task.taskId].reward
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTasks()
|
||||||
|
return self.dailyTasks
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getTaskI18NCfg()
|
||||||
|
if self.taskI18NCfg == nil then
|
||||||
|
self.taskI18NCfg = I18N:getConfig("task")
|
||||||
|
end
|
||||||
|
return self.taskI18NCfg
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getTaskCfg()
|
||||||
|
if self.taskCfg == nil then
|
||||||
|
self.taskCfg = ConfigManager:getConfig("task")
|
||||||
|
end
|
||||||
|
return self.taskCfg
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getDailyTaskCfg()
|
||||||
|
if self.dailyTaskCfg == nil then
|
||||||
|
self.dailyTaskCfg = ConfigManager:getConfig("task_daily")
|
||||||
|
end
|
||||||
|
return self.dailyTaskCfg
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getTaskListByType(taskType)
|
||||||
|
return self.taskTypeMap[taskType] or GConst.EMPTY_TABLE
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:getIfCanClaimTask(task)
|
||||||
|
if task.claimed then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return task.progress <= task.needProgress
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:addTaskProgress(task, count)
|
||||||
|
local currProgress = task.progress
|
||||||
|
if currProgress >= task.needProgress then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local can = self:getIfCanClaimTask(task)
|
||||||
|
task.progress = task.progress + count
|
||||||
|
self:markDailyTaskDirty()
|
||||||
|
if not can and self:getIfCanClaimTask(task) then
|
||||||
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DAILY_TASK_ADD_PROGRESS, task.id, task.taskId, currProgress, task.needProgress)
|
||||||
|
BIReport:postDailyTaskFinish(BIReport.TASK_TYPE.DAILY, task.id, task.taskId, task.refresh)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:registerTask(taskType)
|
||||||
|
ModuleManager.TaskManager:registerTask(DATA_NAME, taskType, function(count)
|
||||||
|
local list = self:getTaskListByType(taskType)
|
||||||
|
if #list > 0 then
|
||||||
|
for _, task in ipairs(list) do
|
||||||
|
self:addTaskProgress(task, count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyTaskData:unregisterTask(taskType)
|
||||||
|
ModuleManager.TaskManager:unRegisterTask(DATA_NAME, taskType)
|
||||||
|
end
|
||||||
|
|
||||||
|
return DailyTaskData
|
||||||
10
lua/app/userdata/task/daily_task_data.lua.meta
Normal file
10
lua/app/userdata/task/daily_task_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 78418602370585e449e79da7a5f4345b
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -1,153 +0,0 @@
|
|||||||
local TaskData = class("TaskData", BaseData)
|
|
||||||
|
|
||||||
local DAILY_TASK_AD_ID = 1
|
|
||||||
local DAILY_TASK_FINAL_ID = 2
|
|
||||||
|
|
||||||
function TaskData:ctor()
|
|
||||||
self.data.dailyTaskDirty = false
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:init(data)
|
|
||||||
local tasks = data and data.tasks
|
|
||||||
local cfg = self:getDailyTaskCfg()
|
|
||||||
local taskCfg = self:getTaskCfg()
|
|
||||||
self.dailyTasks = {}
|
|
||||||
for k, v in pairs(cfg) do
|
|
||||||
local task = tasks and tasks[k] or GConst.EMPTY_TABLE
|
|
||||||
local taskInfo = taskCfg[task.task_id]
|
|
||||||
if taskInfo then
|
|
||||||
local dailyTaskObj = {
|
|
||||||
id = k,
|
|
||||||
taskId = task.task_id,
|
|
||||||
progress = task.progress,
|
|
||||||
needProgress = taskInfo.number,
|
|
||||||
refresh = task.refresh,
|
|
||||||
claimed = task.claimed,
|
|
||||||
type = v.type
|
|
||||||
}
|
|
||||||
if v.bounty then
|
|
||||||
dailyTaskObj.lock = true
|
|
||||||
end
|
|
||||||
self.dailyTasks[k] = dailyTaskObj
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:refreshDailyTask(task)
|
|
||||||
local taskInfo = self:getTaskCfg()[task.task_id]
|
|
||||||
if taskInfo == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local id = task.id
|
|
||||||
local dailyTaskObj = self.dailyTasks[id]
|
|
||||||
if dailyTaskObj == nil then
|
|
||||||
dailyTaskObj = {}
|
|
||||||
self.dailyTasks[id] = dailyTaskObj
|
|
||||||
end
|
|
||||||
-- 刷新任务的时候type不会变
|
|
||||||
dailyTaskObj.id = task.id
|
|
||||||
dailyTaskObj.taskId = task.task_id
|
|
||||||
dailyTaskObj.progress = task.progress
|
|
||||||
dailyTaskObj.needProgress = taskInfo.number
|
|
||||||
dailyTaskObj.refresh = task.refresh
|
|
||||||
dailyTaskObj.claimed = task.claimed
|
|
||||||
self:markDailyTaskDirty()
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getIsOpen()
|
|
||||||
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.TASK, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyResetTime()
|
|
||||||
return 86400 - Time:getServerTime() % 86400
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskAdId()
|
|
||||||
return DAILY_TASK_AD_ID
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskFinalId()
|
|
||||||
return DAILY_TASK_FINAL_ID
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:markDailyTaskDirty()
|
|
||||||
self.data.dailyTaskDirty = not self.data.dailyTaskDirty
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskProgress(id)
|
|
||||||
local task = self.dailyTasks[id]
|
|
||||||
if task == nil then
|
|
||||||
return 0, 1
|
|
||||||
end
|
|
||||||
return task.progress, task.needProgress
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskDesc(id)
|
|
||||||
local task = self.dailyTasks[id]
|
|
||||||
if task == nil then
|
|
||||||
return GConst.EMPTY_STRING
|
|
||||||
end
|
|
||||||
local cfg = self:getTaskI18NCfg()
|
|
||||||
return cfg[task.taskId].desc
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskIsLock(id)
|
|
||||||
local task = self.dailyTasks[id]
|
|
||||||
if task == nil then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
return task.lock
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskCanRefresh(id)
|
|
||||||
local cfg = self:getDailyTaskCfg()[id]
|
|
||||||
if cfg == nil then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return cfg.ad_refresh
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskIcon(id)
|
|
||||||
local task = self.dailyTasks[id]
|
|
||||||
if task == nil then
|
|
||||||
return GConst.EMPTY_STRING
|
|
||||||
end
|
|
||||||
local cfg = self:getTaskCfg()
|
|
||||||
return cfg[task.taskId].icon
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskReward(id)
|
|
||||||
local task = self.dailyTasks[id]
|
|
||||||
if task == nil then
|
|
||||||
return GConst.EMPTY_STRING
|
|
||||||
end
|
|
||||||
local cfg = self:getTaskCfg()
|
|
||||||
return cfg[task.taskId].reward
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTasks()
|
|
||||||
return self.dailyTasks
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getTaskI18NCfg()
|
|
||||||
if self.taskI18NCfg == nil then
|
|
||||||
self.taskI18NCfg = I18N:getConfig("task")
|
|
||||||
end
|
|
||||||
return self.taskI18NCfg
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getTaskCfg()
|
|
||||||
if self.taskCfg == nil then
|
|
||||||
self.taskCfg = ConfigManager:getConfig("task")
|
|
||||||
end
|
|
||||||
return self.taskCfg
|
|
||||||
end
|
|
||||||
|
|
||||||
function TaskData:getDailyTaskCfg()
|
|
||||||
if self.dailyTaskCfg == nil then
|
|
||||||
self.dailyTaskCfg = ConfigManager:getConfig("task_daily")
|
|
||||||
end
|
|
||||||
return self.dailyTaskCfg
|
|
||||||
end
|
|
||||||
|
|
||||||
return TaskData
|
|
||||||
Loading…
x
Reference in New Issue
Block a user