源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
6.9 KiB

  1. CommonModel = CommonModel or BaseClass(BaseVo, true)
  2. local CommonModel = CommonModel
  3. -- 右侧通用邀请弹窗的邀请类型
  4. CommonModel.InviteTipsType = {
  5. GuildSpellList = 1, -- 社团拼单邀请
  6. Team = 2, -- 组队
  7. Crusade = 3, -- 组队讨伐
  8. GuardinThree = 4, --绝地守卫
  9. EventTips = 5, -- 活动tips
  10. }
  11. function CommonModel:__init()
  12. CommonModel.Instance = self
  13. self:Reset()
  14. end
  15. function CommonModel:Reset()
  16. self.list_act_notice = {}
  17. self.act_clock_mask_list = {}
  18. self.invite_data_cache = {} -- 邀请信息总缓存
  19. self.event_invite_cache = {} -- 活动开启邀请tips缓存
  20. self.act_tip_data_cache = {} -- 活动tips缓存
  21. -- 活动通用弹窗界面使用,上线后一段时间内活动预告界面不开启倒计时和不自动进入活动
  22. self.activity_login_time = TimeUtil:getServerTime() + 10
  23. end
  24. function CommonModel:getInstance()
  25. if CommonModel.Instance == nil then
  26. CommonModel.Instance = CommonModel.New()
  27. end
  28. return CommonModel.Instance
  29. end
  30. --存储活动提示信息
  31. function CommonModel:AddActivityNotice( module_id,sub_id,act_start_time,fixed_str,is_loading )
  32. for k,v in pairs(self.list_act_notice) do
  33. --过滤掉重复调用的tip缓存
  34. if v.module_id == module_id and v.sub_id == sub_id then
  35. return
  36. end
  37. end
  38. table.insert( self.list_act_notice, {
  39. module_id = module_id,
  40. sub_id = sub_id,
  41. act_start_time = act_start_time,--此参数暂时无用,被CommonController的EventName.SCENE_LOAD_VIEW_COMPLETE替代了
  42. fixed_str = fixed_str,
  43. is_loading = is_loading
  44. })
  45. -- 根据情况判断是否弹出活动邀请tips
  46. self:ShowInviteTipInSpercificScene(module_id, sub_id)
  47. end
  48. --获取一个活动提示数据
  49. function CommonModel:GetActivityNotictOneInfo( delete_module_id,delete_sub_id )
  50. --传值代表取出数据删除,不传表示取出列表第一个数据
  51. delete_sub_id = delete_sub_id or 0
  52. -------------------------
  53. if delete_module_id then
  54. local result_data = false
  55. local new_tab = {}
  56. for k,v in pairs(self.list_act_notice) do
  57. if v.module_id == delete_module_id and (v.sub_id == delete_sub_id) then
  58. --从列表里面找到重复的,清理掉
  59. result_data = v
  60. else
  61. table.insert( new_tab, v )
  62. end
  63. end
  64. self.list_act_notice = new_tab
  65. return result_data
  66. else
  67. if self.list_act_notice[1] then
  68. return table.remove(self.list_act_notice,1)
  69. end
  70. end
  71. -------------------------
  72. return false
  73. end
  74. --设置活动提示倒计时屏蔽
  75. function CommonModel:GetActClockMaskList( module_id,sub_id )
  76. return self.act_clock_mask_list[(module_id or 0).."@"..(sub_id or 0)]
  77. end
  78. function CommonModel:SetActClockMaskList( module_id,sub_id )
  79. self.act_clock_mask_list[(module_id or 0).."@"..(sub_id or 0)] = true
  80. end
  81. --多开活动类,要加一个重置mask的接口
  82. function CommonModel:ReSetActClockMaskList( module_id,sub_id )
  83. self.act_clock_mask_list[(module_id or 0).."@"..(sub_id or 0)] = false
  84. end
  85. -- 通用邀请界面相关
  86. -- 缓存邀请信息
  87. function CommonModel:PushInviteDataCache(data)
  88. self.invite_data_cache = self.invite_data_cache or {}
  89. if data and data.invite_type then
  90. self.invite_data_cache[#self.invite_data_cache+1] = data
  91. end
  92. end
  93. function CommonModel:GetInviteDataCacheCount( )
  94. return TableSize(self.invite_data_cache)
  95. end
  96. -- 推出最早的邀请信息 only_get_data:只拿数据,不退出列表
  97. function CommonModel:PopInviteDataCache(only_get_data)
  98. if self:GetInviteDataCacheCount() > 0 then
  99. if only_get_data then
  100. return self.invite_data_cache[1]
  101. else
  102. return table.remove(self.invite_data_cache, 1)
  103. end
  104. else
  105. return nil
  106. end
  107. end
  108. -- 在特定场景中,如果活动开始,则需要弹出一个活动邀请的tips
  109. function CommonModel:ShowInviteTipInSpercificScene(module_id, sub_id)
  110. if not module_id or not sub_id then return end
  111. local key = module_id .. "@" .. sub_id
  112. if self.event_invite_cache[key] then return end
  113. -- 不仅只会弹出一次,而且无论是否在特定场景都要记录这个状态
  114. self.event_invite_cache[key] = true
  115. -- 场景判断相关
  116. local scene_mgr = SceneManager:getInstance()
  117. local is_in_guildScene = scene_mgr:IsGuildScene() -- 社团场景
  118. local is_in_bossDeserted = scene_mgr:IsBossDesertedScene() -- 幻魔星域
  119. local is_in_bossHome = scene_mgr:IsBossHomeScene() -- boss之家
  120. -- 不在特定场景内,则不弹出tips
  121. if not is_in_guildScene
  122. and not is_in_bossDeserted
  123. and not is_in_bossHome then
  124. return
  125. end
  126. -- 特定场景内,一些活动不需要弹出邀请tips
  127. if is_in_guildScene then
  128. if module_id == 400 or module_id == 406 or module_id == 408 then -- 社团场景内的活动不需要在社团场景内弹出邀请tips
  129. return
  130. end
  131. end
  132. -- 获取活动配置
  133. local ac_data
  134. for k, v in pairs(Config.Ac) do
  135. if v.module == module_id and v.module_sub == sub_id then
  136. ac_data = v
  137. break
  138. end
  139. end
  140. if ac_data then
  141. self:Fire(EventName.OPEN_SPERCIFIC_SCENE_ACT_TIPVIEW, true, ac_data)
  142. end
  143. end
  144. --调用之前检查上次场景是否需要过滤此次调用
  145. function CommonModel:MaskOpenActTip( module_id,sub_id )
  146. local last_scene = SceneManager.Instance:GetLastSceneId()
  147. -------------------------
  148. if module_id == 418 then
  149. -- 温泉
  150. return SceneManager.Instance:IsBeachScene(last_scene)
  151. elseif module_id == 600 then
  152. --无尽
  153. return SceneManager.Instance:IsEndlessScene(last_scene)
  154. elseif module_id == 601 then
  155. --跨国团战
  156. return SceneManager.Instance:IsCSGWarScene(last_scene)
  157. end
  158. return false
  159. end
  160. function CommonModel:PushActTipDataCache( act_data )
  161. self.act_tip_data_cache = self.act_tip_data_cache or {}
  162. for k,v in pairs(self.act_tip_data_cache) do--相同的数据就别进来捣乱了
  163. if v.winId == act_data.winId
  164. and (v.act_sub_type~=nil and v.act_sub_type == act_data.act_sub_type)
  165. and v.subId == act_data.subId then
  166. return
  167. end
  168. end
  169. self.act_tip_data_cache[#self.act_tip_data_cache + 1] = act_data
  170. end
  171. function CommonModel:GetActTipDataCacheCount( )
  172. return TableSize(self.act_tip_data_cache)
  173. end
  174. --清除最早的信息
  175. function CommonModel:PopActTipDataCache( )
  176. if self:GetActTipDataCacheCount() > 0 then
  177. return table.remove(self.act_tip_data_cache, 1)
  178. else
  179. return nil
  180. end
  181. end
  182. ----------活动提醒弹窗相关-start---------
  183. function CommonModel:PushActRemindTipDataCache( act_data )
  184. self.act_remind_tip_data_cache = self.act_remind_tip_data_cache or {}
  185. for k,v in pairs(self.act_remind_tip_data_cache) do--相同的数据就别进来捣乱了
  186. if v.winId == act_data.winId
  187. -- and (v.act_sub_type~=nil and v.act_sub_type == act_data.act_sub_type)
  188. and v.sub_type == act_data.sub_type then
  189. return
  190. end
  191. end
  192. self.act_remind_tip_data_cache[#self.act_remind_tip_data_cache + 1] = act_data
  193. end
  194. function CommonModel:GetActRemindTipDataCacheCount( )
  195. return TableSize(self.act_remind_tip_data_cache)
  196. end
  197. --清除最早的信息
  198. function CommonModel:PopActRemindTipDataCache( )
  199. if self:GetActRemindTipDataCacheCount() > 0 then
  200. return table.remove(self.act_remind_tip_data_cache, 1)
  201. else
  202. return nil
  203. end
  204. end
  205. ----------活动提醒弹窗相关-end-----------