任务
This commit is contained in:
parent
482e1a2127
commit
09e3d41928
@ -2154,6 +2154,7 @@ function BattleController:battleEnd()
|
|||||||
self.battleUI:enableUITouch()
|
self.battleUI:enableUITouch()
|
||||||
end
|
end
|
||||||
self:controllBattleEnd()
|
self:controllBattleEnd()
|
||||||
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_BATTLE_VICTORY)
|
||||||
end, 1)
|
end, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -90,14 +90,14 @@ function TaskManager:clear()
|
|||||||
self.registerTaskInfo = nil
|
self.registerTaskInfo = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function TaskManager:addTaskProgress(type, params1)
|
function TaskManager:addTaskProgress(type, ...)
|
||||||
if not self.registerTaskInfo then
|
if not self.registerTaskInfo then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local func = TaskManager.TYPE_DEAL_FUNC[type]
|
local func = TaskManager.TYPE_DEAL_FUNC[type]
|
||||||
if func then
|
if func then
|
||||||
func(self, params1)
|
func(self, ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ 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:xWatchAd(params)
|
function TaskManager:xWatchAd()
|
||||||
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_WATCH_AD, 1)
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_WATCH_AD, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -134,11 +134,47 @@ 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:xGoldGot(count)
|
||||||
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_GOLD_GOT, count)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskManager:xGoldCost(count)
|
||||||
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_GOLD_COST, count)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskManager:xGemGot(count)
|
||||||
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_GEM_GOT, count)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskManager:xGemCost(count)
|
||||||
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_GEM_COST, count)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskManager:xBattleVictory()
|
||||||
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_BATTLE_VICTORY, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskManager:xHeroLvUp()
|
||||||
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TaskManager:xHeroFragmentGot(count)
|
||||||
|
self:dispatchTask(GConst.TaskConst.TASK_TYPE.X_HERO_FRAGMENT_GOT, count)
|
||||||
|
end
|
||||||
|
|
||||||
---- 没有特殊说明,方法均返回任务增量
|
---- 没有特殊说明,方法均返回任务增量
|
||||||
TaskManager.TYPE_DEAL_FUNC = {
|
TaskManager.TYPE_DEAL_FUNC = {
|
||||||
[GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER] = TaskManager.xKillMonster,
|
|
||||||
[GConst.TaskConst.TASK_TYPE.X_WATCH_AD] = TaskManager.xWatchAd,
|
[GConst.TaskConst.TASK_TYPE.X_WATCH_AD] = TaskManager.xWatchAd,
|
||||||
|
[GConst.TaskConst.TASK_TYPE.X_GOLD_GOT] = TaskManager.xGoldGot,
|
||||||
|
[GConst.TaskConst.TASK_TYPE.X_GEM_GOT] = TaskManager.xGemGot,
|
||||||
|
[GConst.TaskConst.TASK_TYPE.X_GOLD_COST] = TaskManager.xGoldCost,
|
||||||
|
[GConst.TaskConst.TASK_TYPE.X_GEM_COST] = TaskManager.xGemCost,
|
||||||
|
[GConst.TaskConst.TASK_TYPE.X_BATTLE_VICTORY] = TaskManager.xBattleVictory,
|
||||||
|
[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.COMPLETED_DALY_TASK] = TaskManager.completeDailyTask,
|
||||||
|
|
||||||
|
-- [GConst.TaskConst.TASK_TYPE.X_KILL_MONSTER] = TaskManager.xKillMonster,
|
||||||
}
|
}
|
||||||
|
|
||||||
function TaskManager:taskGoto(taskType)
|
function TaskManager:taskGoto(taskType)
|
||||||
|
|||||||
@ -134,17 +134,24 @@ function ItemData:addItem(data, itemGetType)
|
|||||||
|
|
||||||
self:_addItemNumById(data.id, data.count)
|
self:_addItemNumById(data.id, data.count)
|
||||||
|
|
||||||
if data.id == GConst.ItemConst.ITEM_ID_GEM or data.id == GConst.ItemConst.ITEM_ID_GOLD then
|
if data.id == GConst.ItemConst.ITEM_ID_GEM then
|
||||||
if data.count < 0 then
|
if data.count < 0 then
|
||||||
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_GEM_COST, -data.count)
|
||||||
BIReport:postGemUse(data.count, itemGetType, data.id)
|
BIReport:postGemUse(data.count, itemGetType, data.id)
|
||||||
else
|
else
|
||||||
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_GEM_GOT, data.count)
|
||||||
BIReport:postGemGet(data.count, itemGetType, data.id)
|
BIReport:postGemGet(data.count, itemGetType, data.id)
|
||||||
end
|
end
|
||||||
if data.id == GConst.ItemConst.ITEM_ID_GEM then
|
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("user_gem", data.count)
|
||||||
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("user_gem", data.count)
|
elseif data.id == GConst.ItemConst.ITEM_ID_GOLD then
|
||||||
elseif data.id == GConst.ItemConst.ITEM_ID_GOLD then
|
if data.count < 0 then
|
||||||
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("user_gold", data.count)
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_GOLD_COST, -data.count)
|
||||||
|
BIReport:postGemUse(data.count, itemGetType, data.id)
|
||||||
|
else
|
||||||
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_GOLD_GOT, data.count)
|
||||||
|
BIReport:postGemGet(data.count, itemGetType, data.id)
|
||||||
end
|
end
|
||||||
|
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("user_gold", data.count)
|
||||||
elseif data.id == GConst.ItemConst.ITEM_ID_VIT then
|
elseif data.id == GConst.ItemConst.ITEM_ID_VIT then
|
||||||
if data.count < 0 then
|
if data.count < 0 then
|
||||||
BIReport:postVitUse(data.count)
|
BIReport:postVitUse(data.count)
|
||||||
@ -179,11 +186,14 @@ function ItemData:_addItemNumById(id, num)
|
|||||||
if self.items[id] then
|
if self.items[id] then
|
||||||
self.items[id]:addNum(num)
|
self.items[id]:addNum(num)
|
||||||
else
|
else
|
||||||
if id == GConst.ItemConst.ITEM_ID_VIT then
|
if id == ItemConst.ITEM_ID_VIT then
|
||||||
DataManager.PlayerData:setVit(num)
|
DataManager.PlayerData:setVit(num)
|
||||||
end
|
end
|
||||||
self:_add(id, num)
|
self:_add(id, num)
|
||||||
end
|
end
|
||||||
|
if num > 0 and self.items[id]:getItemType() == ItemConst.ITEM_TYPE.HERO_FRAGMENT then
|
||||||
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_FRAGMENT_GOT, num)
|
||||||
|
end
|
||||||
if id == ItemConst.ITEM_ID_VIT and isFull then
|
if id == ItemConst.ITEM_ID_VIT and isFull then
|
||||||
local maxVit = DataManager.PlayerData:getMaxVit()
|
local maxVit = DataManager.PlayerData:getMaxVit()
|
||||||
local currentCount = DataManager.PlayerData:getVit()
|
local currentCount = DataManager.PlayerData:getVit()
|
||||||
|
|||||||
@ -72,11 +72,6 @@ function ItemEntity:getIconRes()
|
|||||||
return GConst.ATLAS_PATH.ICON_ITEM, self.config.icon
|
return GConst.ATLAS_PATH.ICON_ITEM, self.config.icon
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 类型
|
|
||||||
function ItemEntity:getType()
|
|
||||||
return GConst.ENTITY_TYPE.ITEM
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 其他参数
|
-- 其他参数
|
||||||
function ItemEntity:getParam()
|
function ItemEntity:getParam()
|
||||||
return self.config.parameter
|
return self.config.parameter
|
||||||
@ -92,8 +87,8 @@ function ItemEntity:getDesc()
|
|||||||
return I18N:getText("item", self.data.id, "desc")
|
return I18N:getText("item", self.data.id, "desc")
|
||||||
end
|
end
|
||||||
|
|
||||||
function ItemEntity:getEntityType()
|
function ItemEntity:getItemType()
|
||||||
return GConst.ENTITY_TYPE.ITEM_ENTITY
|
return self.config.type
|
||||||
end
|
end
|
||||||
|
|
||||||
return ItemEntity
|
return ItemEntity
|
||||||
@ -31,6 +31,7 @@ function HeroEntity:setLv(lv)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.data.lv = lv
|
self.data.lv = lv
|
||||||
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP)
|
||||||
self:setDirty()
|
self:setDirty()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -206,18 +206,21 @@ function DailyTaskData:getIfCanClaimTask(task)
|
|||||||
return task.progress <= task.needProgress
|
return task.progress <= task.needProgress
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyTaskData:addTaskProgress(task, count)
|
function DailyTaskData:addTaskProgress(task, taskType, count)
|
||||||
local currProgress = task.progress
|
local currProgress = task.progress
|
||||||
if currProgress >= task.needProgress then
|
if currProgress >= task.needProgress then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local can = self:getIfCanClaimTask(task)
|
local can = self:getIfCanClaimTask(task)
|
||||||
task.progress = task.progress + count
|
task.progress = task.progress + count
|
||||||
self:markDailyTaskDirty()
|
|
||||||
if not can and self:getIfCanClaimTask(task) then
|
if not can and self:getIfCanClaimTask(task) then
|
||||||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DAILY_TASK_ADD_PROGRESS, task.id, task.taskId, currProgress, task.needProgress)
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.DAILY_TASK_ADD_PROGRESS, task.id, task.taskId, currProgress, task.needProgress)
|
||||||
|
if task.type == 1 and task.reset == 1 and taskType ~= GConst.TaskConst.TASK_TYPE.COMPLETED_DALY_TASK then
|
||||||
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.COMPLETED_DALY_TASK)
|
||||||
|
end
|
||||||
BIReport:postDailyTaskFinish(BIReport.TASK_TYPE.DAILY, task.id, task.taskId, task.refresh)
|
BIReport:postDailyTaskFinish(BIReport.TASK_TYPE.DAILY, task.id, task.taskId, task.refresh)
|
||||||
end
|
end
|
||||||
|
self:markDailyTaskDirty()
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyTaskData:registerTask(taskType)
|
function DailyTaskData:registerTask(taskType)
|
||||||
@ -225,7 +228,7 @@ function DailyTaskData:registerTask(taskType)
|
|||||||
local list = self:getTaskListByType(taskType)
|
local list = self:getTaskListByType(taskType)
|
||||||
if #list > 0 then
|
if #list > 0 then
|
||||||
for _, task in ipairs(list) do
|
for _, task in ipairs(list) do
|
||||||
self:addTaskProgress(task, count)
|
self:addTaskProgress(task, taskType, count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user