DialogueModel=DialogueModel or BaseClass(EventDispatcher) --[[/** * 飞行副本ID */]] DialogueModel.FLY_COPY_ID=224 DialogueModel.TASK_TEXT="task_text" DialogueModel.INTO_TIMES="INTO_TIMES" DialogueModel.SELECT_TASK = "SELECT_TASK" DialogueModel.CLICK_ANSWER = "CLICK_ANSWER" DialogueModel.FLASH_INTO_TIMES="FLASH_INTO_TIMES" -- 请求刷新进入副本次数 DialogueModel.REQUEST_CCMD_EVENT = "DialogueModel.REQUEST_CCMD_EVENT" --请求协议 DialogueModel.CHOOSE_MESSAGE_EVENT = "DialogueModel.CHOOSE_MESSAGE_EVENT" --任务选项飘字提示 DialogueModel.CLICK_OK = "DialogueModel.CLICK_OK" --点击对话的确定 DialogueModel.MAIN_LINE_CLICK_OK = "DialogueModel.MAIN_LINE_CLICK_OK" --主线任务点击对话的确定 -- 没有对话时容错使用 DialogueModel.DEFAULT_TALK = {id = 1,total_content = 1,content = {[1] = {total_list = 1,id = 10002,list = {[1] = {type = 0,text = [[四大家族建立的魔法部掌握了能源水晶的开采权,非天赋者都必须接受他们的管理。]],other = [[]]}}}}} function DialogueModel:__init() DialogueModel.Instance=self self.copyTimesVoList = {} self.view_visible = {} self.hide_view = 0 --大于0就隐藏对话框 self.dialogue_is_open = false --对话框界面是否显示 self.ignore_double_exp_alert = false --是否不判断双倍经验领取 self.isAuto = false self.mult_select_task_id = nil self.cache_task_talk_id = {} -- 缓存已经触发过的任务id,避免重复触发 self.is_delay_show_main_task_tips = false --是否延时到场景切换完成后,在展示主线任务提示 self.is_delay_show_main_task_tips = false --是否已经弹过展示主线任务提示 end function DialogueModel:__delete() end function DialogueModel:getInstance() if DialogueModel.Instance==nil then DialogueModel.New() end return DialogueModel.Instance end function DialogueModel:GetDialogueId(npc_id) local npc_config = ConfigItemMgr.Instance:GetNpcItem(npc_id) local dialogueId = nil if npc_config then dialogueId = tonumber(npc_config.talk) --npc默认对话 end return dialogueId end --CopyTimesVo的指点 function DialogueModel:setIntoCopyTimes(copyTimesVo) self.copyTimesVoList[copyTimesVo.copyId] = copyTimesVo; self:Fire(DialogueModel.INTO_TIMES, copyTimesVo) end --返回CopyTimesVo function DialogueModel:getIntoCopyTimes(copyId) return self.copyTimesVoList[copyId] end --npc配置action中的任务type去过滤显示 function DialogueModel:FilterTheTaskBtn(task_type) local show = false -- local _type = task_type.type -- if _type == 1 or _type == 2 or _type == 3 then --社团护送 是否有足够社团职位显示这些任务,1接护送,2提升品质,3开车 -- show = ConvoyModel:GetInstance():HavUnionAuthority(task_type) -- else -- show = true -- end return show end -- 排序多任务列表内容 function DialogueModel:SortMultTaskList(task_list) if not task_list then return end local unfinish_tasks = {} -- 可领取奖励的任务表 local can_accept_tasks = {} -- 可接受任务的任务表 local other_tasks = {} -- 其他 for k, task_data in pairs(task_list) do if task_data.task_state == 3 then unfinish_tasks[#unfinish_tasks+1] = task_data elseif task_data.task_state == 1 then can_accept_tasks[#can_accept_tasks+1] = task_data else other_tasks[#other_tasks+1] = task_data end end local sort_func = function (a, b) if a.task_state == 3 then return a.task_time < b.task_time else local a_taskcfg = ConfigItemMgr.Instance:GetTaskData(a.task_id) local b_taskcfg = ConfigItemMgr.Instance:GetTaskData(b.task_id) return a_taskcfg.level < b_taskcfg.level end end table.sort(unfinish_tasks, sort_func) table.sort(can_accept_tasks, sort_func) table.sort(other_tasks, sort_func) return TableConcat(TableConcat(unfinish_tasks, can_accept_tasks), other_tasks) end function DialogueModel:SetMultSelectTaskID( id ) self.mult_select_task_id = id end function DialogueModel:GetMultSelectTaskID( ) return self.mult_select_task_id end function DialogueModel:CheckTaskTalkEvent( task_id ) if self.cache_task_talk_id[task_id] then return end self.cache_task_talk_id[task_id] = true local list = {} local temp_cfg = Config.Tasktalkevent for i,v in ipairs(temp_cfg) do if v.task == task_id then v.has_show = false list[#list+1] = v end end self:CancelTaskTalkTimer() self.cur_show_index = 1 self.temp_last_time = 0 --当前对话持续时间 local step_time = 0.5 local cfg local function on_show( ) self.temp_last_time = self.temp_last_time + step_time cfg = list[self.cur_show_index] if not cfg then self:CancelTaskTalkTimer() return end if not cfg.has_show then cfg.has_show = true self:ShowTaskTalkView(cfg) end if self.temp_last_time > cfg.delay+cfg.show_time then self.temp_last_time = 0 self.cur_show_index = self.cur_show_index + 1 end end if #list > 1 then if not self.show_task_talk_timer then self.show_task_talk_timer = GlobalTimerQuest:AddPeriodQuest(on_show, step_time, -1) end else on_show() end end function DialogueModel:ShowTaskTalkView( cfg ) if not cfg then return end local main_vo = RoleManager.Instance.mainRoleInfo local temp_head_type = cfg.talker == 0 and 1000+main_vo.career or cfg.talker local talk_cfg = ConfigItemMgr.Instance:GetTalkItem(cfg.talk) local temp_content = "" if talk_cfg and talk_cfg.content[1] and talk_cfg.content[1].list[1] then temp_content = WordManager:changeWords(talk_cfg.content[1].list[1].text) end local temp_head_name = cfg.talker == 0 and main_vo.name or cfg.name local data = { head_type = temp_head_type or 1000, desc = Trim(temp_content) or "", head_name = temp_head_name or "", hide_time = cfg.show_time or 1, dalay_time = cfg.delay or 0, is_task_type = true, } GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW,data) -- 个别需要音效 local sound_res if cfg.task == 10020 then sound_res = "guide_02" elseif cfg.task == 10160 then sound_res = "guide_05" elseif cfg.task == 10640 then sound_res = "guide_11" end if sound_res then local function on_delay( ) lua_soundM:PlayEffect(self, sound_res, false, LuaSoundManager.SOUND_TYPE.GUIDE) end setTimeout(on_delay, cfg.delay + 0.1) end end function DialogueModel:CancelTaskTalkTimer( ) if self.show_task_talk_timer then GlobalTimerQuest:CancelQuest(self.show_task_talk_timer) self.show_task_talk_timer = nil end end