源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

3600 行
115 KiB

TaskModel = TaskModel or BaseClass(BaseVo)
local TaskModel = TaskModel
--任务内容类型定义,任务后台有配置
TaskTipType=
{
TYPE0=0, --开始对话
TYPE1=1, --击败怪物
TYPE2=11, --完成副本
TYPE6=3, --收集物品(打怪)
TYPE7=5, --与npc对话
TYPE8= 6, --开始对话(不可选)
TYPE9=7, --结束对话(不可选)
TYPE16=12,-- 探索场景
TYPE18=4,-- 采集
-- TYPE41=18,--天命觉醒点亮星格
TYPE80=80,--断级主线
TYPE100 = 2, --击杀boss
TYPE101 = 8, --强化装备
TYPE102 = 9, --完成某类型副本
TYPE103 = 10, --单次发条密室副本中获得x经验
TYPE104 = 13, --添加好友
TYPE105 = 14, --加入社团
TYPE106 = 15, --社团装备回收
TYPE107 = 16, --完成社团活动
TYPE108 = 17, --捐献一件装备到社团仓库
TYPE109 = 19, --从市场购买
TYPE110 = 20, --在市场上架一个物品
TYPE111 = 21, --符文之塔
TYPE23 = 23, --物品合成
TYPE24 = 24, --每日活跃度达到XXX点
TYPE25 = 25, --五转天命星格觉醒
TYPE26 = 26, --装备吞噬
TYPE27 = 27, --击杀指定Boss
TYPE28 = 28, --钓鱼之路
TYPE29 = 29, --进入完成某个副本
TYPE31 = 31, --竞技场次数
TYPE34 = 34, --进入完成某类副本
TYPE35 = 35, --可选对话任务
TYPE36 = 36, --装备附能
TYPE37 = 37, --副本波数进度
TYPE38 = 38, --送信任务
TYPE39 = 39, --装备升星
TYPE40 = 40, --商城购买
-------------------------9.16新增
TYPE41 = 41, --好友送礼
TYPE42 = 42, --好友亲密度
TYPE43 = 43, --进阶系统升级
TYPE44 = 44, --升品之路
TYPE45 = 45, --唤神升级
TYPE46 = 46, --星辰升级
TYPE47 = 47, --宠物升级
TYPE48 = 48, --晒娃
TYPE49 = 49, --装备圣物
TYPE50 = 50, --圣物寻宝
TYPE51 = 51, --解锁地狱摩托
TYPE52 = 52, --转职目标
-------------------------
TYPE53 = 53, --龙神抽奖
TYPE54 = 54, --装备套装
TYPE55 = 55, --战魂强化
TYPE56 = 56, --进阶目标(进阶到一定阶数)
TYPE57 = 57, --完成预期任务
TYPE58 = 58, --宝宝同心值
TYPE59 = 59, --战力
TYPE60 = 60, --任意主动技能升级次数
TYPE61 = 61, --指定商店购买技能书
TYPE62 = 62, --任意商店技能书购买
TYPE1002 = 1002, --成就任务
TYPE1004 = 1004, --七日目标
TYPE9998 = 9998, --客户端自定义日常类型
}
--任务类型
TaskType =
{
MAIN_LINE=1, --主线任务
EXTENSION_LINE=2, --支线任务
TRUN_LINE=3, --转职任务
LIMIT_LINE=4, --限时任务
PSIONIC_LINE=5, --圣物任务
GUILD_LINE=6, --社团任务
BOUNTY_LINE=7, --赏金任务
ACTIVITY_LINE=8, --活跃度任务
---------------------------------
TREASURE = 1001, --藏宝图任务
ACHIEVE = 1002, --成就任务
DAILY_ACTIVITE = 1003, --日常活跃任务
SEVEN_DAY_TARGET = 1004, -- 七日目标任务
}
--任务种类
TaskKind =
{
TALK_KIND=0, --对话任务
KILL_MONSTER_KIND=1, --杀怪任务
COLLECT_KIND=2, --收集任务
CAI_JI_KIND=3, --收集任务
HU_SONG_KIND=4, --护送任务
TAN_SUO_KIND=5, --探索任务
DUN_KIND = 6, --副本任务
ITEM_BACK = 7, --收集回收任务
STREN = 8, --装备精炼任务
RUNE_DUN = 9, --符文副本任务
EXP_DUN = 10, --发条密室任务
}
TaskModel.TaskTypeStr =
{
[TaskType.MAIN_LINE]="主线",
[TaskType.EXTENSION_LINE]="支线",
[TaskType.TRUN_LINE]="转职",
[TaskType.LIMIT_LINE]="限时",
[TaskType.GUILD_LINE]="社团",
[TaskType.BOUNTY_LINE]="日常",
[TaskType.PSIONIC_LINE]="圣物",
[TaskType.ACTIVITY_LINE]="活跃",
}
TaskModel.TaskTypeStr3 =
{
[TaskType.MAIN_LINE]="主线",
[TaskType.EXTENSION_LINE]="支线",
[TaskType.TRUN_LINE]="转职",
[TaskType.LIMIT_LINE]="限时",
[TaskType.GUILD_LINE]="社团",
[TaskType.BOUNTY_LINE]="日常",
[TaskType.PSIONIC_LINE]="圣物",
[TaskType.ACTIVITY_LINE]="活跃",
}
TaskModel.TaskTypeStr2 =
{
[TaskType.MAIN_LINE]="主线",
[TaskType.EXTENSION_LINE]="支线",
[TaskType.TRUN_LINE]="转职",
[TaskType.LIMIT_LINE]="限时",
[TaskType.GUILD_LINE]="社团",
[TaskType.BOUNTY_LINE]="日常",
[TaskType.PSIONIC_LINE]="圣物",
[TaskType.ACTIVITY_LINE]="活跃",
[TaskType.TREASURE]="宝图",
[TaskType.ACHIEVE]="成就",
[TaskType.DAILY_ACTIVITE]="活跃",
}
TaskModel.Color =
{
WHITE= "#ffffff",
GREEN = "#2CF66F",
PINK = "#F257FC",
YELLOW ="#FBB73F",
ORANGE="#ffb346",
BLUE = "#65A9FC"
}
TaskModel.ColorNoSymbols =
{
WHITE= Color(1, 1, 1, 1),
GREEN = Color(44/255, 246/255, 44/255, 1),
PINK = Color(242/255, 87/255, 252/255, 1),
YELLOW = Color(251/255, 183/255, 63/255, 1),
ORANGE= Color(255/255, 179/255, 70/255, 1),
BLUE = Color(101/255, 169/255, 252/255, 1),
}
TaskModel.TaskPrefixIdStr =
{
[3070001]= {str = "推荐", color = TaskModel.Color.ORANGE},
[3070002]= {str = "日常", color = TaskModel.Color.ORANGE},
}
TaskModel.QualityColor = {
[0] = TaskModel.Color.WHITE,
[1] = TaskModel.Color.GREEN,
[2] = TaskModel.Color.BLUE,
[3] = TaskModel.Color.PINK,
[4] = TaskModel.Color.YELLOW,
[5] = TaskModel.Color.ORANGE,
}
TaskModel.ColorToImg = {
[TaskModel.Color.WHITE] = "task_item_color_green",
[TaskModel.Color.GREEN] = "task_item_color_green",
[TaskModel.Color.BLUE] = "task_item_color_blue",
[TaskModel.Color.PINK] = "task_item_color_pink",
[TaskModel.Color.YELLOW] = "task_item_color_orange",
[TaskModel.Color.ORANGE] = "task_item_color_orange",
}
--转职任务,boss战 的任务id
TaskModel.TaskTurnBossTaskId =
{
[5] = true,
[10] = true,
[15] = true,
[20] = true,
[25] = true,
}
--转职任务,boss战 推荐战力
TaskModel.TaskTurnBossPower =
{
[5] = 250000,
[10] = 1250000,
[15] = 4500000,
[20] = 12500000,
[25] = 25000000,
}
--任务类型27,击杀类型(每个类型自己配置)
TaskModel.TYPE27_KILL_TYPE =
{
[1] = 3, --赏金boss
}
TaskModel.FirstTaskId = 10010 --第一个任务id
TaskModel.DragonTaskId = 10000100 --飞龙任务
TaskModel.ADD_SPEED_DISTANCE = 7 --加速距离
TaskModel.ShowArrowLv = 50 --显示任务提示箭头的等级
TaskModel.AutoDoNewMainTaskLv = 96 --一定等级以下,收到30000协议会主动优先执行主线任务
TaskModel.AutoOpViewStopTask = 100 --一定等级以下,打开特殊界面要停止任务
function TaskModel:__init()
TaskModel.Instance = self
self:InitData()
end
function TaskModel:InitData( )
self._receivedTaskList={}
self._canTaskList={}
self.all_task_list = {}
self.circle_task_info = {} ----社团/赏金任务进度
self.circle_cache_reward = nil --完成的奖励
self.need_show_circle_tip = false --弹出跑环tip
self.lask_bounty_process = nil --上一次完成的赏金任务进度
self.lask_guild_process = nil --上一次完成的社团任务进度
self.now_task_id = nil -- 同个npc下面可能同时会有主线和支线任务,12101协议任务数据可能会有2条,这样客户端就不知道应该选择哪个任务来触发相关操作, 所以在开始任务前,客户端先记下当前任务id
self.game_start_request = true --游戏启动,要请求一次任务数据
self.followNpcList = nil --跟随npc
self.last_task_id_cache = nil --保存上一个完成的任务id
self.last_task_type_cache = nil --保存上一个完成的任务类型
self.is_auto_task = false --是否正在自动任务,点击任务后设为true,点取消挂机后设为false
self.need_do_task_type = 0 --需要马上做的任务类型,用于赏金或社团任务,因为这两种类型的接任务过程不通用
self.last_time = 0 --上次直接完成任务的时间
self.is_stop = false --任务是否暂停
self.default_task_arrow_list = {}--断级主线任务已显示箭头列表
self.first_receive = false --第一次收到30000
self.need_task = false --切场景后要寻路的数据
self.need_accept = nil --需要升级接的任务, 一般是自动接的任务,要等升级了才能自动接
self.last_finish_task_id = 0 --上一个完成的任务
self.scmd12101Send = false --做完任务,有时服务端推12101过来,这种情况就忽略掉,不处理
self.proto_count = 0 --必须等12005和12002返回才能继续寻路
self.wait_30003 = false
self.wait_30004 = false
self.last_task_scene = nil
self.need_open_rein = false --需要打开转职界面
self.accept_power_task_id = false --接取到战力引导任务的id
self.first_trigger_0 = false --触发标志,只有第一次触发才滚动任务栏
self.first_trigger_1 = false
self.first_trigger_2 = false
self.first_trigger_3 = false
self.first_trigger_4 = false
self.wait_upgrade = false --等待升级后先做主线
-- self.opening_circle_buy_tip = false--快速跑环任务界面展示中
-- self.wait_circle_buy_tip_close = false--花钱跑环任务的话,停止当前任务,等界面关闭时再继续任务
self.circle_auto_use_shoe = {}--非R玩家跑环执行的时候,需要记录是否自动小飞鞋
self.circle_use_clock = false--第一次不用倒计时,点击确定按钮之后使用,中断跑环流程的时候重置不用倒计时
self.need_check_monster = false
self.is_dungeon_finish = false
self.fly_shoe_end_need_task = false
self.collect_task_id = false --收集任务的配置了多个点,使用飞鞋的时候需要使用上次选中的点
self.finish_task_list = {} --已完成任务列表
self.no_main_task_level = 0 --断级时当前主线任务对应的等级,用作标识是否弹可登录提示,同一个等级只触发弹一次可挑战提示(刚好触发断级的那一刻)
self.temp_finish_task_info = {}--标记完成的表,每次有新的已完成任务的时候,就把任务栏滚动容器位置置顶
self:InitTaskListenList()
self.guild_kill_monster_num = 0--断击杀非主线怪物一定数量之后,拉玩家去做主线,每次调用进行任务的时候清零,20001返回的时候累计
self.is_first_login_game_to_do_task = true --是否是第一次登陆游戏做任务
self.is_auto_tip_new_main_line = nil --是否是自动滚动导致关掉提示引导
self.cur_tips_daily_task_item = false --当前推荐的日常活跃任务
self.recorded_finish_turn_task_lv = RoleManager.Instance.mainRoleInfo.level -- 上次完成转职任务的等级记录
end
--[[@
功能: 初始化任务侦听列表,需要触发完成回调的任务,需要往这里添加
任务完成时刻,会在此列表里检索,id存在的,才会触发任务完成事件,避免大部分冗余运算
事件:GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST, on_task_finish)
参数: 无
返回值: 无
]]
function TaskModel:InitTaskListenList( )
--所有需要侦听的任务列表
self.task_listen_list = {}
--功能开启配置
for k,v in pairs(Config.Moduleid) do
if v.task_id ~= 0 then
self.task_listen_list[v.task_id] = true
end
end
for k,v in pairs(Config.Modulesub) do
if v.task_id ~= 0 then
self.task_listen_list[v.task_id] = true
end
end
--任务引导配置
for k,v in pairs(Config.ConfigHelper.Task) do
if k and k ~= 0 then
self.task_listen_list[k] = true
end
end
--羁绊任务
for k,v in pairs(MateConst.SingleDogTask) do
self.task_listen_list[v] = true
end
--剧情
for k,v in pairs(Config.ConfigTaskEffect.TaskStoryID) do
self.task_listen_list[k] = true
end
--摩托解锁任务
for k,v in pairs(NewerTaskConst.PartTaskId) do
self.task_listen_list[k] = true
end
--章节最后一个任务
self.task_listen_list[Config.ConfigTaskEffect.LastChapterTaskId] = true
--经验副本限制红点展示任务
self.task_listen_list[ExpDunModel.Newly_Limit_Taskid] = true
-- 宝宝开启任务
self.task_listen_list[Config.Moduleid[165].task_id] = true
-- 首充打开任务添加
self.task_listen_list[CustomActivityModel.FIRST_RECHARGE_TASK_ID] = true
--首充广告界面
self.task_listen_list[CustomActivityModel.FIRST_RECHARGE_TIP_TASK_ID] = true
--招财猫
self.task_listen_list[CustomActivityModel.CAT_FOTANA_TASK_ID] = true
--七日登陆
self.task_listen_list[CustomActivityModel.SEVEN_LOGIN_TASK_ID] = true
--VIP体验卡
self.task_listen_list[CustomActivityModel.VIP_EX_CARD_TASK_ID] = true
--V3强弹
for i,v in ipairs(CustomActivityModel.VIP_THREE_TASK_ID_LIST) do
self.task_listen_list[v] = true
end
end
function TaskModel:GetDefalutTaskCurTaskAndDes()
--主线断层增加任务提示:活跃度提示,经验副本,经验跑环,社团跑环
local is_can_do_daily_task = false
local is_guild = RoleManager.Instance.mainRoleInfo and RoleManager.Instance.mainRoleInfo.guild_id>0
local is_can_do_guild_task = false
local is_can_do_exp_dun = false
local is_open_daily = false
local daily_task_info = TaskModel:getInstance():GetTaskByType(TaskType.BOUNTY_LINE)
local guild_task_info = TaskModel:getInstance():GetCircleTaskInfo(TaskType.GUILD_LINE)
local live = DailyModel.Instance:GetLivenessInfoLive()
-- if live < 10 then
-- is_open_daily = true
if daily_task_info then
is_can_do_daily_task = true
elseif live < 120 then
is_open_daily = true
elseif ExpDunModel:getInstance():GetNextWaveFitPowerRed() and ExpDunModel:getInstance():GetNextWaveFitLevel() then
is_can_do_exp_dun = true
-- elseif guild_task_info.cur_progress < 10 then
-- is_can_do_guild_task = true
-- elseif ExpDunModel:getInstance():GetNextWaveFitLevel() then
-- is_can_do_exp_dun = true
-- elseif guild_task_info.cur_progress < 20 then
-- is_can_do_guild_task = true
else
is_open_daily = true
end
local content = "<color=#ff3232><u>查看升级途径</u></color>"
-- if is_open_daily then
-- content = "推荐完成<color=#2CF66F>日常活跃</color>"
if is_can_do_daily_task then
content = "完成<color=#2CF66F>经验跑环</color>"
-- elseif is_can_do_guild_task then
-- content = "推荐完成<color=#2CF66F>社团跑环</color>"
elseif is_can_do_exp_dun then
content = "闯关<color=#2CF66F>经验闯关</color>"
else
if self.cur_tips_daily_task_item then
content = string.format("推荐<color=#2CF66F>%s</color>", self.cur_tips_daily_task_item.name)
else
content = "推荐进行日常任务"
end
end
return is_open_daily, is_can_do_daily_task, is_can_do_guild_task, is_can_do_exp_dun, content
end
function TaskModel:__delete( )
self:StopLoginTaskTimer()
end
function TaskModel:DefaultTask()
local temp = nil
local playerLv = RoleManager:getInstance():GetMainRoleVo().level
--任务做了特殊处理
if 53 < playerLv and playerLv < 56 then
temp = ConfigItemMgr.Instance:GetTaskData(10540)
else
temp = ConfigItemMgr.Instance:GetTaskData(self.last_finish_task_id)
end
if temp then
local data = ConfigItemMgr.Instance:GetTaskData(temp.next)
if data then
--主线断层增加任务提示:活跃度提示,经验副本,经验跑环,社团跑环
local is_open_daily, is_can_do_daily_task, is_can_do_guild_task, is_can_do_exp_dun, content = self:GetDefalutTaskCurTaskAndDes()
local lv = data.level
local _nextMain=TaskVo.New()
_nextMain.mainTip=true --假任务唯一的属性
_nextMain.acceptType=1
_nextMain.id = Config.ConfigTaskEffect.DefaultTaskId
_nextMain.level = lv
_nextMain.sortKey = Config.ConfigTaskEffect.TaskTypeSort[99]
_nextMain.type = TaskType.MAIN_LINE
_nextMain.order = 0
local cfg = Config.ConfigTaskEffect.NextTaskName
local task_name
if cfg[lv] then
task_name = cfg[lv]
else
task_name = string.format("升级到%s级", lv)
end
_nextMain.taskName = task_name or ""
_nextMain.description = string.format("等级提升到<color=#2CF66F>%s</color>级,打开活动界面,里面有各种日常活动,奖励多多。", lv)
_nextMain.tipContent = content
local tasktipvo3 = TaskTipsVo.New()
tasktipvo3.type = TaskTipType.TYPE80
_nextMain.taskTips = {tasktipvo3}
_nextMain.is_can_do_daily_task = is_can_do_daily_task
_nextMain.is_can_do_guild_task = is_can_do_guild_task
_nextMain.is_can_do_exp_dun = is_can_do_exp_dun
_nextMain.is_open_daily = is_open_daily
self._nextMain=_nextMain
--断级时弹一次可挑战提示 记录当前断级的任务等级,同个任务等级断级只弹一次提示
if data.level ~= self.no_main_task_level then --触发断级,上线的触发会直接无视
-- BaseDungeonModel:getInstance():CheckDungeonTip()--断级的副本可挑战提示屏蔽
end
self.no_main_task_level = data.level
else
self._nextMain = nil
end
end
end
function TaskModel:getInstance()
if TaskModel.Instance == nil then
TaskModel.New()
end
return TaskModel.Instance
end
--返回登录,清除缓存数据,
function TaskModel:ClearData()
self:InitData()
end
--获取任务面板的选项卡设置
function TaskModel:GetTabData(task_type)
local data = {}
for k,v in pairs(self.all_task_list) do
--进度排序
if self:IsNeedClickTask(v) then
local tip = self:GetExtendSpecialTip(v)
if tip and tip.isFinish==1 then
v.progressState = 1
else
v.progressState = 0
end
else
if v.target_num and v.target_num>0 then
v.progressState = self:IsTaskProgressFinish(v) and 1 or 0
else
v.progressState = 0
end
end
end
self.all_task_list = self:SortFun(self.all_task_list)
for i,v in ipairs(self.all_task_list) do
if v.type == task_type then
table.insert(data, v)
end
end
return data
end
--根据id获取任务
function TaskModel:GetTaskById( task_id )
for k,v in pairs(self.all_task_list) do
if v.id == task_id then
return v
end
end
end
--获取已接的一个任务 根据任务类型
function TaskModel:GetTaskByType( task_type , show)
for k,v in pairs(self._receivedTaskList) do
if v.type == task_type then
return v, 1
end
end
--转职还要判断可接
if task_type == TaskType.TRUN_LINE then
for k,v in pairs(self._canTaskList) do
if v.type == task_type then
return v, 2
end
end
end
end
--获取当前正在做的任务
function TaskModel:GetCurTask( )
if self.now_task_id then
for k,v in pairs(self.all_task_list) do
if v.id == self.now_task_id then
return v
end
end
--判断是否赏金或者社团任务, 用于寻路
if self.now_task_id == Config.ConfigTaskEffect.bountyTaskTipId then
return self:GetBountyTipTask()
elseif self.now_task_id == Config.ConfigTaskEffect.guildTaskTipId then
return self:GetGuildTipTask()
end
end
end
--获取主界面上的任务推送数据 need_handle:是否需要把可接支线合并起来
function TaskModel:GetMainUITaskData(need_handle)
local is_guild = RoleManager.Instance.mainRoleInfo and RoleManager.Instance.mainRoleInfo.guild_id>0
-------------------------
local list = {}
local main = false
local extension = false
local daily = false
local other = false
local extension_num = 0 --可接支线数量
local turn = false -- 2020年2月19日新增:转职任务
local tmp = {}
for i,v in ipairs(self._receivedTaskList) do
if v.type == TaskType.MAIN_LINE then
if main == false then
main = true
table.insert(tmp, v)
end
elseif v.type == TaskType.EXTENSION_LINE then
table.insert(list, v)
elseif v.type == TaskType.BOUNTY_LINE then
--日常任务显示id(完成这个任务才显示)
local is_show_task_finish = TaskModel:getInstance():IsTaskFinished(Config.ConfigTaskEffect.DailyCircleShowTaskId)
if is_show_task_finish then
if not self:GetCircleExtraTask( TaskType.BOUNTY_LINE ) then
table.insert(list, v)
end
end
elseif v.type == TaskType.GUILD_LINE then
if is_guild then
if not self:GetCircleExtraTask( TaskType.GUILD_LINE ) then
table.insert(list, v)
end
end
elseif v.type == TaskType.LIMIT_LINE then
table.insert(list, v)
elseif v.type == TaskType.TRUN_LINE then
if turn == false then
table.insert(list, v)
turn = true
end
elseif v.type == TaskType.PSIONIC_LINE then -- 圣物任务不显示
-- table.insert(list, v)
else
if other == false then
other = true
table.insert(list, v)
end
end
end
for i,v in ipairs(self._canTaskList) do
if v.type == TaskType.MAIN_LINE then
if main == false then
main = true
table.insert(tmp, v)
end
elseif v.type == TaskType.EXTENSION_LINE then
table.insert(list, v)
-- if not need_handle then
-- v.sortKey = Config.ConfigTaskEffect.TaskTypeSort[98] --可接支线的排序
-- table.insert(list, v)
-- end
-- extension_num = extension_num + 1
elseif v.type == TaskType.BOUNTY_LINE then
table.insert(list, v)
elseif v.type == TaskType.GUILD_LINE then
if is_guild then
table.insert(list, v)
end
elseif v.type == TaskType.LIMIT_LINE then
table.insert(list, v)
elseif v.type == TaskType.TRUN_LINE then
if turn == false then
v.order = 501
table.insert(list, v)
turn = true
end
elseif v.type == TaskType.PSIONIC_LINE then
-- table.insert(list, v)
else
if other == false then
other = true
table.insert(list, v)
end
end
end
--[[--插入可接的赏金任务和社团任务(需求修改,不需要插入假任务)
local taskVo = self:GetBountyTipTask()
if taskVo then
table.insert(list, taskVo)
end
taskVo = self:GetGuildTipTask()
if taskVo then
if is_guild then
table.insert(list, taskVo)
end
end--]]
--要插入跑环的十环领取任务
local taskVo = self:GetCircleExtraTask( TaskType.BOUNTY_LINE )
if taskVo then
table.insert(list, taskVo)
end
local taskVo = self:GetCircleExtraTask( TaskType.GUILD_LINE )
if taskVo then
table.insert(list, taskVo)
end
local taskVo = false
if turn == false then
taskVo = self:GetTurnTipTask()
if taskVo then
table.insert(list, taskVo)
end
end
if GetModuleIsOpen(424) then -- 藏宝图任务
local normal_treasure_task = self:GetTreasureTask(TreasureMapConst.Normal) -- 普通藏宝任务
if normal_treasure_task then
table.insert(list, normal_treasure_task)
end
local advance_treasure_task = self:GetTreasureTask(TreasureMapConst.Advance) -- 高级藏宝任务
if advance_treasure_task then
table.insert(list, advance_treasure_task)
end
end
-- --合并支线
-- if extension_num > 0 then
-- local taskVo = TaskVo.New()
-- taskVo.level = 1
-- local str = TaskModel.TaskTypeStr3[TaskType.EXTENSION_LINE]
-- taskVo.description = string.format("<color=#2CF66F>有%d个可接取的支线任务</color>", extension_num)
-- taskVo.taskName = string.format("%s任务", str)
-- taskVo.type = TaskType.EXTENSION_LINE
-- taskVo.isTipTask = true
-- taskVo.need_find_way = 1
-- taskVo.target_num = 0
-- taskVo.order = 0
-- taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[98]
-- taskVo.id = Config.ConfigTaskEffect.extentTaskTipId
-- taskVo.tipContent = string.format("有%d个可接取的支线任务", extension_num)
-- table.insert(list, taskVo)
-- end
for k,v in pairs(list) do
if self:IsNeedClickTask(v) then
local tip = self:GetExtendSpecialTip(v)
if tip and tip.isFinish==1 then
v.progressState = 1
else
v.progressState = 0
end
else
if v.target_num>0 then
v.progressState = self:IsTaskProgressFinish(v) and 1 or 0
else
v.progressState = 0
end
end
end
for i,v in ipairs(tmp) do
table.insert(list, 1, v)
end
--几个婚姻任务不显示
for a,b in pairs(MateConst.SingleDogTask) do
for i=#list,1,-1 do
if b == list[i].id then
table.remove(list, i)
break
end
end
end
self:SetDailyActiviteTaskVo( list )
-- 推荐成就以及可领奖成就(暂时不显示在任务面板)
--self:SetAchiTaskVo( list )
-- 七日目标
-- self:SetSevenTargetTaskVo(list)
list = self:SortFun(list)
-------------------------
--需要维护一个本地活动标记完成的表,每次有新的已完成任务的时候,就把任务栏滚动容器位置置顶
local cur_temp_finish_task_info = {}
local need = false
for k,v in pairs(list) do
if v.acceptType==0 and self:IsTaskProgressFinish(v) then
if v.type ~= TaskType.MAIN_LINE then
cur_temp_finish_task_info[v.id] = true
end
end
-- 成就类要加个id
if v.type == TaskType.ACHIEVE and
v.progress_data and v.progress_data.status == 1 then
if not cur_temp_finish_task_info[v.achieve_id] then
cur_temp_finish_task_info[v.achieve_id] = true
need = true
end
end
end
for k,v in pairs(cur_temp_finish_task_info) do
if not self.temp_finish_task_info[k] then
need = true
end
self.temp_finish_task_info[k] = true
end
if need then
self:Fire(TaskEvent.SHOW_SCROLL_TO_TOP)
end
-------------------------
return list
end
--任务的排序
function TaskModel:SortFun(list)
for k,v in pairs(list) do
if v.tipType then
v.tipTypeSort = Config.ConfigTaskEffect.TaskContentTypeSort[v.tipType] or 0
else
v.tipTypeSort = 0
end
v.sortKey = v.sortKey or 99
end
-------------------------
local func_open_list = {} --功能开放性任务
for i=#list, 1, -1 do
if self:IsFuncOpenTask(list[i]) then
table.insert( func_open_list, table.remove(list,i) )
end
end
local high_order_list = {} --高排序型任务
for i=#list, 1, -1 do
if self:IsHighOrderTask(list[i]) then
table.insert( high_order_list, table.remove(list,i) )
end
end
local main_line_list = {}--主线或者升级指引
for i=#list, 1, -1 do
if list[i].type == TaskType.MAIN_LINE then
table.insert( main_line_list, table.remove(list,i) )
end
end
local over_list = {}--可领取的任务
for i=#list, 1, -1 do
if list[i].progressState == 1 then
table.insert( over_list, table.remove(list,i) )
end
end
local buy_gods_line_list = {}--购买型支线
for i=#list, 1, -1 do
if self:IsBuyGoodsTaskFinished(list[i]) then
table.insert( buy_gods_line_list, table.remove(list,i) )
end
end
--护送任务双倍的时候,提高优先级
local escord_task_list = {}
if EscortModel.getInstance():CurTimeIsDouble() then
for i=#list, 1, -1 do
if self:IsDailyActiviteEscortTask(list[i]) then
table.insert( escord_task_list, table.remove(list,i) )
break
end
end
end
local daily_line_list = {}--经验跑环任务
for i=#list, 1, -1 do
if list[i].type == TaskType.BOUNTY_LINE then
table.insert( daily_line_list, table.remove(list,i) )
end
end
for i=#list, 1, -1 do --社团跑环任务
if list[i].type == TaskType.GUILD_LINE then
table.insert( daily_line_list, table.remove(list,i) )
end
end
local second_order_list = {} --第二排序序型任务
for i=#list, 1, -1 do
if self:IsSecondOrderTask(list[i]) then
table.insert( second_order_list, table.remove(list,i) )
end
end
local daily_activite_list = {} --日常活跃任务
for i=#list, 1, -1 do
if self:IsDailyActiviteTask(list[i]) then
table.insert( daily_activite_list, table.remove(list,i) )
end
end
local third_order_list = {} --第三排序序型任务
for i=#list, 1, -1 do
if self:IsThirdOrderTask(list[i]) then
table.insert( third_order_list, table.remove(list,i) )
end
end
-------------------------
local arg = {"sortKey","progressState","order","acceptType","id"}
local condition = {Array.LOWER,Array.UPPER,Array.UPPER, Array.LOWER,Array.LOWER,}
SortTools.MoreKeysSorter(func_open_list, arg, condition)
SortTools.MoreKeysSorter(high_order_list, arg, condition)
SortTools.MoreKeysSorter(main_line_list, arg, condition)
SortTools.MoreKeysSorter(buy_gods_line_list, arg, condition)
SortTools.MoreKeysSorter(second_order_list, arg, condition)
SortTools.MoreKeysSorter(daily_activite_list, arg, condition)
SortTools.MoreKeysSorter(third_order_list, arg, condition)
SortTools.MoreKeysSorter(over_list, arg, condition)
SortTools.MoreKeysSorter(list, arg, condition)
-------------------------
local end_list = {}
for i,v in ipairs(func_open_list) do table.insert( end_list, v ) end
for i,v in ipairs(high_order_list) do table.insert( end_list, v ) end
for i,v in ipairs(main_line_list) do table.insert( end_list, v ) end
for i,v in ipairs(over_list) do table.insert( end_list, v ) end
for i,v in ipairs(buy_gods_line_list) do table.insert( end_list, v ) end
for i,v in ipairs(escord_task_list) do table.insert( end_list, v ) end
for i,v in ipairs(daily_line_list) do table.insert( end_list, v ) end
for i,v in ipairs(second_order_list) do table.insert( end_list, v ) end
for i,v in ipairs(daily_activite_list) do table.insert( end_list, v ) end
for i,v in ipairs(third_order_list) do table.insert( end_list, v ) end
for i,v in ipairs(list) do table.insert( end_list, v ) end
return end_list
end
-- 任务描述内容拼接
function TaskModel:MakeTaskTip(taskVO)
if taskVO == nil then return end
if taskVO.mainTip == true then --假任务
--下一个有任务的等级
self:DefaultTask()
taskVO.tipParam={}
return
end
for key, taskTipVO in ipairs(taskVO.taskTips) do
if (taskTipVO.isFinish==0 or key==#taskVO.taskTips) then
if taskTipVO.type == TaskTipType.TYPE0 then
--通用寻路
self:makeFindType(taskVO, taskTipVO)
--显示数量
if taskVO.target_num > 0 then
taskVO.tipContent=taskVO.tipContent.."<color="..TaskModel.Color.WHITE..">("..taskVO.cur_num.."/"..taskVO.target_num..")</color>"
end
elseif taskTipVO.type == TaskTipType.TYPE1 then--击败怪物
self:makeType1(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE2 or taskTipVO.type == TaskTipType.TYPE29 then--完成副本
self:makeType2(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE34 then
self:makeType34(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE6 then--收集物品(打怪)
self:makeType6(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE16 then--探索场景
self:makeType16(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE18 then--采集
self:makeType18(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE7 or taskTipVO.type == TaskTipType.TYPE8
or taskTipVO.type == TaskTipType.TYPE9 or taskTipVO.type == TaskTipType.TYPE35
or taskTipVO.type == TaskTipType.TYPE38 then --与npc对话
self:makeType7(taskVO, taskTipVO)
-- --显示数量
-- if taskVO.target_num > 0 then
-- taskVO.tipContent=taskVO.tipContent.."<color="..ColorUtil.WHITE..">("..taskVO.cur_num.."/"..taskVO.target_num..")</color>"
-- end
elseif taskTipVO.type == TaskTipType.TYPE100 then --击败boss
self:makeType100(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE109 or taskTipVO.type == TaskTipType.TYPE110 then --市场上架 市场购买
self:makeType109(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE102 then --完成某副本类型
self:makeType102(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE103 then --单次副本获得x经验
self:makeType103(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE106 then --提交装备
self:makeType106(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE107 then --完成社团活动
self:makeType107(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE23 then --合成物品
self:makeType23(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE24 then --活跃度
self:makeType24(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE104 then --添加好友
self:makeType104(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE26 then --装备吞噬
self:makeType26(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE27 then --击杀首领
self:makeType27(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE28 then --钓鱼活动
self:makeType28(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE29 then --烹饪活动
self:makeType29(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE111 then --符文爬塔
self:makeType111(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE36 then --装备附能
self:makeType36(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE37 then --副本波数进度
self:makeType37(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE101 then --强化装备
self:makeType101(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE31 then --竞技场次数
self:makeType31(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE39 then --装备升星
self:makeType39(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE40 then --交易券购买
self:makeType40(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE42 then --好感度
self:makeNormalType2(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE44 then --升品之路
self:makeNormalType2(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE49 then --圣物装备
self:makeNormalType2(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE51 then --解锁地狱摩托
self:makeType51(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE53 then --龙神抽奖
self:makeType53(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE54 then --装备套装
self:makeType54(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE55 then --战魂强化
self:makeType55(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE56 then --进阶目标(进阶到一定阶数)
self:makeType56(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE57 then --完成预期任务
self:makeType57(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE48 then --晒娃
self:makeType48(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE58 then --宝宝同心值
self:makeType58(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE59 then --战力
self:makeType59(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE60 then --任意商店技能书购买
self:makeType60(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE61 then --指定商店购买技能书
self:makeType61(taskVO, taskTipVO)
elseif taskTipVO.type == TaskTipType.TYPE62 then --任意商店技能书购买
self:makeType62(taskVO, taskTipVO)
else
--无特殊参数要求
self:makeNormalType(taskVO, taskTipVO)
end
taskVO.tipType = taskTipVO.type
--显示数量
if Config.ConfigTaskEffect.NeedShowNumTaskType[taskTipVO.type] or
Config.ConfigTaskEffect.NeedShowNumTaskId[taskVO.id] then
--通关专属幻魔要显示次数
local numStr = ""
numStr = "("..HtmlColorTxt(taskTipVO.nowCount, "#2CF66F").."/"..taskTipVO.count..")"
taskVO.tipContent = taskVO.tipContent..numStr
if taskTipVO.type == TaskTipType.TYPE100 then
--赏金幻魔
taskVO.tipContent = taskVO.tipContent .. "\n<color=#f558ff>可获大量装备和交易券</color>"
end
if taskTipVO.type == TaskTipType.TYPE102 then --完成某副本类型
if taskTipVO.id == BaseDungeonModel.DUN_TYPE.PersonBoss then
taskVO.tipContent = string.format( "击杀<color=#2CF66F>%s</color>%s\n<color=#f558ff>可获大量装备和交易券</color>",BaseDungeonModel.DUN_NAME[taskTipVO.id] or "",numStr )
end
end
if taskTipVO.type == TaskTipType.TYPE58 then --完成宝宝同心值
taskVO.tipContent = string.format( "同心值达到<color=#2CF66F></color>%s\n<color=#f558ff>完成日常任务积攒同心值</color>",numStr )
end
if taskTipVO.type == TaskTipType.TYPE59 then --战力
taskVO.tipContent = string.format( "达到<color=#2CF66F></color>%s战力\n<color=#f558ff>点击查看可提战的系统</color>",numStr )
end
if taskTipVO.type == TaskTipType.TYPE62 then --任意商店技能书购买
taskVO.tipContent = string.format( "购买%s本技能书",numStr )
end
-------------------------
if taskTipVO.type == TaskTipType.TYPE24 then
--活跃度要加文本
taskVO.tipContent = taskVO.tipContent .. "\n<color=#f558ff>每天必做的成长任务</color>"
end
end
break
end
end
end
function TaskModel:makeType1(taskVO, taskTipVO)
local strs = ""
local findtype = TaskTipType.TYPE1
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local temp = ConfigItemMgr.Instance:GetMonsterDataItem(taskTipVO.id)
if temp then
strs = string.format(cfg, Trim(temp.name))
end
else
strs = Trim(taskVO.tips)
end
local findstr={}
if taskTipVO.scene_x ~= 0 and taskTipVO.scene_y ~= 0 then
findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
else
findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
end
taskVO.tipContent=strs
taskVO.tipParam=findstr
taskVO.need_find_way = taskTipVO.need_find_way
end
--完成副本
function TaskModel:makeType2(taskVO, taskTipVO)
--特殊限制的主线副本,因为UI还是显示任务栏,需要把通关副本改为击败怪物
local dun_id = taskTipVO.id
local strs = ""
local is_special_ui_dun = Config.ConfigChangeSceneEffect.DungeonLimit[dun_id] and Config.ConfigChangeSceneEffect.DungeonLimit[dun_id].keep_ui
if is_special_ui_dun then
local wave_cfg = Config.Dunwave[dun_id.."@1"]
if wave_cfg then
local mon_list = stringtotable(wave_cfg.mon_list) or {}
local mon_id = mon_list[1] and mon_list[1][1]
local mon_cfg = ConfigItemMgr.Instance:GetMonsterDataItem(mon_id)
if mon_cfg then
local cfg = "消灭 <color=#2CF66F>%s</color>"
strs = string.format(cfg, Trim(mon_cfg.name))
if taskVO.type == TaskType.BOUNTY_LINE then
local numStr = ""
numStr = "("..HtmlColorTxt(taskTipVO.nowCount, "#2CF66F").."/"..taskTipVO.count..")"
strs = strs..numStr
end
else
strs = "消灭前方怪物"
end
else
strs = "消灭前方怪物"
end
else
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local temp = Config.Dungeoncfg[taskTipVO.id]
if temp then
if temp.type == BaseDungeonModel.DUN_TYPE.ONE_TOWER then
strs = string.format("通关简单模式第<color=#2CF66F>%s</color>层", taskTipVO.id-7000)
elseif dun_id == BossModel.FAKE_MONEY_BOSS_DUN_ID then
strs = string.format("击杀<color=#2CF66F>%s</color>", Trim(temp.name))
if not self:IsTaskProgressFinish(taskVO) then --未完成才显示进度
local numStr = ""
numStr = "("..HtmlColorTxt(taskTipVO.nowCount, "#2CF66F").."/"..taskTipVO.count..")"
strs = strs..numStr
end
else
strs = string.format(cfg, Trim(temp.name))
end
end
else
strs = Trim(taskVO.tips)
end
end
taskVO.tipContent=strs
taskVO.tipParam={TaskTipType.TYPE2, taskTipVO.sceneId, taskTipVO.id, taskVO.id, taskTipVO.scene_x, taskTipVO.scene_y}
taskVO.need_find_way = 1
local task_id = taskVO.id
if task_id == Config.ConfigTaskEffect.TOWER_DUN_ID then
local dun_id = taskVO.tipParam and taskVO.tipParam[3] or 0
if tonumber(taskVO.tipParam[1]) == TaskTipType.TYPE2 and dun_id > 7000 and dun_id < 8000 then
local dun_cfg = BaseDungeonModel:getInstance():GetDunCfg(dun_id)
local dun_power = 150000--dun_cfg and dun_cfg.recommend_power or 0
local my_power = RoleManager.Instance.mainRoleInfo.fighting
if my_power >= dun_power then
taskVO.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVO.type]
else
taskVO.sortKey = 9999 --置底
end
end
end
end
--完成经验副本类型副本
function TaskModel:makeType34(taskVO, taskTipVO)
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local dunStr = BaseDungeonModel.DUN_NAME[taskTipVO.id] or ""
strs = string.format(cfg, dunStr)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={TaskTipType.TYPE34, taskTipVO.sceneId, taskTipVO.id, taskVO.id, taskTipVO.scene_x, taskTipVO.scene_y}
taskVO.need_find_way = 1
end
--收集
function TaskModel:makeType6(taskVO, taskTipVO)
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local temp = GoodsModel:getInstance():GetGoodsBasicByTypeId(taskTipVO.id)
strs = string.format(cfg, Trim(temp.goods_name))
else
strs = Trim(taskVO.tips)
end
local findstr={}
local findtype = TaskTipType.TYPE6
local monster_id = 0 --找坐标就行了
if taskTipVO.scene_x ~= 0 and taskTipVO.scene_y ~= 0 then
findstr={findtype, taskTipVO.sceneId, monster_id,taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
else
findstr={findtype, taskTipVO.sceneId, monster_id,taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
end
taskVO.tipContent=strs
taskVO.tipParam= findstr
taskVO.need_find_way = taskTipVO.need_find_way
end
--探索场景, 寻路到指定场景指定地点
function TaskModel:makeType16(taskVO, taskTipVO)
local strs = "探索场景"
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local temp = ConfigItemMgr.Instance:GetSceneItem(taskTipVO.sceneId)
if temp then
strs = string.format(cfg, Trim(temp.name))
end
end
taskVO.tipContent=strs
taskVO.tipParam={TaskTipType.TYPE16, taskTipVO.sceneId, taskTipVO.scene_x, taskTipVO.scene_y, taskTipVO.count}
taskVO.need_find_way = 1
end
--采集
function TaskModel:makeType18(taskVO, taskTipVO)
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local temp = ConfigItemMgr.Instance:GetMonsterDataItem(taskTipVO.id)
if temp then
strs = string.format(cfg, Trim(temp.name))
end
else
strs = Trim(taskVO.tips)
end
local findstr={}
local findtype = TaskTipType.TYPE18
if taskTipVO.scene_x ~= 0 and taskTipVO.scene_y ~= 0 then
findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
else
findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
end
taskVO.tipContent=strs
taskVO.tipParam= findstr
taskVO.need_find_way = taskTipVO.need_find_way
end
--与npc对话
function TaskModel:makeType7(taskVO, taskTipVO)
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg and not SceneManager.Instance:IsClientHideNpc(taskTipVO.id) then
local temp = ConfigItemMgr.Instance:GetNpcItem(taskTipVO.id)
if temp and temp.name then
strs = string.format(cfg, Trim(temp.name))
end
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = taskTipVO.need_find_way
end
--击杀boss
function TaskModel:makeType100( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
strs = cfg or Trim(taskVO.tips)
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--强化装备
function TaskModel:makeType101( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count, taskTipVO.id)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--市场上架 市场购买
function TaskModel:makeType109( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--完成某副本类型
function TaskModel:makeType102( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local dunStr = BaseDungeonModel.DUN_NAME[taskTipVO.id] or ""
strs = string.format(cfg, dunStr)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--单次副本获得x经验
function TaskModel:makeType103( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local dunStr = Config.ConfigDungeonClient.dunTypeStr[taskTipVO.id] or ""
strs = string.format(cfg, CalUnitNum2(taskTipVO.count))
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--添加好友类型
function TaskModel:makeType104( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg,taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--装备吞噬
function TaskModel:makeType26( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg,taskTipVO.id)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--击杀首领
function TaskModel:makeType27( taskVO, taskTipVO )
local strs = ""
local cfg = ConfigItemMgr.Instance:GetMonsterDataItem(taskTipVO.id)
if cfg then
strs = "击杀 " .. HtmlColorTxt(Trim(cfg.name), ColorUtil.GREEN_DARK)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.count}
taskVO.need_find_way = 1
end
function TaskModel:makeType28( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
function TaskModel:makeType29( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--符文爬塔
function TaskModel:makeType111( taskVO, taskTipVO )
-- local strs = ""
-- local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
-- if cfg then
-- local dun_id = taskTipVO.count
-- local layer_id = 1
-- local name = ""
-- local force_read_server = false
-- local config = Config.Dungeoncfg[dun_id]
-- if config then
-- if config.type == 20 then
-- name = "魂珠副本"
-- elseif config.type == 21 then
-- name = "神格副本"
-- elseif config.type == 5 then
-- force_read_server = true
-- end
-- end
-- if force_read_server then
-- strs = Trim(taskVO.tips)
-- else
-- config = BaseDungeonModel.GetDungeonrunelvdataCfg(dun_id)
-- if config then
-- layer_id = config.lv
-- end
-- strs = string.format(cfg,name,layer_id)
-- end
-- else
-- strs = Trim(taskVO.tips)
-- end
-- taskVO.tipContent=strs
-- taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.count, taskVO.id}
-- taskVO.need_find_way = 1
end
--装备附能
function TaskModel:makeType36( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--副本波数进度
function TaskModel:makeType37( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local temp = Config.Dungeoncfg[taskTipVO.id]
if temp then
if temp.type == BaseDungeonModel.DUN_TYPE.EXP then
strs = string.format("成功挑战第<color=#2CF66F>%s</color>波", taskTipVO.count)
else
strs = string.format(cfg, Trim(temp.name), taskTipVO.count)
end
end
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
--战力
local task_id = taskVO.id
if task_id == Config.ConfigTaskEffect.EXP_DUN_ID then
local my_power = RoleManager.Instance.mainRoleInfo.fighting
local wave = taskTipVO.count
local wave_cfg = BaseDungeonModel:getInstance():GetDunWaveCfg(BaseDungeonModel.EXP_DUN_ID, wave)
local wave_power = wave_cfg.recommend_power or 999999999999
if my_power >= wave_power then
taskVO.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVO.type]
else
taskVO.sortKey = 9999 --置底
end
end
end
--提交装备
function TaskModel:makeType106( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.id, ColorUtil:getColorName(taskTipVO.count))
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--竞技场次数
function TaskModel:makeType31( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--装备升星
function TaskModel:makeType39( taskVO, taskTipVO )
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
local strs = cfg or Trim(taskVO.tips)
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--商城购买
function TaskModel:makeType40( taskVO, taskTipVO )
local need_money = taskTipVO.sceneId --需要的价格
local shop_key_id = taskTipVO.scene_x --商品id
local money_type = Config.Shop[shop_key_id] and Config.Shop[shop_key_id].ctype --商品消耗货币类型
local my_money = GoodsModel:getInstance():GetGoodsNumFromType(money_type) --我的商品消耗货币
local money_type_id = Config.ConfigNotNormalGoods[money_type] and Config.ConfigNotNormalGoods[money_type].goods_id
local money_name = GoodsModel:getInstance():getGoodsName(money_type_id)
local goods_type_id = taskTipVO.id
local goods_name = ""
local goods = ConfigItemMgr.Instance:GetGoodItem(goods_type_id)
if goods then
local colorStr = TaskModel.QualityColor[goods.color] or TaskModel.QualityColor[1]
goods_name = HtmlColorTxt(Trim(goods.goods_name), colorStr)
end
local strs = ""
if taskTipVO.isFinish == 1 or my_money >= need_money then --已完成
strs = string.format("%s足够了,去购买%s吧", money_name, goods_name)
else --未完成
strs = string.format("获得<color=#2CF66F>%s%s</color>,前往商城购买%s", need_money, money_name, goods_name)
strs = strs .. "\n" .. string.format("当前%s(<color=#2CF66F>%s</color>/%s)", money_name, my_money, need_money)
end
-------------------------
local equip_type = EquipModel:getInstance():GetEquipType( goods_type_id )
if equip_type then
local type_const = EquipModel.EquipType
if equip_type == type_const.Guard or equip_type == type_const.LeftRing
or equip_type == type_const.RightRing or equip_type == type_const.Necklace then
-- 守护戒指耳饰类--项链类
strs = string.format( "购买<color=#2CF66F>[%s]</color>",Trim(goods.goods_name) )
strs = strs .. "\n" .. string.format("拥有%s(<color=#2CF66F>%s</color>/%s)", money_name, my_money, need_money)
end
end
-------------------------
taskVO.is_money_enough = my_money >= need_money
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, shop_key_id, goods_type_id, taskVO.id, need_money}
taskVO.need_find_way = 1
-- taskVO.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskTipVO.type]
end
--解锁地狱摩托
function TaskModel:makeType51( taskVO, taskTipVO )
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
taskVO.tipContent = cfg
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--龙神抽奖
function TaskModel:makeType53( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--装备套装
function TaskModel:makeType54( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local color = ColorUtil:GetColor(taskTipVO.sceneId)
strs = string.format(cfg, taskTipVO.count, taskTipVO.id, color, ColorUtil:getColorName(taskTipVO.sceneId))
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--战魂强化
function TaskModel:makeType55( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--进阶目标(进阶到一定阶数)
function TaskModel:makeType56( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, FosterConst.ModelName[taskTipVO.id], taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--完成预期任务
function TaskModel:makeType57( taskVO, taskTipVO )
local strs = Trim(taskVO.tips)
if taskVO.id == 2040002 then
taskVO.tipContent = strs .. "\n" .. HtmlColorTxt( "AI娘可以协助出战" , '#f558ff')
elseif taskVO.id == 2040003 then
taskVO.tipContent = strs .. "\n" .. HtmlColorTxt( "恶魔骑士正在前方等你" , '#f558ff')
else
taskVO.tipContent = strs
end
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--晒娃
function TaskModel:makeType48( taskVO, taskTipVO )
local strs = Trim(taskVO.tips)
if taskVO.id == 3120003 then
taskVO.tipContent = strs .. "\n" .. HtmlColorTxt( "积攒同心值激活宝宝" , '#f558ff')
else
taskVO.tipContent = strs
end
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--宝宝同心值
function TaskModel:makeType58( taskVO, taskTipVO )
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--战力
function TaskModel:makeType59( taskVO, taskTipVO )
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--任意主动技能升级次数
function TaskModel:makeType60( taskVO, taskTipVO )
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.tipContent = HtmlColorTxt("升级技能", ColorUtil.GREEN_DARK)
taskVO.need_find_way = 1
end
--指定商店购买技能书
function TaskModel:makeType61( taskVO, taskTipVO )
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.tipContent = HtmlColorTxt("交易商店购买技能书", ColorUtil.GREEN_DARK)
taskVO.need_find_way = 1
end
--任意商店技能书购买
function TaskModel:makeType62( taskVO, taskTipVO )
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--无特殊参数要求2
function TaskModel:makeNormalType2( taskVO, taskTipVO )
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
local strs = cfg or Trim(taskVO.tips)
taskVO.tipContent = string.format(strs, taskTipVO.count)
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--完成社团活动
function TaskModel:makeType107( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local tb = {"社团首领","社团晚宴","守卫社团","社团争霸"}
strs = string.format(cfg,tb[taskTipVO.id])
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--合成装备
function TaskModel:makeType23( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
local temp = GoodsModel:getInstance():GetGoodsBasicByTypeId(taskTipVO.id)
strs = string.format(cfg, taskTipVO.count, Trim(temp.goods_name))
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--活跃度
function TaskModel:makeType24( taskVO, taskTipVO )
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--通用寻路数据
function TaskModel:makeFindType(taskVO, taskTipVO)
local strs = ""
strs = Trim(taskVO.tips)
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = taskTipVO.need_find_way
end
--不需要数据
function TaskModel:makeNormalType(taskVO, taskTipVO)
local strs = ""
local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
if cfg then
strs = string.format(cfg, taskTipVO.id, taskTipVO.count)
else
strs = Trim(taskVO.tips)
end
taskVO.tipContent=strs
taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
taskVO.need_find_way = 1
end
--* 使用","连接参数成字符串
function TaskModel:MakeParams( _table)
local result=""
local len=#_table
local index=1
for key, var in ipairs(_table) do
if index==len then
result=result..var
else
result=result..var..","
end
index=index+1
end
return result
end
--根据ID 获取可接任务对象,没有则放回null
function TaskModel:GetCanTaskById(taskId)
local taskVO=nil;
for key, taskVO in ipairs(self._canTaskList) do
if taskVO.id == taskId then
return taskVO
end
end
return nil
end
--根据ID 获取已接任务对象,没有则放回null
function TaskModel:GetReceivedTaskById(taskId)
local taskVO=nil;
for key, taskVO in ipairs(self._receivedTaskList) do
if taskVO.id == taskId then
return taskVO
end
end
return nil
end
-- 根据类型 返回是否有该类型的任务
function TaskModel:FindHaveTaskByType( taskType )
for i,taskVO in ipairs(self.all_task_list) do
if taskVO.type == taskType then
return true
end
end
return false
end
function TaskModel:GetReceivedTaskList()
return self._receivedTaskList
end
function TaskModel:GetCanTaskList()
return self._canTaskList
end
--获取主线任务
function TaskModel:GetMainTask()
for key, taskVO in ipairs(self._receivedTaskList) do
if taskVO.type == TaskType.MAIN_LINE then
return taskVO
end
end
for _, taskVO in ipairs(self._canTaskList) do
if taskVO.type == TaskType.MAIN_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
return taskVO
end
end
return self._nextMain
end
--npc是否是跟随npc
function TaskModel:IsFollowNpc(npc_id)
local bool = false
if self.followNpcList then
for i,v in ipairs(self.followNpcList) do
if tonumber(v[1]) == npc_id then
bool = true
break
end
end
end
return bool
end
--点击任务链接操作 @use_shoe 是否使用小飞鞋
--@force_use_shoe:点击任务栏飞鞋按钮时强制使用飞鞋
function TaskModel:TaskClickFun(task_data, use_shoe, force_use_shoe)
self.guild_kill_monster_num = 0--重置一下
if not task_data then
return
end
--未接任务的话就接一下
if task_data.acceptType and task_data.acceptType==1 and task_data.type and task_data.type == TaskType.MAIN_LINE and task_data.level and task_data.level<=RoleManager.Instance.mainRoleInfo.level and task_data.id then
TaskController.Instance.auto_accept_main_id = nil
GlobalEventSystem:Fire(TaskEventType.SEND_TASK_ACCEPT, task_data.id)
return
end
--PrintTable(task_data)
self:MakeTaskTip(task_data)
local params = self:MakeParams(task_data.tipParam)
print("Saber:TaskModel [969] params: ",params)
if not SceneManager.Instance:IsMainCityorYieldScene() and
not SceneManager.Instance:IsMirrorDungeonScene() and
not self:CanDoTaskInEveryScene(params) then
Message.show("正在副本或活动中")
return
end
self.is_stop = false --去掉停止任务状态 避免有些情况,停止了但不确定从哪个界面出来,没开始任务
local vip_free_shoe = VipModel:getInstance():CanFreeUseShoe()
-- if VipModel:getInstance():CanFreeUseShoe() then
-- use_shoe = true
-- end
if task_data.type == TaskType.BOUNTY_LINE or task_data.type == TaskType.GUILD_LINE then
--跑环类任务需要看看玩家有没有选择自动使用小飞鞋
if (not vip_free_shoe) and self.circle_auto_use_shoe[task_data.type] then
--有vip免费小飞鞋,就不要参与判断了
use_shoe = true
end
else
self.circle_auto_use_shoe = {}
end
-- if task_data.type == TaskType.MAIN_LINE then
-- GlobalEventSystem:Fire(TaskEventType.SHOW_TASK_GUILD_ARROW, false)
-- end
-- SceneManager.Instance:ClearPreChangeSceneHandle()
-- GlobalEventSystem:Fire(EventName.CANCEL_PRE_CHANGE)
if params and task_data.mainTip == false then
if self:IsAutoDoTask(task_data) then
self.now_task_id = task_data.id
-- 点击任务item的自动寻路,理论上应该也算是玩家自己选择任务,要避免进入多任务选择的逻辑
DialogueModel:getInstance():SetMultSelectTaskID(task_data.id)
end
--新手任务特殊处理,采集完直接弹出对话框
if task_data.id and task_data.id == 10020 then
local is_task_finished = true
for k,vo in pairs(task_data.taskTips) do
if vo.isFinish == 0 then
is_task_finished = false
end
end
task_data.need_find_way = is_task_finished and 0 or 1
end
local is_daily_task_finished = false
if task_data and task_data.type == TaskType.BOUNTY_LINE then
for k,vo in pairs(task_data.taskTips) do
if vo.isFinish == 1 then
is_daily_task_finished = true
end
end
end
if task_data and task_data.type == TaskType.GUILD_LINE then
is_daily_task_finished = task_data:IsLastTaskTipsFinished()
print('Ych:TaskModel.lua[1899] data', is_daily_task_finished)
PrintTable(task_data)
end
if is_daily_task_finished then
GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, task_data.type)
return
end
if task_data.need_find_way == 1 then
GlobalEventSystem:Fire(EventName.WAYFINDING, params, use_shoe, force_use_shoe)
else
--不需要寻路,直接打开npc对话框
if task_data.tipParam[3] then
local npc = Scene.Instance:GetNpc(task_data.tipParam[3])
if npc == nil or not npc:IsInState(PoseState.MOVE) then
GlobalEventSystem:Fire(SceneEventType.SHOW_TASK, task_data.tipParam[3])
end
end
-- 转职任务,如果是未达成需求等级的话弹出升级引导
if task_data.type == TaskType.TRUN_LINE and RoleManager.Instance.mainRoleInfo.level < task_data.level then
GlobalEventSystem:Fire(EventName.SHOW_MAIN_TASK_TIPS_VIEW, true)
return
end
end
if self:IsAutoDoTask(task_data) then
--如果当前点击的和上一个完成的任务类型不同,就重置
if task_data.type ~= self.last_task_type_cache then
self.last_task_type_cache = nil
self.last_task_id_cache = nil
end
-- GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true)
if use_shoe then
Scene.Instance:CancelClickTarget()
Scene.Instance.user_manul_time = Status.NowTime
end
AutoFightManager:getInstance():CacheGoToPos()
--重置状态
self.is_auto_task = true --手动点击,设为true
self:ResetFlag()
end
end
end
--重置状态
function TaskModel:ResetFlag( )
self.need_accept = nil
self.is_stop = false
self.wait_30003 = false
self.wait_30004 = false
end
--获取任务打怪目标,用于自动战斗
function TaskModel:GetTaskTarget( now )
local task_data = self:GetCurTask()
if not task_data then return end
local params = self:MakeParams(task_data.tipParam)
if params and task_data.mainTip == false then
local array=Split(params,",")
local type=tonumber(array[1])
if type == TaskTipType.TYPE1 or type == TaskTipType.TYPE6
and task_data.cur_num<task_data.target_num then
local id = tonumber(array[3])
local sceneId = tonumber(array[2])
local monster = Scene.Instance:FindNearestMonster(id) --附近有怪的话直接自动打怪,没有则随机怪堆
if monster then
return monster
else
--打死怪物后,30001可能还没通知进度完成,这时可能去下一个打怪点,做下延迟判断
if now then
--如果做任务过程,有怪物追着你到npc,接完任务就马上打身边的怪物,
--打完九宫格内就没怪物了,所以如果附近没怪,要手动寻找怪物点
local random_pos = self:GetTaskMonsterRandomPos(id, sceneId)
if random_pos then --随机一堆怪物,解决玩家分流问题,避免玩家扎堆杀怪
local findVo = FindVo.New()
findVo.type = FindVo.MONSTER
findVo.id = id
findVo.x = random_pos.x
findVo.y = random_pos.y
findVo.sceneId = sceneId
GlobalEventSystem:Fire(EventName.FIND,findVo)
GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
return
end
else
local onDelay = function ( )
self.dtimer = nil
if self.is_auto_task and not self.is_stop then
self:GetTaskTarget(true)
end
end
if not self.dtimer then
self.dtimer = setTimeout(onDelay, 1)
end
end
end
end
end
end
--获取任务打怪目标,用于自动战斗
function TaskModel:GetTaskTargetId( )
local task_data = self:GetCurTask()
if not task_data then return end
local params = self:MakeParams(task_data.tipParam)
if params and task_data.mainTip == false then
local array=Split(params,",")
local type=tonumber(array[1])
if type == TaskTipType.TYPE1 or type == TaskTipType.TYPE6
and task_data.cur_num<task_data.target_num then
local id = tonumber(array[3])
return id
end
end
end
--是否已接采集任务
function TaskModel:HaveCaiJiTask(content_id)
local have = false
local monster_id = nil
for i,v in ipairs(self._receivedTaskList) do
if v.task_kind == TaskKind.CAI_JI_KIND and v.id == self.now_task_id and v.cur_num<v.target_num then
have = true
if v.content_id == 0 then
monster_id = content_id
else
monster_id = v.content_id
end
break
end
end
return have, monster_id
end
--随机场景中某堆怪物, 解决玩家分流问题,避免玩家扎堆杀怪
function TaskModel:GetTaskMonsterRandomPos(monster_id, sceneId)
local random_logic_pos, random_real_pos, ignore_rush = nil
local cfg = Config.ConfigWorldMon.SceneMons[tonumber(sceneId)]
if cfg and cfg.mon_list then
local monster_heap = cfg.mon_list[tonumber(monster_id)]
if monster_heap and #monster_heap.way_point > 0 then
ignore_rush = monster_heap.ignore_rush
local pos = monster_heap.way_point[math.random(1, #monster_heap.way_point)]
if pos then
random_real_pos = pos
random_logic_pos = {x = pos.x / SceneObj.LogicRealRatio.x, y = pos.y / SceneObj.LogicRealRatio.y}
end
end
end
return random_logic_pos, random_real_pos, ignore_rush
end
--刷新采集任务怪的名字面板,有相应任务时才显示名字面板
function TaskModel:RefreshCollectMonsterName(content_id)
for id, monster in pairs(Scene.Instance:GetMonsterList()) do
if monster:GetVo().type_id == content_id then
monster.vo:ChangeVar("name", monster.vo.name, nil, true)
end
end
end
--找出任务的步骤是否已完成
function TaskModel:FindTaskTipIsFinish(task)
local finish = false
if task and task.taskTips then
for i,v in ipairs(task.taskTips) do
if v.isFinish == 1 then
finish = true
end
end
end
return finish
end
--是否主线任务
function TaskModel:IsMainTask(id)
local basedata = ConfigItemMgr.Instance:GetTaskData(id)
if basedata then
return basedata.type == TaskType.MAIN_LINE
end
end
--是否跑环任务
function TaskModel:IsCircleTask(id)
local basedata = ConfigItemMgr.Instance:GetTaskData(id)
if basedata then
return basedata.type == TaskType.BOUNTY_LINE or basedata.type == TaskType.GUILD_LINE
end
end
--是否转职任务
function TaskModel:IsTurnTask(id)
local basedata = ConfigItemMgr.Instance:GetTaskData(id)
if basedata then
return basedata.type == TaskType.TRUN_LINE
end
end
--是否第一个任务
function TaskModel:IsFisrtTask()
for i,v in ipairs(self.all_task_list) do
if v.type == TaskType.MAIN_LINE then
if v.id == TaskModel.FirstTaskId then
return true
end
end
end
end
--是否要创建飞龙
function TaskModel:IsCreateDragonTask()
return self.last_finish_task_id < TaskModel.DragonTaskId
end
--任务进度显示
function TaskModel:GetTaskProgressTip( taskVo )
local str = string.format("<color='%s'>进度:(<color='%s'>%s</color>/%s)</color>",
TaskModel.Color.YELLOW, ColorUtil.RED, 0, 1)
if taskVo.target_num~=0 then
local color = ColorUtil.GREEN
if taskVo.cur_num < taskVo.target_num then
color = ColorUtil.RED
end
--暂时支持一个进度显示
str = string.format("<color='%s'>进度:(<color='%s'>%s</color>/%s)</color>", TaskModel.Color.YELLOW,
color, taskVo.cur_num, taskVo.target_num)
end
return str
end
--获取任务颜色
function TaskModel:GetColorByTaskType( task_type )
local color_str
if task_type == TaskType.MAIN_LINE then
color_str = TaskModel.Color.YELLOW
elseif task_type == TaskType.EXTENSION_LINE then
color_str = TaskModel.Color.BLUE
elseif task_type == TaskType.BOUNTY_LINE then
color_str = TaskModel.Color.ORANGE
elseif task_type == TaskType.GUILD_LINE then
color_str = TaskModel.Color.ORANGE
elseif task_type == TaskType.LIMIT_LINE then
color_str = TaskModel.Color.PINK
elseif task_type == TaskType.TRUN_LINE then
color_str = TaskModel.Color.PINK
elseif task_type == TaskType.ACTIVITY_LINE then
color_str = TaskModel.Color.BLUE
elseif task_type == TaskType.TREASURE then
color_str = TaskModel.Color.ORANGE
elseif task_type == TaskType.DAILY_ACTIVITE then
color_str = TaskModel.Color.GREEN
else
color_str = TaskModel.Color.GREEN
end
return color_str
end
--获取任务颜色
function TaskModel:GetColorValueByTaskType( task_type )
local color_str
if task_type == TaskType.MAIN_LINE then
color_str = TaskModel.ColorNoSymbols.YELLOW
elseif task_type == TaskType.EXTENSION_LINE then
color_str = TaskModel.ColorNoSymbols.BLUE
elseif task_type == TaskType.BOUNTY_LINE then
color_str = TaskModel.ColorNoSymbols.ORANGE
elseif task_type == TaskType.GUILD_LINE then
color_str = TaskModel.ColorNoSymbols.ORANGE
elseif task_type == TaskType.LIMIT_LINE then
color_str = TaskModel.ColorNoSymbols.PINK
elseif task_type == TaskType.TRUN_LINE then
color_str = TaskModel.ColorNoSymbols.PINK
elseif task_type == TaskType.ACTIVITY_LINE then
color_str = TaskModel.ColorNoSymbols.BLUE
else
color_str = TaskModel.ColorNoSymbols.GREEN
end
return color_str
end
--任务是否有红点
function TaskModel:HasTaskRed( )
return self:HasMainLineRed() or self:HasExtensionTaskAccept() or self:HasBountyRed() or self:HasGuildRed() or self:HasTurnRed()
end
--主线任务是否有红点
function TaskModel:HasMainLineRed( )
for _, taskVO in ipairs(self._canTaskList) do
if taskVO.type == TaskType.MAIN_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
return true
end
end
end
--支线任务是否有红点
function TaskModel:HasExtensionTaskAccept( )
for _, taskVO in ipairs(self._canTaskList) do
if taskVO.type == TaskType.EXTENSION_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
return true
end
end
end
--转职任务是否有红点
function TaskModel:HasTurnRed( )
for _, taskVO in ipairs(self._canTaskList) do
if taskVO.type == TaskType.TRUN_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
return true
end
end
end
--悬赏任务是否有红点
function TaskModel:HasBountyRed( )
return self:CanAcceptCircleTask(TaskType.BOUNTY_LINE)
end
--社团任务是否有红点
function TaskModel:HasGuildRed( )
return self:CanAcceptCircleTask(TaskType.GUILD_LINE)
end
--任务进度是否完成
function TaskModel:IsTaskProgressFinish( task )
if task and task.taskTips then
for k,v in pairs(task.taskTips) do
if v.isFinish==0 and v.type~=TaskTipType.TYPE9 then
return false
end
end
return true
end
end
--显示小飞鞋的任务类型
function TaskModel:IsShowFlyShoe( data )
for k,v in pairs(Config.ConfigTaskEffect.circleRewardTaskId) do
if data.id == v then
--两个跑环领奖任务不要显示,但是属于跑环类
return false
end
end
return Config.ConfigTaskEffect.ShowShoeTaskType[data.tipType]
and (data.type~=TaskType.EXTENSION_LINE or data.acceptType==0)
and data.type~=TaskType.TREASURE
end
--设置社团/赏金任务进度
function TaskModel:SetCircleTaskInfo( info )
local set_auto_task = false--跑环任务变更修改自动任务状态
if info.task_type == TaskType.BOUNTY_LINE then
if (info.cur_progress == 10) then
--某个等级之前,完成10环经验跑环,提示做主线
if self.lask_bounty_process == 9 and RoleManager.Instance.mainRoleInfo.level <= Config.ConfigTaskEffect.DailyTaskFinishShowMainTipsLevel then
self:ShowMainLineTips(true)
end
else
self.circle_task_info[info.task_type] = info
end
self.lask_bounty_process = info.cur_progress
elseif info.task_type == TaskType.GUILD_LINE then
self.circle_task_info[info.task_type] = info
if (self.lask_guild_process == 9 and info.cur_progress == 10) then
GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
if SceneManager:getInstance():IsMainCityorYieldScene() then
GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, info.task_type)
else
self.wait_circle_show_award_data = info.task_type
end
end
self.lask_guild_process = info.cur_progress
end
GlobalEventSystem:Fire(EventName.REFRESH_TASK_CIRCLE_TIPS)
self:Fire(TaskEvent.TASK_LIST_INIT)
end
function TaskModel:GetCircleTaskInfo( task_type )
return self.circle_task_info[task_type]
end
--能否接社团/赏金任务
function TaskModel:CanAcceptCircleTask( task_type )
local info = self:GetCircleTaskInfo(task_type)
return not self:GetTaskByType(task_type) and info and info.cur_progress and info.cur_progress==0
and ( (task_type==TaskType.BOUNTY_LINE and GetModuleIsOpen(300,1))
or (task_type==TaskType.GUILD_LINE and GetModuleIsOpen(300,2) and RoleManager.Instance.mainRoleInfo.guild_id>0) )
end
--社团任务红点
function TaskModel:CanAcceptTaskRed( )
local info = self:GetCircleTaskInfo(TaskType.GUILD_LINE)
if not info then return end
return (self:GetTaskByType(TaskType.GUILD_LINE) ~= nil or (RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.Other.guild_task and RoleManager.Instance.mainRoleInfo.guild_id>0) and info.cur_progress == 0 )
end
--根据任务类型获取直接完成需要消耗的彩钻
function TaskModel:GetCostFinishTask( task_type )
local need = 0
local cfg = Config.Tasktype[task_type]
local list = false
if cfg and cfg.finish_cost then
list = stringtotable(cfg.finish_cost)
if list[1] and list[1][3] then
need = tonumber(list[1][3])
end
end
return need,list[1]
end
--飞龙任务
function TaskModel:IsDragonFlyTask()
for i,v in ipairs(self.all_task_list) do
if v.type == TaskType.MAIN_LINE then
if v.id == TaskModel.DragonTaskId and v.acceptType==0 and v.cur_num<v.target_num then
return true
end
end
end
end
--断级主线任务是否需要显示箭头提醒
function TaskModel:DefaultTaskShowArrow()
if not self._nextMain then
return
end
local level = self._nextMain.level
if level and level~=0 and self.default_task_arrow_list[level] == nil then
self.default_task_arrow_list[level] = true
GlobalEventSystem:Fire(EventName.TEST_HELP_STEP, 999991007)
GlobalEventSystem:Fire(EventName.IS_SHOW_TRUN_MASK_HELPER)
end
end
--20秒不动,自动做任务, 副本,杀怪,采集类优先, 然后才是主线任务
function TaskModel:AutoDoTaskByType( )
--SceneManager:getInstance():IsEscortScene() or
if (not SceneManager:getInstance():IsMainCityorYieldScene() and not self.is_stop and not self.is_auto_task) then
return
end
local list = self:GetMainUITaskData()
local task_data
for k,v in pairs(list) do
if v.tipParam and v.tipParam[1] then
local tip_type = v.tipParam[1]
if v.acceptType==0 and (tip_type==TaskTipType.TYPE1
or tip_type==TaskTipType.TYPE2 or tip_type==TaskTipType.TYPE6
or tip_type==TaskTipType.TYPE18) and self:IsAutoDoTask(v) then
task_data = v
break
end
end
end
if not task_data then
task_data = self:GetMainTask()
end
if task_data and not task_data.mainTip then
return task_data
end
end
--是否显示武器, 采集任务完成后才显示
function TaskModel:IsHideMainRoleWeapon( )
local is_weapon_task_finish = self:IsTaskFinished(Config.ConfigTaskEffect.MonsterWeaponTaskID)
if RoleManager.Instance.mainRoleInfo.level<4 and not is_weapon_task_finish then
return true
else
return false
end
end
--获取赏金任务提示
function TaskModel:GetBountyTipTask( )
if self:CanAcceptCircleTask(TaskType.BOUNTY_LINE) then
print('Ych:TaskModel.lua[2216] data', data)
--当日赏金任务任务未做
local taskVo = TaskVo.New()
taskVo.level = Config.ConfigOpenLv.Other.bounty_task
local str = TaskModel.TaskTypeStr3[TaskType.BOUNTY_LINE]
local cfg = self:GetTaskAcceptNpcConfig(TaskType.BOUNTY_LINE)
local temp = ConfigItemMgr.Instance:GetNpcItem(cfg.npc_id)
if not temp then return end
taskVo.description = "日常每天做一做,升级快战力高,千万不要错过!每完成10环还有特殊奖励,每天凌晨4点重置日常任务!"
taskVo.taskName = string.format("%s任务", str)
taskVo.task_name = string.format("%s任务", str)
taskVo.type = TaskType.BOUNTY_LINE
taskVo.isTipTask = true
taskVo.need_find_way = 1
taskVo.target_num = 0
taskVo.order = 0
taskVo.id = Config.ConfigTaskEffect.bountyTaskTipId
taskVo.task_id = Config.ConfigTaskEffect.bountyTaskTipId
taskVo.tips = string.format("寻找<color=#2CF66F>%s</color>", Trim(temp.name))
taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type] --任务类型排序
taskVo.taskTips = {}
taskVo.taskTips[1] = TaskTipsVo.New()
taskVo.taskTips[1].type = TaskTipType.TYPE0
taskVo.taskTips[1].id = cfg.npc_id
taskVo.taskTips[1].sceneId = cfg.scene_id
taskVo.taskTips[1].need_find_way = 1
taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
-------------------------
local basedata=ConfigItemMgr.Instance:GetTaskData(70010001)
if basedata then
taskVo.award_list = stringtotable(basedata.award_list)
end
for k,v in pairs(taskVo.award_list) do
if tonumber(v[2]) == 100007 then
v[3] = v[3] + NewMainRoleModel:getInstance():GetRoleActivityBaseExp( ) * DailyModel:GetInstance():GetBackAwardPer( 300, 1 )
end
end
-------------------------
return taskVo
end
end
--获取社团任务提示
function TaskModel:GetGuildTipTask( )
if self:CanAcceptCircleTask(TaskType.GUILD_LINE) then
--当日社团任务任务未做
local taskVo = TaskVo.New()
taskVo.level = Config.ConfigOpenLv.Other.guild_task
local str = TaskModel.TaskTypeStr3[TaskType.GUILD_LINE]
local cfg = self:GetTaskAcceptNpcConfig(TaskType.GUILD_LINE)
local temp = ConfigItemMgr.Instance:GetNpcItem(cfg.npc_id)
if not temp then return end
taskVo.description = "凡是会长说的!砸锅卖铁也要干——《社团成员守则节选》!每10环社团任务还会有特殊阶段奖励!撸起袖子加油吧!每周一凌晨4点重置社团任务!"
taskVo.taskName = string.format("%s任务", str)
taskVo.task_name = string.format("%s任务", str)
taskVo.type = TaskType.GUILD_LINE
taskVo.isTipTask = true
taskVo.target_num = 0
taskVo.order = 0
taskVo.need_find_way = 1
taskVo.id = Config.ConfigTaskEffect.guildTaskTipId
taskVo.task_id = Config.ConfigTaskEffect.guildTaskTipId
taskVo.tips = string.format("寻找<color=#2CF66F>%s</color>", Trim(temp.name))
taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type] --任务类型排序
taskVo.taskTips = {}
taskVo.taskTips[1] = TaskTipsVo.New()
taskVo.taskTips[1].type = TaskTipType.TYPE0
taskVo.taskTips[1].id = cfg.npc_id
taskVo.taskTips[1].sceneId = cfg.scene_id
taskVo.taskTips[1].need_find_way = 1
taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
-------------------------
local basedata=ConfigItemMgr.Instance:GetTaskData(60010001)
if basedata then
taskVo.award_list = stringtotable(basedata.award_list)
end
for k,v in pairs(taskVo.award_list) do
if tonumber(v[2]) == 100007 then
v[3] = v[3] + NewMainRoleModel:getInstance():GetRoleActivityBaseExp( ) * DailyModel:GetInstance():GetBackAwardPer( 300, 2 )
end
end
-------------------------
return taskVo
end
end
--获取特殊支线步骤
function TaskModel:GetExtendSpecialTip( task )
if task and task.taskTips then
for k,v in pairs(task.taskTips) do
if Config.ConfigTaskEffect.NeedClickTaskType[v.type] then
return v
end
end
end
end
-- 获取下一阶段转职任务(不可接取的情况)
function TaskModel:GetTurnTipTask( )
local mainVo = RoleManager.Instance.mainRoleInfo
-- 当前【转职任务】阶数为0,表示当前还没开始转职任务的第一阶段,第一阶段要到达对应等级直接接任务开始
if not mainVo.turn_stage or mainVo.turn_stage == 0 then return nil end
local taskVo = nil
local key = (mainVo.turn+1).."@"..(mainVo.turn_stage+1)
local task_cfg = Config.Transfer[key]
if task_cfg and task_cfg.need_lev > mainVo.level then -- 要确定当前确实不可以接这个任务
local basedata = ConfigItemMgr.Instance:GetTaskData(tonumber(task_cfg.task_id))
taskVo = TaskVo.New()
taskVo.level = task_cfg.need_lev
local str = TaskModel.TaskTypeStr3[TaskType.TRUN_LINE]
taskVo.description = "%s级可继续转职任务"
taskVo.taskName = Trim(basedata.name)
taskVo.type = TaskType.TRUN_LINE
taskVo.isTipTask = true
taskVo.cur_num = mainVo.level
taskVo.target_num = task_cfg.need_lev
taskVo.order = 0
taskVo.need_find_way = 0
taskVo.id = task_cfg.task_id
taskVo.tips = string.format("<color=#2CF66F>%s</color>级继续任务", task_cfg.need_lev)
taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type] or 99 --任务类型排序
-- taskVo.tipContent="<color="..TaskModel.Color.WHITE..">("..taskVo.cur_num.."/"..taskVo.target_num..")</color>"
taskVo.tipContent=string.format("<color=#2CF66F>%s</color>级继续任务(<color=#f14041>%s</color>/%s)",
task_cfg.need_lev, taskVo.cur_num, taskVo.target_num)
taskVo.taskTips = {}
-- taskVo.taskTips[1] = TaskTipsVo.New()
-- taskVo.taskTips[1].type = TaskTipType.TYPE0
-- taskVo.taskTips[1].id = cfg.npc_id
-- taskVo.taskTips[1].sceneId = cfg.scene_id
-- taskVo.taskTips[1].need_find_way = 1
-- taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
end
return taskVo
end
function TaskModel:GetTreasureTask(type)
self.treasure_task_list = self.treasure_task_list or {}
if not self.treasure_task_list[type] then
local treasure_task = TaskVo.New()
treasure_task.id = Config.ConfigTaskEffect.TreasureMapTaskId
treasure_task.level = 1
treasure_task.type = TaskType.TREASURE
treasure_task.sub_type = type
treasure_task.taskName = type == TreasureMapConst.Normal and "普通藏宝图" or "高级藏宝图"
treasure_task.tipContent = ""
treasure_task.isSend = 1;
treasure_task.acceptType = 0
treasure_task.tipType = TaskType.TREASURE
treasure_task.isFake = true
treasure_task.sortKey = Config.ConfigTaskEffect.TaskTypeSort[TaskType.TREASURE]
treasure_task.taskTips = {}
treasure_task.taskTips[1] = TaskTipsVo.New()
treasure_task.taskTips[1].type = TaskTipType.TYPE0
treasure_task.taskTips[1].id = 0
treasure_task.taskTips[1].sceneId = 0
treasure_task.taskTips[1].need_find_way = 1
treasure_task.tipParam = {TaskType.TREASURE, 0, 0, 0};
self.treasure_task_list[type] = treasure_task
end
return self.treasure_task_list[type]
end
--获取当前的主线任务id 协议返回的是上一个完成的任务id, 加1就行了, 用于判断任务开放的功能
function TaskModel:GetMainTaskId( )
return self.last_finish_task_id + 1
end
--获取该npc的任务状态
function TaskModel:GetNpcState( npc_id )
for k,v in ipairs(self.all_task_list) do
if v.taskTips and (v.type==TaskType.GUILD_LINE or v.type==TaskType.BOUNTY_LINE) then
local len = #v.taskTips
local start_npc = 0 --非对话步骤,没有npc_id,判断是否和开始npc一样就行了
for m,n in ipairs(v.taskTips) do
if n.type==TaskTipType.TYPE8 or n.type==TaskTipType.TYPE7 then
start_npc = n.id
break
end
end
-------------------------
if npc_id == v.tipParam[3] then
-------------------------
for m,n in ipairs(v.taskTips) do
if (n.isFinish==0 or m==len) then
if n.type==TaskTipType.TYPE8 or n.type==TaskTipType.TYPE7 then
if n.id==npc_id then
return 1
end
elseif n.type == TaskTipType.TYPE9 then
if n.id==npc_id then
return 3
end
elseif n.type == TaskTipType.TYPE38 then
if n.id==npc_id then
return 3
end
else
if npc_id == start_npc then
return 2
end
end
end
end
end
end
end
end
--开始做日常任务
function TaskModel:DoBountyTask( )
local task
if self:HasBountyRed() then
task = self:GetBountyTipTask()
else
task = self:GetTaskByType(TaskType.BOUNTY_LINE)
end
self:TaskClickFun(task)
end
--开始做社团任务
function TaskModel:DoGuildTask( )
local task
if self:HasGuildRed() then
task = self:GetGuildTipTask()
else
task = self:GetTaskByType(TaskType.GUILD_LINE)
end
self:TaskClickFun(task)
end
--是否自动做的任务
function TaskModel:IsAutoDoTask( task )
if task and task.type and task.type==TaskType.LIMIT_LINE then
return false
end
if task and (task.id == Config.ConfigTaskEffect.bountyTaskTipId or task.id == Config.ConfigTaskEffect.guildTaskTipId) then
return true
end
if task and task.tipParam and task.tipParam[1] then
if task.tipParam[1]==TaskTipType.TYPE2 then
if task.type == TaskType.EXTENSION_LINE then
--社团和赏金的副本是需要自动做的
return false
else
return true
end
else
return not Config.ConfigTaskEffect.NotNeedAutoTaskType[task.tipParam[1]]
end
end
end
--是否点一下才能完成的支线任务
function TaskModel:IsNeedClickTask( task )
if task and task.tipParam and task.tipParam[1] then
if task.tipParam[1]==TaskTipType.TYPE2 then
if task.type == TaskType.EXTENSION_LINE then
return true
else
return false
end
else
return Config.ConfigTaskEffect.NeedClickTaskType[task.tipParam[1]]
end
end
end
--是否点一下才能完成的支线任务 步骤
function TaskModel:IsNeedClickTipTask( tip_type, task_type )
if tip_type==TaskTipType.TYPE2 then
if task_type == TaskType.EXTENSION_LINE then
return true
else
return false
end
else
return Config.ConfigTaskEffect.NeedClickTaskType[tip_type]
end
end
--判断是否有转职任务
function TaskModel:HasTurnLine( )
for k,v in pairs(self.all_task_list) do
if v.type == TaskType.TRUN_LINE then
return true
end
end
end
----- 转职任务相关特殊处理 -----
-- 当前任务是否需要打开转职引导界面
function TaskModel:NeedOpenTurnMainView(task_vo)
if not task_vo then return true end
if Config.ConfigTaskEffect.OpenMainTurnTaskViewId[task_vo.id] then return true end
return false
end
-- 是否是可以继续自动进行的转职任务
function TaskModel:NeedAutoDoTurnTask(task_vo)
-- 打怪任务之外,其他的任务均不可自动继续
if not task_vo then return false end
local taskTipVO = task_vo.taskTips and task_vo.taskTips[1]
if taskTipVO and taskTipVO.type == TaskTipType.TYPE1 then --击败怪物
return true
end
if taskTipVO and taskTipVO.isFinish == 1 then -- 任务已经完成,可以自动前往
return true
end
return false
end
-- 记录完成转职任务时的等级,用于判断后续接取的任务是不是在卡级阶段
-- 是的话则不自动进行任务
function TaskModel:RecordProcessingTurnTaskLevel( )
self.recorded_finish_turn_task_lv = RoleManager.Instance.mainRoleInfo.level
end
-- 当前接取到的转职任务是否时卡级阶段
function TaskModel:IsNewTurnTaskInLimitLv( )
-- print("Saber:TaskModel [2699] self.recorded_finish_turn_task_lv: ",self.recorded_finish_turn_task_lv)
-- print("Saber:TaskModel [2700] RoleManager.Instance.mainRoleInfo.level: ",RoleManager.Instance.mainRoleInfo.level)
return self.recorded_finish_turn_task_lv < RoleManager.Instance.mainRoleInfo.level
end
----- 转职任务相关特殊处理 -----
--是否在等待30003或者30004, 如果请求了这两条, 返回后才刷新界面和做任务,否则可能数据是旧的
function TaskModel:IsWaitProto( )
return self.wait_30003 or self.wait_30004
end
function TaskModel:HideRoleWeapon( )
--采集完武器,显示武器模型
local role = Scene.Instance:GetMainRole()
if role then
if self:IsHideMainRoleWeapon() then
role:HideAllWeapon(Character.WeaponHideFlag.Story)
else
role:ShowAllWeapon(Character.WeaponHideFlag.Story)
end
end
end
--获取任务面板的支线数据
function TaskModel:GetExtensionTabData()
local tab_data = {
[1] = {main_tab = "已接支线", sub_tab = {}},
[2] = {main_tab = "可接支线", sub_tab = {}},
}
local one = {}
local data1 = {}
local two = {}
local data2 = {}
self.all_task_list = self:SortFun(self.all_task_list)
for i,v in ipairs(self.all_task_list) do
if v.type == TaskType.EXTENSION_LINE then
if v.acceptType == 0 then
table.insert(data1, v)
else
table.insert(data2, v)
end
end
end
tab_data[1].sub_tab = data1
tab_data[2].sub_tab = data2
return tab_data
end
function TaskModel:GetDoubleExp(id)
local exp = 0
local level = 0
local playerLv = RoleManager:getInstance():GetMainRoleVo().level
for index,data in pairs(Config.Taskexpmodulelv) do
if data.module_id == id and playerLv >= data.min_lv and playerLv <= data.max_lv then
exp = data.exp
break
end
end
if exp ~= 0 then
local curr_exp = RoleManager.Instance.mainRoleInfo.exp
local total_exp = curr_exp + exp
local need_exp = Config.Exp[playerLv].exp
--如果不够一级
if total_exp < need_exp then
level = GetPreciseDecimal(exp / need_exp,1)
elseif total_exp == need_exp then
level = 1
else
local len = #Config.Exp - 1 --最后一级是 0
local lv_exp = nil
for i = playerLv,len do
lv_exp = Config.Exp[i].exp
if total_exp > lv_exp then
level = level + 1
total_exp = total_exp - lv_exp
else
level = level + GetPreciseDecimal(total_exp / lv_exp,1)
break
end
end
end
end
if level <= 0.1 then
level = 0.1
end
return exp,level
end
function TaskModel:SetTaskAutoFlag(bool)
self.is_auto_task = bool
end
--获取是否自动任务中
function TaskModel:GetTaskAutoFlag()
return self.is_auto_task
end
function TaskModel:IsLoseAutoTaskDungeon(dun_id)
if SceneManager.Instance:IsGodHoodDungeon(dun_id) or SceneManager.Instance:IsGemDungeon(dun_id) then
return true
end
return false
end
--主线是否完成
function TaskModel:IsMainTaskFinish(task_id)
if task_id <= self.last_finish_task_id then
return true
end
return false
end
--主线是否完成
function TaskModel:IsEnterDungeonTask()
local task = TaskModel:getInstance():GetCurTask()
if task then
for k,v in pairs(task.taskTips) do
if v.isFinish == 0 then
if v.type==TaskTipType.TYPE2 then
return true
else
return false
end
end
end
end
return false
end
--主线是否完成
function TaskModel:CanDoTaskInEveryScene(param)
local array=Split(param,",")
if array and #array > 0 then
local type = tonumber(array[1])
if Config.ConfigTaskEffect.NeedClickTaskType[type] then
--点击判断是否已经完成任务,是的话发协议完成任务
local task = TaskModel:getInstance():GetTaskById(tonumber(array[4]))
if self:IsNeedClickTask(task) then
local tip = self:GetExtendSpecialTip(task)
if tip and tip.isFinish==1 then
return true
end
end
end
if type == TaskTipType.TYPE41 or type == TaskTipType.TYPE25 or type == TaskTipType.TYPE101 or type == TaskTipType.TYPE104 or type == TaskTipType.TYPE105 or
type == TaskTipType.TYPE106 or type == TaskTipType.TYPE108 or type == TaskTipType.TYPE109 or type == TaskTipType.TYPE110 or type == TaskTipType.TYPE23 or
type == TaskTipType.TYPE24 or type == TaskTipType.TYPE26 then
return true
end
end
return false
end
--获取接取任务的npc配置
function TaskModel:GetTaskAcceptNpcConfig(task_type)
local npc_cfg = Config.ConfigTaskEffect.npc
if KfWorldModel:GetInstance():IsKFCityOpen() then
npc_cfg = Config.ConfigTaskEffect.kfNpc
end
if task_type then
return npc_cfg[task_type]
else
return npc_cfg
end
end
--主线是否完成
function TaskModel:SetNeedTaskFlag(bool)
self.need_task = bool
end
--主线是否完成
function TaskModel:NeedShowExtendTip()
local playerLv = RoleManager:getInstance():GetMainRoleVo().level
if playerLv > 150 then
return false
end
for index,taskVO in pairs(self.all_task_list) do
if taskVO.type == TaskType.MAIN_LINE or taskVO.type == TaskType.BOUNTY_LINE or taskVO.type == TaskType.GUILD_LINE or taskVO.type == TaskType.TRUN_LINE then
return false
end
end
if self:GetBountyTipTask() or self:GetGuildTipTask() then
return false
end
return true
end
function TaskModel:NeedFindWayTask(type)
local need = false
if type == TaskTipType.TYPE0 or type == TaskTipType.TYPE7 or type == TaskTipType.TYPE8 or
type == TaskTipType.TYPE9 or type == TaskTipType.TYPE1 or type == TaskTipType.TYPE18 or
type == TaskTipType.TYPE6 or type == TaskTipType.TYPE2 or type == TaskTipType.TYPE38 then
need = true
end
return need
end
function TaskModel:SetCollectTaskId(task_id)
self.collect_task_id = task_id
end
function TaskModel:ClearCollectTaskId()
self.collect_task_id = false
end
function TaskModel:GetCollectTaskId()
return self.collect_task_id
end
function TaskModel:IsTaskFinished( id )
if self.finish_task_list then
local flag = false
if self.finish_task_list[id] then
flag = true
end
return flag
end
end
function TaskModel:SetFinishTaskList( list )--已完成任务列表
self.finish_task_list = list
GlobalEventSystem:Fire(TaskEvent.ANS_FINISHED_TASK_LIST)
end
function TaskModel:AddFinishTask( id )
local story_id = Config.ConfigTaskEffect.TaskStoryID[id]
if story_id then
self:SetTriggerStoryId(story_id)
end
self.finish_task_list[id] = id
if self.task_listen_list and self.task_listen_list[id] then
GlobalEventSystem:Fire(TaskEvent.ANS_FINISHED_TASK_LIST,id)
end
end
function TaskModel:SetTriggerStoryId( id )
self.trigger_story_id = id
end
function TaskModel:GetTriggerStoryId( )
return self.trigger_story_id
end
-- 2019年11月4日新增 : 获取可选任务内容配置
function TaskModel:GetOptionalTaskCfg(task_id)
if not task_id then return nil end
local talk_cfg = {}
local choose_talk_cfg = Config.Choosetalk[task_id]
if choose_talk_cfg then
talk_cfg.intellect = choose_talk_cfg.intellect
talk_cfg.nastic = choose_talk_cfg.nastic
talk_cfg.indecision = choose_talk_cfg.indecision
talk_cfg.value = choose_talk_cfg.value
talk_cfg.talk_list = {}
-- 让对话id小的在前
-- 1 理性, 2,感性 3中性
local temp = {}
temp[choose_talk_cfg.intellect] = 1
temp[choose_talk_cfg.nastic] = 2
if choose_talk_cfg.indecision then -- 不一定有第三个选项
temp[choose_talk_cfg.indecision] = 3
end
for k,v in pairsByKeys(temp) do
local index = #talk_cfg.talk_list+1
talk_cfg.talk_list[index] = ConfigItemMgr.Instance:GetTalkItem(k)
talk_cfg.talk_list[index].choose_type = v
end
-- if choose_talk_cfg.intellect < choose_talk_cfg.nastic then
-- talk_cfg.intellect_first = true
-- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.intellect)
-- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.nastic)
-- else
-- talk_cfg.intellect_first = false
-- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.nastic)
-- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.intellect)
-- end
-- talk_cfg.reback = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.reback)
else
return nil
end
return talk_cfg
end
-- 根据npcid获取目标npc身上的任务
function TaskModel:GetTaskDataByNpcId(npc_id)
local tb = {}
if not npc_id then return tb end
for k, task_vo in pairs(self.all_task_list) do
if task_vo.end_npc == npc_id then
tb[#tb+1] = task_vo
end
end
return tb
end
--动态任务内容配置
function TaskModel:DynamicTaskConf( task_id )
for k,v in pairs(Config.Typetaskdynamic) do
if v.task_id == task_id then
return v
end
end
end
--取得包含该副本id的任务信息
function TaskModel:GetTaskVoByDungeonID( dun_id )
for i,v in ipairs(self.all_task_list) do
if v.tipParam then
local task_tip_type = v.tipParam[1]
local is_dun_type = task_tip_type == TaskTipType.TYPE2 or task_tip_type == TaskTipType.TYPE102
local dun_id_in_task_info = v.tipParam[3]
if is_dun_type and dun_id_in_task_info == dun_id then
--副本类型的任务
return v
end
end
end
return nil
end
--新手期显示章节任务UI
function TaskModel:IsShowChapterTask( )
return not self:IsTaskFinished(Config.ConfigTaskEffect.LastChapterTaskId)
end
--设置切换场景类型,任务寻路的时候,走到传送阵的时候传送类型是4(无视场景数量,直达最终场景)
function TaskModel:SetChangeSceneType( type, find_vo )
self.task_change_scene_type = type
self.task_change_scene_vo = find_vo
end
function TaskModel:GetChangeSceneType( )
return self.task_change_scene_type, self.task_change_scene_vo
end
--获取任务栏item的高度
function TaskModel:GetTaskItemHeight( data )
local temp_height = 52 --一行文本
if not data then
return temp_height
end
if data.tipType == TaskTipType.TYPE40 then --商城购买支线
if data.is_money_enough or self:IsTaskProgressFinish(data) then
temp_height = 72 --两行文本
else
temp_height = 92 --三行文本
local equip_type = EquipModel:getInstance():GetEquipType( data.tipParam[3] )
if equip_type then
local type_const = EquipModel.EquipType
if equip_type == type_const.Guard or equip_type == type_const.LeftRing
or equip_type == type_const.RightRing or equip_type == type_const.Necklace then
-- 守护戒指耳饰类--项链类
temp_height = 72
end
end
end
elseif data.tipType == TaskTipType.TYPE1002 then -- 成就
local str = DeleteColorTag(data.tipContent)
local str_width = self:CalStrWidth(str)
local per_width = 188
local line_count = math.ceil(str_width / per_width)
-- print('Msh:TaskModel.lua[2664] data', str_width, per_width, str)
if line_count == 1 then
temp_height = 52
elseif line_count == 2 then
temp_height = 72
elseif line_count == 3 then
temp_height = 92
end
elseif data.tipType == TaskTipType.TYPE42 then --亲密度支线
temp_height = 72
elseif data.tipType == TaskTipType.TYPE100 then--赏金幻魔
temp_height = 72
elseif data.tipType == TaskTipType.TYPE102 then --完成某副本类型
if data.tipParam[3] == BaseDungeonModel.DUN_TYPE.PersonBoss then
temp_height = 72
end
elseif data.tipType == TaskTipType.TYPE24 then --活跃度
temp_height = 72
-- elseif data.type == TaskType.BOUNTY_LINE or data.type == TaskType.GUILD_LINE then --跑环支线
-- temp_height = 72 --一行文本+按钮
elseif data.tipType == TaskTipType.TYPE57 then --完成预期任务
temp_height = 72
elseif data.tipType == TaskTipType.TYPE48 then --晒娃
temp_height = 72
elseif data.tipType == TaskTipType.TYPE58 then --宝宝同心值
temp_height = 72
elseif data.tipType == TaskTipType.TYPE59 then --战力
temp_height = 72
elseif TaskModel.TaskTurnBossTaskId[data.id] then--转职任务boss战任务id
temp_height = 72
end
return temp_height
end
--当前存在此任务列表,并且 有一个任务没完成
function TaskModel:IsTaskListUnFinished(task_list)
if not task_list or #task_list == 0 then
return false
end
local is_all_finished = true
for k,v in pairs(task_list) do
for ii,vv in ipairs(self.all_task_list) do
if vv.id == v then
return true
end
end
end
return false
end
--是否完成了前面一个任务,并且没完成后面一个任务
function TaskModel:IsBetweenTaskListState(task_list)
if not task_list or #task_list ~= 2 then
return false
end
local b = false
local pre_task_id, next_task_id = task_list[1], task_list[2]
if self:IsTaskFinished(pre_task_id) and not self:IsTaskFinished(next_task_id) then
b = true
end
return b
end
--是否可领取跑环奖励
function TaskModel:CanCircleReward( task_type )
if not task_type then return end
local info = self:GetCircleTaskInfo(task_type)
if not info then
return false
end
local reward_progress = info and info.reward_progress or 0
if reward_progress == 0 and info.cur_progress >= 10 then
return reward_progress
elseif reward_progress <= 1 and info.cur_progress >= 20 then
return reward_progress
end
return false
end
--跑环的十环领取任务
function TaskModel:GetCircleExtraTask( task_type )
if not task_type then return end
local can_reward = self:CanCircleReward( task_type ) and true or false
if can_reward then
--可领取十环奖励
local taskVo = TaskVo.New()
taskVo.level = 1
local str = TaskModel.TaskTypeStr3[task_type]
local cfg = self:GetTaskAcceptNpcConfig(task_type)
local temp = ConfigItemMgr.Instance:GetNpcItem(cfg.npc_id)
if not temp then return end
taskVo.description = "每完成10环有特殊奖励!"
taskVo.taskName = string.format("%s任务", str)
taskVo.task_name = string.format("%s任务", str)
taskVo.type = task_type
taskVo.isTipTask = true
taskVo.need_find_way = 1
taskVo.target_num = 0
taskVo.order = 0
taskVo.id = Config.ConfigTaskEffect.circleRewardTaskId[task_type]
taskVo.task_id = Config.ConfigTaskEffect.circleRewardTaskId[task_type]
taskVo.tips = "领取环数奖励"--string.format("寻找<color=#2CF66F>%s</color>", Trim(temp.name))
taskVo.sortKey = 0 --任务类型排序
taskVo.taskTips = {}
taskVo.taskTips[1] = TaskTipsVo.New()
taskVo.taskTips[1].type = TaskTipType.TYPE0
taskVo.taskTips[1].id = cfg.npc_id
taskVo.taskTips[1].sceneId = cfg.scene_id
taskVo.taskTips[1].need_find_way = 1
taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
taskVo.award_list = {}
-------------------------
return taskVo
end
end
----------推荐成就-start---------
-- 直接拉取
function TaskModel:SetAchiTaskVo( list )
local level = RoleManager.Instance.mainRoleInfo.level
if level < 150 then return end
--如果所有的任务数量,超过6个则不显示可接的成就,否则填充至6个(已经完成的,不算最大数量里面)
local cur_task_count = #list
local max_can_get_achitask_count = 6
local achieve_model = AchieveModel:getInstance()
local can_get_list = achieve_model:GetCanGetAchiList() or {}
for i, v in pairs(can_get_list) do
local taskVo = TaskVo.New()
taskVo.type = TaskType.ACHIEVE
taskVo.tipContent = Trim(v.desc) .. "" .. achieve_model:ParseCondition( v )
taskVo.taskName = Trim(v.name)
taskVo.achi_data = v
taskVo.progress_data = achieve_model:GetTargetAchieveData(v.type, v.sub_type)
taskVo.tipType = TaskTipType.TYPE1002
taskVo.task_position = 0
taskVo.progressState = 1
taskVo.achieve_id = v.type * 10000000000 + v.sub_type
table.insert(list, taskVo)
end
--超过最大数量,就不添加了
if cur_task_count >= max_can_get_achitask_count then return end
local recommend_achi = achieve_model:GetRecommendAchiList() or {}
for pos,v in pairs(recommend_achi) do
local taskVo = TaskVo.New()
taskVo.type = TaskType.ACHIEVE
taskVo.tipContent = Trim(v.desc) .. achieve_model:ParseCondition( v )
taskVo.taskName = Trim(v.name)
taskVo.achi_data = v
taskVo.progress_data = achieve_model:GetTargetAchieveData(v.type, v.sub_type)
taskVo.tipType = TaskTipType.TYPE1002
taskVo.task_position = pos
taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type]
taskVo.achieve_id = v.type * 10000000000 + v.sub_type
table.insert(list, taskVo)
--添加可接成就后,再去判断是否超过最大显示数量
cur_task_count = cur_task_count + 1
if cur_task_count >= max_can_get_achitask_count then break end
end
end
-- 日常活跃任务
function TaskModel:SetDailyActiviteTaskVo( list )
local level = RoleManager.Instance.mainRoleInfo.level
if level < Config.ConfigTaskEffect.DailyTaskActiviteCheckLevel then return end
local is_show_task_finish = TaskModel:getInstance():IsTaskFinished(Config.ConfigTaskEffect.DailyCircleShowTaskId)
if not is_show_task_finish then return end
local daily_model = DailyModel.getInstance()
local show_data = daily_model:GetCommonShowList() or {}
local daily_list = {}
self.cur_tips_daily_task_item = false
for i,v in ipairs(show_data) do
local taskVo = TaskVo.New()
-- print('Ych:TaskModel.lua[3107] data', data)
-- PrintTable(v)
local task_max = v.show_max_times and v.show_max_times or v.max_times
local cur_num, max_num = daily_model:DailyCommonTipsCurNumAndMaxNum(v)
if cur_num < max_num then
local key = v.module .. "@" .. v.module_sub
local cfg = Config.ConfigTaskEffect.DailyActiviteTask[key]
if cfg then
if cfg.recommend == 1 and (not self.cur_tips_daily_task_item or self.cur_tips_daily_task_item.order < cfg.order) then
self.cur_tips_daily_task_item = cfg
end
taskVo.type = TaskType.DAILY_ACTIVITE
taskVo.tipContent = Trim(cfg.desc)
taskVo.taskName = Trim(cfg.name)
taskVo.achi_data = v
taskVo.progress_data = 1
taskVo.tipType = TaskTipType.TYPE9998
taskVo.task_position = 0
--竞技场如果处于冷却,排序要降低
if v.module == 280 and v.module_sub == 0 then
local is_cd, cd_time = PkRankModel.getInstance():GetChallengeCd()
if is_cd then
taskVo.order = 1
else
taskVo.order = cfg.order
end
--赏金幻魔显示购买次数的时候,置底,并且在竞技场之上
elseif v.module == 460 and v.module_sub == 3 then
local left_count, all_count = BossModel:GetInstance():GetMoneyLeftCount()
if left_count > 0 then
taskVo.order = cfg.order
else
taskVo.order = 2
end
else
taskVo.order = cfg.order
end
taskVo.progressState = 0
taskVo.id = 19000000000 + v.module * 100 + v.module_sub
taskVo.module = v.module
taskVo.module_sub = v.module_sub
table.insert(list, taskVo)
end
end
end
end
-- 更新任务数据
function TaskModel:UpdateSingleAchiTaskVo( taskVo )
local achieve_model = AchieveModel:getInstance()
local recommend_data = achieve_model:GetRecommendAchiList()[taskVo.task_position] or {}
if not recommend_data.name then return end
taskVo.tipContent = Trim(recommend_data.desc) .. "" .. achieve_model:ParseCondition( recommend_data )
taskVo.taskName = Trim(recommend_data.name)
taskVo.achi_data = recommend_data
taskVo.progress_data = achieve_model:GetTargetAchieveData(recommend_data.type, recommend_data.sub_type)
end
-- 更新任务数据
function TaskModel:UpdateAchiTaskVo( taskVo_list )
for i,v in ipairs(taskVo_list) do
if v.type == TaskType.ACHIEVE and v.task_position > 0 then -- 只更新推荐任务栏
self:UpdateSingleAchiTaskVo(v)
end
end
end
-- 是否是功能型开放任务
function TaskModel:IsFuncOpenTask( task_vo )
local b = false
if task_vo and Config.ConfigTaskEffect.ModuleOpenTask[task_vo.id] then
b = true
end
return b
end
-- 是否是高排序型任务(order 1000 <= order <= 9999)
function TaskModel:IsHighOrderTask( task_vo )
local b = false
if task_vo and task_vo.order >= 1000 and task_vo.order <= 9999 then
b = true
end
return b
end
-- 是否是第二排序任务(order 1000 <= order <= 9999)
function TaskModel:IsSecondOrderTask( task_vo )
local b = false
if task_vo and task_vo.order >= 501 and task_vo.order <= 999 then
b = true
end
return b
end
-- 是否是日常活跃任务
function TaskModel:IsDailyActiviteTask( task_vo )
local b = false
if task_vo and task_vo.type == TaskType.DAILY_ACTIVITE then
b = true
end
return b
end
-- 是否是日常活跃任务中的护送任务
function TaskModel:IsDailyActiviteEscortTask( task_vo )
local b = false
if task_vo and task_vo.type == TaskType.DAILY_ACTIVITE and task_vo.module == 500 and task_vo.module_sub == 0 then
b = true
end
return b
end
-- 是否是日常活跃任务中的竞技场任务
function TaskModel:IsDailyActivitePkrankTask( task_vo )
local b = false
if task_vo and task_vo.type == TaskType.DAILY_ACTIVITE and task_vo.module == 280 and task_vo.module_sub == 0 then
b = true
end
return b
end
-- 是否是第三排序任务(order 1 <= order <= 500)
function TaskModel:IsThirdOrderTask( task_vo )
local b = false
if task_vo and task_vo.order >= 1 and task_vo.order <= 500 then
b = true
end
return b
end
-- 知否是购买型支线,并且已经完成,或者满足完成条件
function TaskModel:IsBuyGoodsTaskFinished( task_vo )
local b = false
if task_vo and task_vo.type == TaskType.EXTENSION_LINE and task_vo.taskTips then
for key, taskTipVO in ipairs(task_vo.taskTips) do
if taskTipVO.type == TaskTipType.TYPE40 then
local need_money = taskTipVO.sceneId --需要的价格
local shop_key_id = taskTipVO.scene_x --商品id
local money_type = Config.Shop[shop_key_id] and Config.Shop[shop_key_id].ctype --商品消耗货币类型
local my_money = GoodsModel:getInstance():GetGoodsNumFromType(money_type) --我的商品消耗货币
if task_vo.progressState == 1 or taskTipVO.isFinish == 1 or my_money >= need_money then --已完成
b = true
end
end
end
end
return b
end
-- 计算任务的长度
function TaskModel:CalStrWidth( str )
local key_width = {
[1] = 14.84, -- 汉字
[2] = 4.88, -- "("
[3] = 8.26, -- 数字 1
[4] = 4.13, --"/"
}
local word_offset = 0.197
if not str then
return 0
end
local char_count = 0
local width = 0;
for i=1, #str do
local curByte = string.byte(str, i)
local temp_width = 0
if curByte == nil then
temp_width = 0
elseif curByte == 47 then -- "/"
temp_width = key_width[4]
char_count = char_count + 1
elseif curByte == 40 or curByte == 41 then -- "(" ")"
temp_width = key_width[2]
char_count = char_count + 1
elseif curByte>=48 and curByte<=57 then -- 数字
temp_width = key_width[3]
char_count = char_count + 1
elseif curByte>=224 and curByte<=239 then -- 汉字
temp_width = key_width[1]
char_count = char_count + 1
elseif curByte>=240 and curByte<=247 then -- 汉字
temp_width = key_width[1]
char_count = char_count + 1
end
width = width + temp_width
end
--print('Msh:TaskModel.lua[2871] data', char_count, (char_count - 8))
return width - (char_count - 8) * word_offset
end
----------推荐成就-end-----------
-- 是否可以去做主线
function TaskModel:CanSitchToMainLine( target_task_vo)
local is_can = false
local cur_main_task = target_task_vo or self:GetMainTask()
if cur_main_task and RoleManager.Instance.mainRoleInfo.level >= cur_main_task.level then
local cur_tips_task_id = cur_main_task.tipParam and cur_main_task.tipParam[3] or -1
-- print('Ych:TaskModel.lua[3296] data', data)
-- PrintTable(cur_main_task)
for k,v in pairs(cur_main_task.taskTips) do
if cur_tips_task_id == v.id then
if v.type == TaskTipType.TYPE7 or
v.type == TaskTipType.TYPE8 or
v.type == TaskTipType.TYPE9 or
v.type == TaskTipType.TYPE1 then
is_can = true
end
break
end
end
--print('Ych:TaskModel.lua[3308] data', is_can)
end
return is_can
end
-- 是否可以去做主线
function TaskModel:JustDoMainLine( )
local cur_main_task = self:GetMainTask()
if cur_main_task and RoleManager.Instance.mainRoleInfo.level >= cur_main_task.level then
self.now_task_id = false
self:SetTaskAutoFlag(true)
GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true, true)
end
end
-- 是否可以日常跑环
function TaskModel:CanSitchToDailyCircleTask( )
local task_data = self:GetTaskByType(TaskType.BOUNTY_LINE)
if task_data then
return true
end
end
-- 是否可以日常跑环
function TaskModel:JustDoDailyCircleTask( )
local task_data = self:GetTaskByType(TaskType.BOUNTY_LINE)
if task_data then
self.now_task_id = task_data.id
self:SetTaskAutoFlag(true)
GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true)
end
end
function TaskModel:ShowMainLineTips(is_force)
local main_task = self:GetMainTask()
if main_task then
if (RoleManager.Instance.mainRoleInfo.level >= main_task.level) or is_force then
self.tip_new_main_line = main_task.id
GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE, 9993150002)
self:Fire(TaskEvent.SHOW_NEW_MAIN_LINE_TIP)
end
end
end
-- 第一次登陆游戏做任务
function TaskModel:FirstLoginGameToDotask( )
if self.is_first_login_game_to_do_task == true then
if RoleManager.Instance.mainRoleInfo.level <= Config.ConfigTaskEffect.DailyCircleTaskCheckLevel then
local is_open_daily,_,_,_,tips_content = self:GetDefalutTaskCurTaskAndDes()
if not (is_open_daily and not self.cur_tips_daily_task_item) then
self:ShowMainLineTips(true)
end
end
self.is_first_login_game_to_do_task = false
end
end
-- 获取第一条日常活跃任务的序号
function TaskModel:GetFirstDailyTaskIndex( )
local idx = 0
local task_list = self:GetMainUITaskData(true)
for i,v in ipairs(task_list) do
if v.type == TaskType.DAILY_ACTIVITE then
idx = i
break
end
end
return idx, #task_list
end
----------七日目标-start---------
-- 直接拉取
function TaskModel:SetSevenTargetTaskVo( list )
local level = RoleManager.Instance.mainRoleInfo.level
local seven_day_target_model = SevenDayTargetModel:getInstance()
-- 【少于105级】 或 【没开放七日目标】 都返回
-- print('=======Msh:TaskModel.lua[3451] =======', seven_day_target_model:IsSevenDayTargetOpen())
if level < 105 or not seven_day_target_model:IsSevenDayTargetOpen() then
return
end
-- 只拿最新那天
local login_day = seven_day_target_model:GetSevenDayTargetLoginDay()
local cfg = seven_day_target_model:GetSevenDayTargetTaskCFGByDay(login_day)
local server_data = seven_day_target_model:GetSevenDayTargetInfo(login_day) or {}
local total_num = TableSize(cfg)
local cur_num = 0
for i,v in pairs(server_data) do
local cfg = seven_day_target_model:GetSevenDayTargetTaskOneCFG(v.days, v.mod_id, v.sub_id)
if cfg then
if v.progress >= cfg.limit_times then
cur_num = cur_num + 1
end
end
end
-- 当天技能领完 就不用显示了
if total_num == cur_num and total_num > 0 then -- 进度满了 看看技能领没领
local skill_data = seven_day_target_model:GetSevenDayTargetSkillInfo() or {}
if skill_data[login_day] then -- 有技能数据就是领了
return
end
end
-- local color = cur_num == 0 and ColorUtil.RED_DARK or ColorUtil.GREEN_DARK
local taskVo = TaskVo.New()
taskVo.type = TaskType.SEVEN_DAY_TARGET
taskVo.tipContent = string.format("完成本日目标 (%s/%s)", HtmlColorTxt(cur_num, ColorUtil.GREEN_DARK), total_num)
taskVo.taskName = string.format('七日目标 【第%s日】', login_day)
taskVo.server_data = server_data
taskVo.total_num = total_num
taskVo.cur_num = cur_num
-- taskVo.seven_cfg = cfg
taskVo.tipType = TaskTipType.TYPE1004
taskVo.order = 501 -- 归为第二排序任务
taskVo.sortKey = 3 -- 排序刚好要在转职后面
-- taskVo.task_position = 0
-- taskVo.progressState = 1
-- taskVo.achieve_id = v.type * 10000000000 + v.sub_type
table.insert(list, taskVo)
end
----------七日目标-end-----------