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

458 行
16 KiB

  1. require("game.proto.603.Require603")
  2. require("game.csMain.CSMainModel")
  3. require("game.csMain.CSMainConst")
  4. -------------------
  5. require("game.csMain.CSMainBaseView")
  6. require("game.csMain.CSMainRoleModelItem")
  7. -------------------
  8. require("game.csMain.CSMainTaskView")
  9. require("game.csMain.CSMainTaskItem")
  10. -------------------
  11. require("game.csMain.CSMainExploitRankView")
  12. require("game.csMain.CSMainExploitRankTab")
  13. require("game.csMain.CSMainExploitRankItem")
  14. require("game.csMain.CSMainExploitRankTopItem")
  15. require("game.csMain.CSMainExploitRankDailyRewardView")
  16. require("game.csMain.CSMainExploitRankDailyRewardItem")
  17. -------------------
  18. require("game.csMain.CSMainMilitaryRanksAttrItem")
  19. require("game.csMain.CSMainMilitaryRanksBaseView")
  20. require("game.csMain.CSMainMilitaryRanksTab")
  21. require("game.csMain.CSMainMilitaryRanksDetailsView")
  22. require("game.csMain.CSMainMilitaryRanksRankView")
  23. require("game.csMain.CSMainMilitaryRanksRankItem")
  24. -------------------
  25. require("game.csMain.CSMainAppointView")
  26. require("game.csMain.CSMainAppointTab")
  27. require("game.csMain.CSMainAppointRankItem")
  28. require("game.csMain.CSMainAppointRoleListItem")
  29. require("game.csMain.CSMainAppointRoleItem")
  30. require("game.csMain.CSMainAppointOtherRecordView")
  31. require("game.csMain.CSMainAppointAllRoleListItem")
  32. -------------------
  33. require("game.csMain.CSMainAdvanceNoticeView")
  34. CSMainController = CSMainController or BaseClass(BaseController, true)
  35. local CSMainController = CSMainController
  36. function CSMainController:__init()
  37. CSMainController.Instance = self
  38. self.model = CSMainModel:getInstance()
  39. self:AddEvents()
  40. self:RegisterAllProtocal()
  41. end
  42. function CSMainController:__delete()
  43. end
  44. function CSMainController:RegisterAllProtocal( )
  45. self:RegisterProtocal(60300, "Handle60300")
  46. self:RegisterProtocal(60301, "Handle60301")
  47. self:RegisterProtocal(60302, "Handle60302")
  48. self:RegisterProtocal(60303, "Handle60303")
  49. self:RegisterProtocal(60304, "Handle60304")
  50. self:RegisterProtocal(60305, "Handle60305")
  51. self:RegisterProtocal(60306, "Handle60306")
  52. self:RegisterProtocal(60307, "Handle60307")
  53. self:RegisterProtocal(60308, "Handle60308")
  54. self:RegisterProtocal(60309, "Handle60309")
  55. self:RegisterProtocal(60310, "Handle60310")
  56. self:RegisterProtocal(60311, "Handle60311")
  57. self:RegisterProtocal(60312, "Handle60312")
  58. self:RegisterProtocal(60313, "Handle60313")
  59. self:RegisterProtocal(60314, "Handle60314")
  60. self:RegisterProtocal(60315, "Handle60315")
  61. self:RegisterProtocal(60316, "Handle60316")
  62. self:RegisterProtocal(60317, "Handle60317")
  63. end
  64. function CSMainController:AddEvents()
  65. local function onGameStart()
  66. local function onDelay()
  67. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60301)
  68. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60308)
  69. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60315)
  70. -- local my_country = KfWorldModel:GetInstance():GetMyCountryId()
  71. -- if my_country then
  72. -- self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
  73. -- end
  74. end
  75. setTimeout(onDelay, 2.5)
  76. local function delay_method( )
  77. local my_country = KfWorldModel:GetInstance():GetMyCountryId()
  78. if my_country then
  79. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
  80. end
  81. end
  82. setTimeout(delay_method, 5)
  83. end
  84. GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
  85. -- 满足等级后请求信息
  86. local function onLevelUp(level)
  87. if level == GetModuleOpenLevel(603) then
  88. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60301)
  89. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60308)
  90. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60315)
  91. local my_country = KfWorldModel:GetInstance():GetMyCountryId()
  92. if my_country then
  93. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
  94. end
  95. elseif level == 96 then
  96. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60315)
  97. end
  98. end
  99. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
  100. --请求信息 i|32 h|16 c|8 l|64 s|字符串
  101. local function onRequestHandler(...)
  102. local args_list = {...}
  103. if args_list[1] == 60300 then
  104. self:SendFmtToGame(args_list[1])
  105. elseif args_list[1] == 60301 then
  106. self:SendFmtToGame(args_list[1])
  107. elseif args_list[1] == 60304 then
  108. self:SendFmtToGame(args_list[1],"cc",args_list[2],args_list[3])
  109. elseif args_list[1] == 60305 then
  110. self:SendFmtToGame(args_list[1])
  111. elseif args_list[1] == 60306 then
  112. self:SendFmtToGame(args_list[1],"l",args_list[2])
  113. elseif args_list[1] == 60307 or args_list[1] == 60316 then
  114. self:SendFmtToGame(args_list[1],"c",args_list[2])
  115. elseif args_list[1] == 60308 then
  116. self:SendFmtToGame(args_list[1])
  117. elseif args_list[1] == 60309 then
  118. self:SendFmtToGame(args_list[1],"l",args_list[2])
  119. elseif args_list[1] == 60310 then
  120. self:SendFmtToGame(args_list[1])
  121. elseif args_list[1] == 60311 then
  122. self:SendFmtToGame(args_list[1])
  123. elseif args_list[1] == 60312 then
  124. self:SendFmtToGame(args_list[1],"c",args_list[2])
  125. else
  126. self:SendFmtToGame(args_list[1])
  127. end
  128. end
  129. self.model:Bind(CSMainConst.REQUEST_CCMD_EVENT, onRequestHandler)
  130. --主界面
  131. local function on_open_cs_main_base_view(is_close)
  132. if is_close then
  133. if self.cs_main_base_view then
  134. self.cs_main_base_view:Close()
  135. end
  136. return
  137. end
  138. if self.cs_main_base_view == nil then
  139. self.cs_main_base_view = CSMainBaseView.New()
  140. end
  141. self.cs_main_base_view:Open()
  142. end
  143. self.model:Bind(CSMainConst.OPEN_CS_MAIN_BASE_VIEW,on_open_cs_main_base_view)
  144. --任务界面
  145. local function on_open_cs_main_task_view(is_close)
  146. if is_close then
  147. if self.cs_main_task_view then
  148. self.cs_main_task_view:Close()
  149. end
  150. return
  151. end
  152. if self.cs_main_task_view == nil then
  153. self.cs_main_task_view = CSMainTaskView.New()
  154. end
  155. --跳到有红点的任务页签去
  156. local jump_index = 1
  157. for i=1,3 do
  158. local red = self.model:GetTaskRedByColor(i)
  159. if red then
  160. jump_index = i
  161. break
  162. end
  163. end
  164. self.cs_main_task_view:Open(jump_index)
  165. end
  166. self.model:Bind(CSMainConst.OPEN_CS_MAIN_TASK_VIEW,on_open_cs_main_task_view)
  167. --军功排行界面
  168. local function on_open_cs_main_exploit_rank_view()
  169. if self.cs_main_exploit_rank_view == nil then
  170. self.cs_main_exploit_rank_view = CSMainExploitRankView.New()
  171. end
  172. self.cs_main_exploit_rank_view:Open()
  173. end
  174. self.model:Bind(CSMainConst.OPEN_CS_MAIN_EXPLOIT_RANK_VIEW,on_open_cs_main_exploit_rank_view)
  175. --每日奖励领取界面
  176. local function on_open_cs_main_exploit_rank_daily_reward_view()
  177. if self.cs_main_exploit_rank_daily_reward_view == nil then
  178. self.cs_main_exploit_rank_daily_reward_view = CSMainExploitRankDailyRewardView.New()
  179. end
  180. self.cs_main_exploit_rank_daily_reward_view:Open()
  181. end
  182. self.model:Bind(CSMainConst.OPEN_CS_MAIN_EXPLOIT_RANK_DAILY_REWARD_VIEW,on_open_cs_main_exploit_rank_daily_reward_view)
  183. --军衔主界面
  184. local function on_open_cs_main_military_ranks_base_view()
  185. if self.cs_main_military_ranks_base_view == nil then
  186. self.cs_main_military_ranks_base_view = CSMainMilitaryRanksBaseView.New()
  187. end
  188. self.cs_main_military_ranks_base_view:Open()
  189. end
  190. self.model:Bind(CSMainConst.OPEN_CS_MAIN_MILITARY_RANKS_BSAE_VIEW,on_open_cs_main_military_ranks_base_view)
  191. --职位任命界面
  192. local function on_open_cs_main_appoint_view()
  193. if self.cs_main_appoint_view == nil then
  194. self.cs_main_appoint_view = CSMainAppointView.New()
  195. end
  196. self.cs_main_appoint_view:Open()
  197. end
  198. self.model:Bind(CSMainConst.OPEN_CS_MAIN_APPOINT_VIEW,on_open_cs_main_appoint_view)
  199. --其他职位任命界面
  200. local function on_open_cs_main_appoint_view(vo)
  201. if self.cs_main_other_appoint_view == nil then
  202. self.cs_main_other_appoint_view = CSMainAppointOtherRecordView.New()
  203. end
  204. self.cs_main_other_appoint_view:Open(vo)
  205. end
  206. self.model:Bind(CSMainConst.OPEN_CS_MAIN_OTHER_APPOINT_VIEW,on_open_cs_main_appoint_view)
  207. --星域世界预告界面
  208. local function on_open_cs_main_advance_notice_view()
  209. if self.cs_main_advance_notice_view == nil then
  210. self.cs_main_advance_notice_view = CSMainAdvanceNoticeView.New()
  211. end
  212. self.cs_main_advance_notice_view:Open()
  213. end
  214. self.model:Bind(CSMainConst.OPEN_CS_MAIN_ADVANCE_NOTICE_VIEW,on_open_cs_main_advance_notice_view)
  215. --主要的更新红点方法
  216. local function update_red_dot_by_tab_id_func( tab_id )
  217. if not tab_id then
  218. self.model:IsNeedRedAll()
  219. else
  220. self.model:IsNeedRed(tab_id)
  221. end
  222. local bool = self.model:GetMainRed()
  223. -- GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 603, bool)
  224. self.model:Fire(CSMainConst.UPDATE_MAIN_RIGHT_TOP_RED)
  225. end
  226. self.model:Bind(CSMainConst.UPDATE_RED_DOT,update_red_dot_by_tab_id_func)
  227. local function update_cs_main_goods_num()
  228. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
  229. end
  230. self.model:Bind(CSMainConst.UPDATE_CS_MAIN_GOODS_NUM,update_cs_main_goods_num)
  231. local function on_announce_sand_table_red_update( )
  232. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.SandTable)
  233. end
  234. SandTableModel:getInstance():Bind(SandTableConst.RedDotRefresh, on_announce_sand_table_red_update)
  235. local function update_power_change()
  236. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
  237. end
  238. self.update_power_change_id = RoleManager.Instance.mainRoleInfo:BindOne("fighting", update_power_change)
  239. end
  240. --############ 指挥室 ############
  241. function CSMainController:Handle60300( )
  242. local vo = SCMD60300.New(true)
  243. -- print("==WQ==:SCMD60300 [start:183] vo:", vo)
  244. -- PrintTable(vo)
  245. -- print("==WQ==:CSMainController [end]")
  246. self.model:SetCSMainDirectorData(vo)
  247. self.model:Fire(CSMainConst.UPDATE_CS_MAIN_BASE_VIEW)
  248. end
  249. --############ 任务单 ############
  250. function CSMainController:Handle60301( )
  251. local vo = SCMD60301.New(true)
  252. -- print("==WQ==:SCMD60301 [start:193] vo:", vo)
  253. -- PrintTable(vo)
  254. -- print("==WQ==:CSMainController [end]")
  255. self.model:SetCSMainTaskData(vo)
  256. self.model:Fire(CSMainConst.UPDATE_CS_MAIN_TASK_VIEW)
  257. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Active)
  258. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Task)
  259. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
  260. end
  261. --#############任务更新##########
  262. function CSMainController:Handle60302( )
  263. local vo = SCMD60302.New(true)
  264. self.model:UpdateCSMainTaskData(vo)
  265. self.model:Fire(CSMainConst.UPDATE_CS_MAIN_TASK_ITEM,vo.id)
  266. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Task)
  267. end
  268. --#############指定值更新##########
  269. function CSMainController:Handle60303( )
  270. local vo = SCMD60303.New(true)
  271. -- print("==WQ==:SCMD60303 [start:209] vo:", vo)
  272. -- PrintTable(vo)
  273. -- print("==WQ==:CSMainController [end]")
  274. self.model:UpdateCSMainKeyValue(vo)
  275. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
  276. end
  277. --############ 领取 ############
  278. function CSMainController:Handle60304( )
  279. local vo = SCMD60304.New(true)
  280. if vo.res == 1 then
  281. self.model:SetCSMainGetRewardData(vo)
  282. if vo.opty == 0 then
  283. elseif vo.opty == 1 then
  284. self.model:Fire(CSMainConst.REFRESH_CS_MAIN_TASK_ITEM_SORT)
  285. end
  286. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Active)
  287. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Task)
  288. else
  289. ErrorCodeShow(vo.res)
  290. lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
  291. end
  292. end
  293. --########军衔进阶#############
  294. function CSMainController:Handle60305( )
  295. local vo = SCMD60305.New(true)
  296. if vo.res == 1 then
  297. Message.show("军衔进阶成功")
  298. self.model:UpdateCSMainMilitaryRanksData(vo)
  299. self.model:Fire(CSMainConst.CS_MAIN_MILITARY_ADVANCE_SUCCESE)
  300. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
  301. else
  302. ErrorCodeShow(vo.res)
  303. lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
  304. end
  305. end
  306. --############# 主动查询个人形象(00协议返回空的时候用) #############
  307. function CSMainController:Handle60306( )
  308. local vo = SCMD60306.New(true)
  309. -- print("==WQ==:SCMD60305 [start:233] vo:", vo)
  310. -- PrintTable(vo)
  311. -- print("==WQ==:CSMainController [end]")
  312. if vo and vo.role_id and vo.role_id ~= 0 then
  313. self.model:UpdateCSMainDirectorData(vo)
  314. self.model:Fire(CSMainConst.UPDATE_CS_MAIN_BASE_VIEW_ROLE_REQUEST,vo.role_id)
  315. end
  316. end
  317. --#########榜单获取##########
  318. function CSMainController:Handle60307( )
  319. local vo = SCMD60307.New(true)
  320. self.model:SetMyCountryExploitRankNum(vo)--记录我的国家军功排行数,如果数量为0,表示不能膜拜,不给红点
  321. self.model:Fire(CSMainConst.UPDATE_EXPLOIT_RANK_CON,vo)
  322. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.WorShip)
  323. end
  324. --##########榜单页面相关##############
  325. function CSMainController:Handle60308( )
  326. local vo = SCMD60308.New(true)
  327. -- print("==WQ==:CSMainController [start:260] vo:", vo)
  328. -- PrintTable(vo)
  329. -- print("==WQ==:CSMainController [end]")
  330. -- vo.last_rank = 10
  331. -- vo.day_award = 0
  332. self.model:UpdateCSMainExploitData(vo)
  333. self.model:Fire(CSMainConst.UPDATE_EXPLOIT_RANK_DATA_EXTRA)
  334. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.DailyReward)
  335. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.WorShip)
  336. end
  337. --##########膜拜##############
  338. function CSMainController:Handle60309( )
  339. local vo = SCMD60309.New(true)
  340. if vo.res == 1 then
  341. self.model:UpdateCSMainClickWorshipRole(vo)
  342. self.model:Fire(CSMainConst.UPDATE_WORSHIP_STATE)
  343. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.WorShip)
  344. else
  345. ErrorCodeShow(vo.res)
  346. lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
  347. end
  348. end
  349. --##########领取##############
  350. function CSMainController:Handle60310( )
  351. local vo = SCMD60310.New(true)
  352. if vo.res == 1 then
  353. self.model:UpdateRankRewardState()
  354. self.model:Fire(CSMainConst.UPDATE_EXPLOIT_DAILY_REWARD_VIEW)
  355. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.DailyReward)
  356. else
  357. ErrorCodeShow(vo.res)
  358. lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
  359. end
  360. end
  361. --#########上期军功排名##########
  362. function CSMainController:Handle60311( )
  363. local vo = SCMD60311.New(true)
  364. self.model:SetLastMilitaryScoreRankData(vo)
  365. self.model:Fire(CSMainConst.UPDATE_LAST_MILITARY_SCORE_RANK_VIEW,vo)
  366. end
  367. --#########历史名单############
  368. function CSMainController:Handle60312( )
  369. local vo = SCMD60312.New(true)
  370. self.model:SetAppointData(vo)
  371. self.model:Fire(CSMainConst.UPDATE_APPOINT_DATA_VIEW,vo.opty)
  372. end
  373. --#########军衔排行############
  374. function CSMainController:Handle60313( )
  375. local vo = SCMD60313.New(true)
  376. self.model:Fire(CSMainConst.UPDATE_MILITARY_RANKS_RANK_VIEW,vo)
  377. end
  378. --#########上期团战成绩排行############
  379. function CSMainController:Handle60314( )
  380. local vo = SCMD60314.New(true)
  381. self.model:SetLastGuildWarScoreRankData(vo)
  382. self.model:Fire(CSMainConst.UPDATE_LAST_GUILD_WAR_SCORE_RANK_VIEW,vo)
  383. end
  384. --#########预告领取情况############
  385. function CSMainController:Handle60315( )
  386. local vo = SCMD60315.New(true)
  387. -- print("==WQ==:SCMD60315 [start:421] vo:", vo)
  388. -- PrintTable(vo)
  389. -- print("==WQ==:CSMainController [end]")
  390. self.model:SetCSMainAdvanceNoticeRewardData(vo)
  391. self.model:Fire(CSMainConst.UPDATE_CS_MAIN_ADVANCE_NOTICE_REWARD_STATE)
  392. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.NoticeReward)
  393. end
  394. --#########预告领取############
  395. function CSMainController:Handle60316( )
  396. local vo = SCMD60316.New(true)
  397. if vo.res == 1 then
  398. self.model:UpdateCSMainAdvanceNoticeRewardData(vo)
  399. self.model:Fire(CSMainConst.UPDATE_CS_MAIN_ADVANCE_NOTICE_REWARD_STATE)
  400. self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.NoticeReward)
  401. else
  402. ErrorCodeShow(vo.res)
  403. lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
  404. end
  405. end
  406. --#########通知自己国家军功榜前五名变动############
  407. function CSMainController:Handle60317( )
  408. local vo = SCMD60317.New(true)
  409. local my_country = KfWorldModel:GetInstance():GetMyCountryId()
  410. if my_country then
  411. self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
  412. end
  413. end