源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

265 行
9.4 KiB

  1. --[[
  2. --]]
  3. require("game.proto.604.Require604")
  4. require("game.sandTable.SandTableModel")
  5. require("game.sandTable.SandTableConst")
  6. require("game.sandTable.view.SandTableView")--主界面
  7. require("game.sandTable.view.SandTableNodeItem")--据点Item
  8. -------------------------
  9. require("game.sandTable.view.SandTableNodeTip")--据点tip信息
  10. require("game.sandTable.view.SandTableNodeTipItem")--据点tip信息item
  11. require("game.sandTable.view.SandTableTipCon")--tip信息页容器
  12. require("game.sandTable.view.SandTableRankTip")--战功榜信息
  13. require("game.sandTable.view.SandTableRankItem")--战功榜信息item
  14. require("game.sandTable.view.SandTableSelfTip")--本国战况信息页
  15. require("game.sandTable.view.SandTableBuffTip")--buff据点信息页
  16. require("game.sandTable.view.SandTableSceneView")--场景
  17. require("game.sandTable.view.SandTableSceneRankItem")--场景伤害榜单节点
  18. require("game.sandTable.view.SandTableResultView")--结算
  19. SandTableController = SandTableController or BaseClass(BaseController, true)
  20. local SandTableController = SandTableController
  21. function SandTableController:__init()
  22. SandTableController.Instance = self
  23. self.model = SandTableModel:getInstance()
  24. self:RegisterAllProtocal()
  25. self:AddEvents()
  26. end
  27. function SandTableController:__delete()
  28. end
  29. function SandTableController:RegisterAllProtocal( )
  30. self:RegisterProtocal(60400, "on60400")-- 跨服沙盘-开启状态
  31. self:RegisterProtocal(60401, "on60401")-- 跨服沙盘-全局信息
  32. self:RegisterProtocal(60402, "on60402")-- 跨服沙盘-全局信息-单个据点-主推
  33. self:RegisterProtocal(60403, "on60403")-- 跨服沙盘-查看据点攻占详情
  34. self:RegisterProtocal(60404, "on60404")-- 跨服沙盘-进攻据点
  35. self:RegisterProtocal(60405, "on60405")-- 跨服沙盘-插旗
  36. self:RegisterProtocal(60407, "on60407")-- 跨服沙盘-领取据点占领奖励
  37. self:RegisterProtocal(60408, "on60408")-- 跨服沙盘-我方激活的buff
  38. self:RegisterProtocal(60409, "on60409")-- 跨服沙盘-副本内信息
  39. self:RegisterProtocal(60410, "on60410")-- 跨服沙盘-副本结算信息
  40. end
  41. function SandTableController:AddEvents()
  42. local protocal_format = {
  43. [60402] = "h",
  44. [60403] = "h",
  45. [60404] = "hc",
  46. [60405] = "hc",
  47. [60406] = "c",
  48. [60407] = "h",
  49. }
  50. local function onSendCmdFunc( ... )
  51. local args_list = {...}
  52. if protocal_format[args_list[1]] then
  53. local proto_id = table.remove(args_list,1)
  54. self:SendFmtToGame(proto_id, protocal_format[proto_id], unpack(args_list))
  55. else
  56. self:SendFmtToGame(args_list[1])
  57. end
  58. end
  59. self.model:Bind(SandTableConst.PROTO_CCMD_EVENT, onSendCmdFunc)
  60. local function on_game_start()
  61. self.model:Reset()
  62. if GetModuleIsOpen(604,nil) then
  63. self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60400)
  64. end
  65. end
  66. GlobalEventSystem:Bind(EventName.GAME_START, on_game_start)
  67. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, function (level)
  68. if GetModuleOpenLevel( 604,nil) == level then
  69. self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60400)
  70. end
  71. end)
  72. local function OPEN_MAIN_VIEW( is_close )
  73. if is_close then
  74. if self.sandtableview then
  75. self.sandtableview:Close()
  76. end
  77. else
  78. self.sandtableview = self.sandtableview or SandTableView.New()
  79. if not self.sandtableview:HasOpen() then
  80. self.sandtableview:Open()
  81. end
  82. end
  83. end
  84. self.model:Bind(SandTableConst.OPEN_MAIN_VIEW, OPEN_MAIN_VIEW)
  85. local function OPEN_RESULT_VIEW( data )
  86. self.sandtableresultview = self.sandtableresultview or SandTableResultView.New()
  87. if not self.sandtableresultview:HasOpen() then
  88. self.sandtableresultview:Open(data)
  89. end
  90. end
  91. self.model:Bind(SandTableConst.OPEN_RESULT_VIEW, OPEN_RESULT_VIEW)
  92. local function onSceneStartHandler( )
  93. self.model:ResetFightScoreCfg()--重置积分,节约空间
  94. self:ChangeScene()
  95. end
  96. self:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler)
  97. local function ANS_CSGWAR_RED( )
  98. self:CheckRedDot()
  99. end
  100. CSGWarModel:GetInstance():Bind(CSGWarConst.ANS_CSGWAR_RED, ANS_CSGWAR_RED)
  101. local function on_arms_num_change_var( )
  102. -- 那几个满足挑战条件的,给个外部红点让人去打
  103. self:CheckRedDot()
  104. end
  105. CSMainModel:getInstance():BindOne("arms_num", on_arms_num_change_var)
  106. end
  107. function SandTableController:ChangeScene( )
  108. if self.sandtablesceneview then
  109. self.sandtablesceneview:Close()
  110. end
  111. if SceneManager.Instance:IsSandTableDungeon() then
  112. self.sandtablesceneview = self.sandtablesceneview or SandTableSceneView.New()
  113. self.sandtablesceneview:Open()
  114. -------------------------
  115. local point_type = self.model:GetPointTypeByDunId( )
  116. local str = SandTableConst.EnterTip[point_type]
  117. if not str then return end
  118. local main_vo = RoleManager.Instance.mainRoleInfo
  119. local temp_head_name = main_vo.name
  120. local data = {
  121. head_type = 1000 + main_vo.career,
  122. desc = str,
  123. head_name = temp_head_name or "",
  124. hide_time = 8,
  125. dalay_time = 1,
  126. is_task_type = true,
  127. }
  128. GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW,data)
  129. else
  130. local last_id = SceneManager.Instance:GetLastSceneId()
  131. if SceneManager.Instance:IsSandTableDungeonScene(last_id) then
  132. --上一次是沙盘副本场景
  133. CSMainModel:getInstance():Fire(CSMainConst.OPEN_CS_MAIN_BASE_VIEW)
  134. local function delay( )
  135. self.model:Fire(SandTableConst.OPEN_MAIN_VIEW)
  136. end
  137. setTimeout(delay,0.2)
  138. end
  139. end
  140. end
  141. -- ############ 跨服沙盘-开启状态 protocol=60400 ############
  142. function SandTableController:on60400( )
  143. local vo = SCMD60400.New(true)
  144. self.model:SetActInfo(vo)
  145. self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60401)
  146. end
  147. -- ############ 跨服沙盘-全局信息 protocol=60401 ############
  148. function SandTableController:on60401( )
  149. local vo = SCMD60401.New(true)
  150. self.model:SetPointDateList( vo.point_list,true )
  151. self.model:SetBuffInfo( vo.buff_info )
  152. self.model:Fire(SandTableConst.REFRESH_ALL_POINT_INFO)
  153. self:CheckRedDot( )
  154. end
  155. -- ############ 跨服沙盘-全局信息-单个据点-主推 protocol=60402 ############
  156. function SandTableController:on60402( )
  157. local vo = SCMD60402.New(true)
  158. self.model:SetPointDateList( {vo} )
  159. self.model:Fire(SandTableConst.REFRESH_ALL_POINT_INFO)
  160. self:CheckRedDot( )
  161. end
  162. -- ############ 跨服沙盘-查看据点攻占详情 protocol=60403 ############
  163. function SandTableController:on60403( )
  164. local vo = SCMD60403.New(true)
  165. self.model:SetFightRankData(vo)
  166. self.model:Fire(SandTableConst.OPEN_POINT_INFO_VIEW, vo.point_id, nil, vo)
  167. end
  168. -- ############ 跨服沙盘-进攻据点 protocol=60404 ############
  169. function SandTableController:on60404( )
  170. local vo = SCMD60404.New(true)
  171. if vo.res == 1 then
  172. Message.show("操作成功~")
  173. self.model:SetDungeonInfo(false)
  174. else
  175. ErrorCodeShow(vo.res)
  176. end
  177. end
  178. -- ############ 跨服沙盘-插旗 protocol=60405 ############
  179. function SandTableController:on60405( )
  180. local vo = SCMD60405.New(true)
  181. if vo.res == 1 then
  182. self.model:Fire(SandTableConst.CancelShowTip)
  183. -------------------------
  184. if vo.type == 1 then
  185. Message.show("发起成功~")
  186. -- local is_us = self.model:IsSelfFactionByPoint( vo.point_id )
  187. local cfg = self.model:GetPointCfg( vo.point_id )
  188. if cfg then
  189. local content = string.format(SandTableConst.FlagTalk, Trim(cfg.name))
  190. ChatModel:getInstance():Fire(ChatModel.SEND_MSG,ChatModel.CHANNEL_COUNTRY,content,nil,nil,ChatModel.CHAT_COMMON_TYPE.SYSTEM)
  191. end
  192. else
  193. Message.show("已取消~")
  194. end
  195. else
  196. ErrorCodeShow(vo.res)
  197. end
  198. end
  199. -- ############ 跨服沙盘-领取据点占领奖励 protocol=60407 ############
  200. function SandTableController:on60407( )
  201. local vo = SCMD60407.New(true)
  202. if vo.res == 1 then
  203. Message.show("领取成功")
  204. local data = self.model:GetPointDateList( vo.point_id )
  205. if data then
  206. --找到数据就自己更新
  207. data.award_time = vo.award_time
  208. self:CheckRedDot( )
  209. self.model:Fire(SandTableConst.REFRESH_ALL_POINT_INFO)
  210. else
  211. --没找到就请求数据了
  212. self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60401)
  213. end
  214. else
  215. ErrorCodeShow(vo.res)
  216. end
  217. end
  218. -- ############ 跨服沙盘-我方激活的buff protocol=60408 ############
  219. function SandTableController:on60408( )
  220. local vo = SCMD60408.New(true)
  221. self.model:SetSelfActiveBuff(vo.skill_list)
  222. end
  223. -- ############ 跨服沙盘-副本内信息 protocol=60409 ############
  224. function SandTableController:on60409( )
  225. local vo = SCMD60409.New(true)
  226. self.model:SetDungeonInfo(vo)
  227. self.model:Fire(SandTableConst.ANS_DUNGEON_INFO)
  228. end
  229. -- ############ 跨服沙盘-副本结算信息 protocol=60410 ############
  230. function SandTableController:on60410( )
  231. CustomActivityModel:getInstance():SetGoodsCanFly(false)
  232. local vo = SCMD60410.New(true)
  233. self.model:Fire(SandTableConst.OPEN_RESULT_VIEW, vo)
  234. self.model:Fire(SandTableConst.CancelShowTip)
  235. self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60402, vo.point_id)
  236. end
  237. function SandTableController:CheckRedDot( )
  238. local function call_backack( )
  239. -- local csgwar_red_data = CSGWarModel:getInstance():GetCSGWarRedData()
  240. -- local csgwar_red = csgwar_red_data.one_red or csgwar_red_data.support_red or csgwar_red_data.fight_red or csgwar_red_data.occupy_red
  241. -------------------------
  242. self.model:GetRedDot( true )
  243. -------------------------
  244. self.model:Fire(SandTableConst.RedDotRefresh)
  245. end
  246. TimeManager.GetInstance():StartTime("SandTableController_CheckRedDot", 0.5, call_backack)
  247. end