|
|
- require("game.advertisement.AdvertisementModel")
- require("game.advertisement.AdvertisementView")
-
- AdvertisementController = AdvertisementController or BaseClass(BaseController, true)
- local AdvertisementController = AdvertisementController
-
- AdvertisementController.IsDebug = true
-
- function AdvertisementController:__init()
- AdvertisementController.Instance = self
- self.model = AdvertisementModel:getInstance()
- self:AddEvents()
- self:RegisterAllProtocal()
- end
-
- function AdvertisementController:__delete()
-
- end
-
- function AdvertisementController:RegisterAllProtocal( )
-
- end
-
- function AdvertisementController:AddEvents()
- -- 监控场景加载完毕 加载完才可以去判断 防止cookie没有初始化 只在首次登陆起作用
- local function onSceneStartHandler()
- self.model:SetSceneLoadState()
- if self.on_game_start_id then
- self:UnBind(self.on_game_start_id)
- end
- end
- self.on_game_start_id = self:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler)
- --EventName.GAME_START
- --EventName.SCENE_LOAD_VIEW_COMPLETE
-
-
- -- 打开广告
- local function on_open_advertisement_view( sub_type )
- if not sub_type then
- --logWarn('=======Msh:AdvertisementController.lua[27] sub_type=======', sub_type)
- return
- end
- if self.advertisement_view == nil then
- self.advertisement_view = AdvertisementView.New()
- end
- if not self.advertisement_view:HasOpen() then
- self.advertisement_view:Open(sub_type)
- end
- end
- self.model:Bind(AdvertisementModel.OPEN_ADVERTISEMENT_VIEW, on_open_advertisement_view)
-
- -- 过天刷新cookie检测
- local update_cookie = function ( )
- self.model:UpdateCookie()
- end
- GlobalEventSystem:Bind(EventName.UPDATE_ROLE_LOGIN_TIME_DATA, update_cookie)
-
-
- -- 强制关闭广告
- local function on_close_advertisement_view( )
- if self.advertisement_view == nil then
- return
- end
- if self.advertisement_view:HasOpen() then
- -- 关闭现有广告 回滚今天的cookie次数
- self.model:ResetCookieBySubType(self.advertisement_view.sub_type)
- self.advertisement_view:Close()
- end
- end
- self.model:Bind(AdvertisementModel.CLOSE_ADVERTISEMENT_VIEW, on_close_advertisement_view)
- end
|