require("game.light.LightModel") require("game.proto.147.Require147") require("game.light.view.LightSubView") require("game.light.view.LightTabItem") require("game.light.view.LightAttrItem") require("game.light.view.LightAttrItemTwo") require("game.light.view.LightAttrItemThree") require("game.light.view.LightItem") require("game.light.view.LightActiveView")--幻光展示界面 require("game.light.view.LightSuccessView") ------------------------- LightController = LightController or BaseClass(BaseController, true) local LightController = LightController function LightController:__init() LightController.Instance = self self.model = LightModel:GetInstance() self:AddEvents() self:RegisterAllProtocal() end function LightController:__delete() end function LightController:RegisterAllProtocal( ) --幻光部分 self:RegisterProtocal(14700, 'handle14700') --幻光基础信息 self:RegisterProtocal(14701, 'handle14701') --幻光升级 self:RegisterProtocal(14702, 'handle14702') --幻光幻化 self:RegisterProtocal(14703, 'handle14703') --幻光激活 self:RegisterProtocal(14704, 'handle14704') --幻光新数据信息 self:RegisterProtocal(14708, 'handle14708') --幻光登录天数更新 end function LightController:AddEvents() local function onRequestHandler(...) local args = {...} if args[1] == 16701 or args[1] == 14701 or args[1] == 14702 or args[1] == 14703 then self:SendFmtToGame(args[1], "h", args[2]) else self:SendFmtToGame(args[1]) end end self.model:Bind(LightModel.REQUEST_CCMD_EVENT, onRequestHandler) local function gameStartHandler() self.model:ResetData() local delay = function() self.model.is_game_start = true if GetModuleIsOpen(147,nil,true) then self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700) end end setTimeout(delay,1) end GlobalEventSystem:Bind(EventName.GAME_START, gameStartHandler) local function role_lv_up(level) if GetModuleOpenLevel( 147,0,true) == level then self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700) end end RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, role_lv_up) local function ANS_FINISHED_TASK_LIST( task_id ) if task_id == Config.Moduleid[147].task_id then self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700) end end GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST,ANS_FINISHED_TASK_LIST) local onOpenLightActiveView = function (cur_select_right)--幻光展示界面 if self.LightActiveView == nil then self.LightActiveView = LightActiveView.New() end if self.LightActiveView:HasOpen() then else self.LightActiveView:Open(cur_select_right) end end self.model:Bind(LightModel.OPEN_LIGHT_ACTIVE_VIEW, onOpenLightActiveView) local OPEN_SUCCESS_VIEW = function (cur_select_right, grade, star)--幻光展示界面 if self.lightsuccessview == nil then self.lightsuccessview = LightSuccessView.New() self.lightsuccessview:Open(cur_select_right, grade, star) end end self.model:Bind(LightModel.OPEN_SUCCESS_VIEW, OPEN_SUCCESS_VIEW) end --幻光基础信息 function LightController:handle14700( ) local scmd = SCMD14700.New(true) self.model:SetLoginDay( scmd.days ) self.model:SetLightInfo( scmd.visus ) self:CheckLightRedDot() self.model:Fire(LightModel.ANS_LIGHT_BASE) ------------------------- local role = Scene.Instance:GetMainRole() if role then role:RefreshLightEffect() end ------------------------- end --幻光升级 function LightController:handle14701( ) local scmd = SCMD14701.New(true) if scmd.result == 1 then Message.show("升级成功") GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS) self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700) if scmd.grade > 1 and scmd.lv == 1 then self.model:Fire(LightModel.OPEN_SUCCESS_VIEW,scmd.id,scmd.grade,scmd.lv) end self.model:Fire(LightModel.ANS_LIGHT_UPGRADE,scmd.lv) else ErrorCodeShow(scmd.result) self.model:Fire(LightModel.ANS_LIGHT_UPGRADE) end end --幻光幻化 function LightController:handle14702( ) local scmd = SCMD14702.New(true) if scmd.result == 1 then GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS) if scmd.opty == 1 then Message.show("穿戴成功") else Message.show("取消穿戴") end self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700) else ErrorCodeShow(scmd.result) end end --幻光激活 function LightController:handle14703( ) local scmd = SCMD14703.New(true) if scmd.result == 1 then GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS) Message.show("激活成功") self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14702,scmd.id) SkillManager.Instance:Fire(SkillManager.UPDATE_SKILL_LIST) self.model:Fire(LightModel.OPEN_SUCCESS_VIEW,scmd.id,0,0) ------------------------- --触发一下升级特效 self.model:Fire(LightModel.ANS_LIGHT_UPGRADE,1) ------------------------- else ErrorCodeShow(scmd.result) end end --幻光新数据信息 function LightController:handle14704( ) local scmd = SCMD14704.New(true) self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700) GlobalEventSystem:Fire(EventName.GET_DAILY_LIGHT_SKILL) end --幻光登录天数更新 function LightController:handle14708( ) local scmd = SCMD14708.New(true) self.model:SetLoginDay( scmd.days ) self:CheckLightRedDot() self.model:Fire(LightModel.ANS_LIGHT_BASE) end function LightController:CheckLightRedDot( ) local function call_backack( ) self.model:GetLightAllRed(true) ------------------------- NewMainRoleModel:GetInstance():Fire(NewMainRoleModel.UPDATE_RED_DOT, NewMainRoleModel.TabId.Light) end TimeManager.GetInstance():StartTime("LightControllerLightCheckRedDotTimeManager", 0.5, call_backack) end