require("game.contract.ContractModel") require("game.contract.ContractConst") require("game.contract.view.ContractSubView")--主界面 require("game.contract.view.ContractLvItem")--等级item require("game.contract.view.ContractBuyUnlockView")--购买解锁 require("game.contract.view.ContractTaskView")--任务界面 require("game.contract.view.ContractTaskItem")--任务item require("game.contract.view.ContractRewardView")--领奖结算 require("game.contract.view.ContractPreLookView")--奖励预览 require("game.contract.view.ContractBuyLevelView")-- 购买等级 ContractController = ContractController or BaseClass(BaseController, true) local ContractController = ContractController function ContractController:__init() ContractController.Instance = self self.model = ContractModel:getInstance() self:AddEvents() self:RegisterAllProtocal() end function ContractController:__delete() end function ContractController:AddEvents() local function on_game_start() self.model:Reset() end GlobalEventSystem:Bind(EventName.GAME_START, on_game_start) local function onLevelChange( level ) if level == Config.Modulesub["331@74"].open_lv then self:CheckRedDot() end end RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelChange) local function onSceneChangeHandler() self.model.need_open_fuli_view = false end self:Bind(SceneEventType.SCENE_CHANGED, onSceneChangeHandler) local function OPEN_CONTRACT_VIEW( ) if GetModuleIsOpen(331,74) then local temp_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.CONTRACT) for i,v in pairs(temp_list or {}) do local id = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000 + v.sub_type GlobalEventSystem:Fire(FuliConst.OPEN_FULI_MAIN_VIEW, id) return end end Message.show("活动未开启") end self.model:Bind(ContractConst.OPEN_CONTRACT_VIEW,OPEN_CONTRACT_VIEW) local function OPEN_TASK_VIEW( index,sub_type ) self.contracttaskview = self.contracttaskview or ContractTaskView.New() self.contracttaskview:Open(index,sub_type) end self.model:Bind(ContractConst.OPEN_TASK_VIEW,OPEN_TASK_VIEW) local function SHOW_REWARD_RESULT( data ) self.contractrewardview = self.contractrewardview or ContractRewardView.New() self.contractrewardview:Open(data) end self.model:Bind(ContractConst.SHOW_REWARD_RESULT,SHOW_REWARD_RESULT) local function SHOW_REWARD_LIST( sub_type,tag ) self.contractprelookview = self.contractprelookview or ContractPreLookView.New() self.contractprelookview:Open(sub_type,tag) end self.model:Bind(ContractConst.SHOW_REWARD_LIST,SHOW_REWARD_LIST) local function OPEN_UNLOCK_VIEW( sub_type ) self.contractbuyunlockview = self.contractbuyunlockview or ContractBuyUnlockView.New() self.contractbuyunlockview:Open(sub_type) end self.model:Bind(ContractConst.OPEN_UNLOCK_VIEW,OPEN_UNLOCK_VIEW) local function OPEN_BUY_LEVEL_VIEW( sub_type ) self.contractbuylevelview = self.contractbuylevelview or ContractBuyLevelView.New() self.contractbuylevelview:Open(sub_type) end self.model:Bind(ContractConst.OPEN_BUY_LEVEL_VIEW, OPEN_BUY_LEVEL_VIEW) end function ContractController:CheckRedDot( ) local function call_backack( ) self.model:GetAllRed(true) self.model:Fire(ContractConst.REFRESH_RED_DOT) ------------------------- local temp_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.CONTRACT) for i,v in pairs(temp_list or {}) do local id = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000 + v.sub_type FuliModel:getInstance():Fire(FuliConst.UPDATE_FULI_RED_DOT,id) FuliModel:getInstance():Fire(FuliConst.ANS_UPDATE_FULI_RED_DOT,id) end end TimeManager.GetInstance():StartTime("ContractController_CheckRedDot", 0.5, call_backack) end function ContractController:RegisterAllProtocal( ) local register_cfg = { [33232] = {--基础信息 req_event_data = {ContractConst.REQ_BASIC_DATA,"h"},req_func = false, handler = function(self,scmd)-- handler_manual if scmd.errcode == 1 then self.model:SetBasicData(scmd) self:CheckRedDot() self.model:Fire(ContractConst.ANS_BASIC_DATA) else -- ErrorCodeShow(scmd.errcode) end end, }, [33233] = {--任务完成进度 req_event_data = {ContractConst.REQ_TASK_PROCESS,"h"},req_func = false, handler = function(self,scmd)-- handler_manual self.model:SetTaskProcessInfo(scmd) self:CheckRedDot() self.model:Fire(ContractConst.ANS_TASK_PROCESS) end, }, [33234] = {--任务积分领取 req_event_data = {ContractConst.REQ_GET_TASK_SCORE,"hch"},req_func = false, handler = function(self,scmd)-- handler_manual if scmd.result == 1 then GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS) self.model:RefreshBasicLvAndScore(scmd) self:CheckRedDot() self.model:Fire(ContractConst.ANS_BASIC_DATA) else ErrorCodeShow(scmd.result) end end, }, [33235] = {--任务更新 handler = function(self,scmd)-- handler_manual self.model:RefreshTaskProcess(scmd.sub_type,scmd.update_tasks) self:CheckRedDot() self.model:Fire(ContractConst.ANS_TASK_PROCESS) end, }, [33236] = {--领取等级奖励 -- // 1等级奖励领取|2等级奖励一键领取 -- // 等级|一键时为0 req_event_data = {ContractConst.REQ_GET_REWARD,"hch"},req_func = false, handler = function(self,scmd)-- handler_manual if scmd.result == 1 then GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS) self.model:Fire(ContractConst.SHOW_REWARD_RESULT,scmd) self.model:Fire(ContractConst.REQ_BASIC_DATA,scmd.sub_type) else ErrorCodeShow(scmd.result) end end, }, [33237] = {--购买王牌宝典 --// 是否使用折扣卡 req_event_data = {ContractConst.REQ_PAY_FOR_UNLOCK, "hcc"},req_func = false, handler = function(self,scmd)-- handler_manual if scmd.result == 1 then Message.show("购买成功!") GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS) self.model:RefreshBasicPayStatus(scmd.sub_type,scmd.pay_state) self:CheckRedDot() self.model:Fire(ContractConst.ANS_PAY_FOR_UNLOCK) self.model:Fire(ContractConst.ANS_BASIC_DATA) self.model:Fire(ContractConst.SHOW_REWARD_LIST,scmd.sub_type,"after_buy") else ErrorCodeShow(scmd.result) end end, }, [33290] = {--等级购买 req_event_data = {ContractConst.REQ_BUY_LEVEL, "hhh"},req_func = false, handler = function(self,scmd)-- handler_manual if scmd.errcode == 1 then Message.show("购买成功!") self.model:Fire(ContractConst.REQ_BASIC_DATA, scmd.sub_type) else ErrorCodeShow(scmd.errcode) end end, }, } self:RegisterProtocalByCFG(register_cfg) end