源战役客户端
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.

194 line
7.7 KiB

  1. require("game.contract.ContractModel")
  2. require("game.contract.ContractConst")
  3. require("game.contract.view.ContractSubView")--主界面
  4. require("game.contract.view.ContractLvItem")--等级item
  5. require("game.contract.view.ContractBuyUnlockView")--购买解锁
  6. require("game.contract.view.ContractTaskView")--任务界面
  7. require("game.contract.view.ContractTaskItem")--任务item
  8. require("game.contract.view.ContractRewardView")--领奖结算
  9. require("game.contract.view.ContractPreLookView")--奖励预览
  10. require("game.contract.view.ContractBuyLevelView")-- 购买等级
  11. ContractController = ContractController or BaseClass(BaseController, true)
  12. local ContractController = ContractController
  13. function ContractController:__init()
  14. ContractController.Instance = self
  15. self.model = ContractModel:getInstance()
  16. self:AddEvents()
  17. self:RegisterAllProtocal()
  18. end
  19. function ContractController:__delete()
  20. end
  21. function ContractController:AddEvents()
  22. local function on_game_start()
  23. self.model:Reset()
  24. end
  25. GlobalEventSystem:Bind(EventName.GAME_START, on_game_start)
  26. local function onLevelChange( level )
  27. if level == Config.Modulesub["331@74"].open_lv then
  28. self:CheckRedDot()
  29. end
  30. end
  31. RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelChange)
  32. local function onSceneChangeHandler()
  33. self.model.need_open_fuli_view = false
  34. end
  35. self:Bind(SceneEventType.SCENE_CHANGED, onSceneChangeHandler)
  36. local function OPEN_CONTRACT_VIEW( )
  37. if GetModuleIsOpen(331,74) then
  38. local temp_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.CONTRACT)
  39. for i,v in pairs(temp_list or {}) do
  40. local id = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000 + v.sub_type
  41. GlobalEventSystem:Fire(FuliConst.OPEN_FULI_MAIN_VIEW, id)
  42. return
  43. end
  44. end
  45. Message.show("活动未开启")
  46. end
  47. self.model:Bind(ContractConst.OPEN_CONTRACT_VIEW,OPEN_CONTRACT_VIEW)
  48. local function OPEN_TASK_VIEW( index,sub_type )
  49. self.contracttaskview = self.contracttaskview or ContractTaskView.New()
  50. self.contracttaskview:Open(index,sub_type)
  51. end
  52. self.model:Bind(ContractConst.OPEN_TASK_VIEW,OPEN_TASK_VIEW)
  53. local function SHOW_REWARD_RESULT( data )
  54. self.contractrewardview = self.contractrewardview or ContractRewardView.New()
  55. self.contractrewardview:Open(data)
  56. end
  57. self.model:Bind(ContractConst.SHOW_REWARD_RESULT,SHOW_REWARD_RESULT)
  58. local function SHOW_REWARD_LIST( sub_type,tag )
  59. self.contractprelookview = self.contractprelookview or ContractPreLookView.New()
  60. self.contractprelookview:Open(sub_type,tag)
  61. end
  62. self.model:Bind(ContractConst.SHOW_REWARD_LIST,SHOW_REWARD_LIST)
  63. local function OPEN_UNLOCK_VIEW( sub_type )
  64. self.contractbuyunlockview = self.contractbuyunlockview or ContractBuyUnlockView.New()
  65. self.contractbuyunlockview:Open(sub_type)
  66. end
  67. self.model:Bind(ContractConst.OPEN_UNLOCK_VIEW,OPEN_UNLOCK_VIEW)
  68. local function OPEN_BUY_LEVEL_VIEW( sub_type )
  69. self.contractbuylevelview = self.contractbuylevelview or ContractBuyLevelView.New()
  70. self.contractbuylevelview:Open(sub_type)
  71. end
  72. self.model:Bind(ContractConst.OPEN_BUY_LEVEL_VIEW, OPEN_BUY_LEVEL_VIEW)
  73. end
  74. function ContractController:CheckRedDot( )
  75. local function call_backack( )
  76. self.model:GetAllRed(true)
  77. self.model:Fire(ContractConst.REFRESH_RED_DOT)
  78. -------------------------
  79. local temp_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.CONTRACT)
  80. for i,v in pairs(temp_list or {}) do
  81. local id = 33100000 + CustomActivityModel.CustomActBaseType.CONTRACT * 1000 + v.sub_type
  82. FuliModel:getInstance():Fire(FuliConst.UPDATE_FULI_RED_DOT,id)
  83. FuliModel:getInstance():Fire(FuliConst.ANS_UPDATE_FULI_RED_DOT,id)
  84. end
  85. end
  86. TimeManager.GetInstance():StartTime("ContractController_CheckRedDot", 0.5, call_backack)
  87. end
  88. function ContractController:RegisterAllProtocal( )
  89. local register_cfg = {
  90. [33232] = {--基础信息
  91. req_event_data = {ContractConst.REQ_BASIC_DATA,"h"},req_func = false,
  92. handler = function(self,scmd)-- handler_manual
  93. if scmd.errcode == 1 then
  94. self.model:SetBasicData(scmd)
  95. self:CheckRedDot()
  96. self.model:Fire(ContractConst.ANS_BASIC_DATA)
  97. else
  98. -- ErrorCodeShow(scmd.errcode)
  99. end
  100. end,
  101. },
  102. [33233] = {--任务完成进度
  103. req_event_data = {ContractConst.REQ_TASK_PROCESS,"h"},req_func = false,
  104. handler = function(self,scmd)-- handler_manual
  105. self.model:SetTaskProcessInfo(scmd)
  106. self:CheckRedDot()
  107. self.model:Fire(ContractConst.ANS_TASK_PROCESS)
  108. end,
  109. },
  110. [33234] = {--任务积分领取
  111. req_event_data = {ContractConst.REQ_GET_TASK_SCORE,"hch"},req_func = false,
  112. handler = function(self,scmd)-- handler_manual
  113. if scmd.result == 1 then
  114. GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
  115. self.model:RefreshBasicLvAndScore(scmd)
  116. self:CheckRedDot()
  117. self.model:Fire(ContractConst.ANS_BASIC_DATA)
  118. else
  119. ErrorCodeShow(scmd.result)
  120. end
  121. end,
  122. },
  123. [33235] = {--任务更新
  124. handler = function(self,scmd)-- handler_manual
  125. self.model:RefreshTaskProcess(scmd.sub_type,scmd.update_tasks)
  126. self:CheckRedDot()
  127. self.model:Fire(ContractConst.ANS_TASK_PROCESS)
  128. end,
  129. },
  130. [33236] = {--领取等级奖励
  131. -- // 1等级奖励领取|2等级奖励一键领取
  132. -- // 等级|一键时为0
  133. req_event_data = {ContractConst.REQ_GET_REWARD,"hch"},req_func = false,
  134. handler = function(self,scmd)-- handler_manual
  135. if scmd.result == 1 then
  136. GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
  137. self.model:Fire(ContractConst.SHOW_REWARD_RESULT,scmd)
  138. self.model:Fire(ContractConst.REQ_BASIC_DATA,scmd.sub_type)
  139. else
  140. ErrorCodeShow(scmd.result)
  141. end
  142. end,
  143. },
  144. [33237] = {--购买王牌宝典
  145. --// 是否使用折扣卡
  146. req_event_data = {ContractConst.REQ_PAY_FOR_UNLOCK, "hcc"},req_func = false,
  147. handler = function(self,scmd)-- handler_manual
  148. if scmd.result == 1 then
  149. Message.show("购买成功!")
  150. GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
  151. self.model:RefreshBasicPayStatus(scmd.sub_type,scmd.pay_state)
  152. self:CheckRedDot()
  153. self.model:Fire(ContractConst.ANS_PAY_FOR_UNLOCK)
  154. self.model:Fire(ContractConst.ANS_BASIC_DATA)
  155. self.model:Fire(ContractConst.SHOW_REWARD_LIST,scmd.sub_type,"after_buy")
  156. else
  157. ErrorCodeShow(scmd.result)
  158. end
  159. end,
  160. },
  161. [33290] = {--等级购买
  162. req_event_data = {ContractConst.REQ_BUY_LEVEL, "hhh"},req_func = false,
  163. handler = function(self,scmd)-- handler_manual
  164. if scmd.errcode == 1 then
  165. Message.show("购买成功!")
  166. self.model:Fire(ContractConst.REQ_BASIC_DATA, scmd.sub_type)
  167. else
  168. ErrorCodeShow(scmd.errcode)
  169. end
  170. end,
  171. },
  172. }
  173. self:RegisterProtocalByCFG(register_cfg)
  174. end