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

184 lines
6.3 KiB

  1. require("game.light.LightModel")
  2. require("game.proto.147.Require147")
  3. require("game.light.view.LightSubView")
  4. require("game.light.view.LightTabItem")
  5. require("game.light.view.LightAttrItem")
  6. require("game.light.view.LightAttrItemTwo")
  7. require("game.light.view.LightAttrItemThree")
  8. require("game.light.view.LightItem")
  9. require("game.light.view.LightActiveView")--幻光展示界面
  10. require("game.light.view.LightSuccessView")
  11. -------------------------
  12. LightController = LightController or BaseClass(BaseController, true)
  13. local LightController = LightController
  14. function LightController:__init()
  15. LightController.Instance = self
  16. self.model = LightModel:GetInstance()
  17. self:AddEvents()
  18. self:RegisterAllProtocal()
  19. end
  20. function LightController:__delete()
  21. end
  22. function LightController:RegisterAllProtocal( )
  23. --幻光部分
  24. self:RegisterProtocal(14700, 'handle14700') --幻光基础信息
  25. self:RegisterProtocal(14701, 'handle14701') --幻光升级
  26. self:RegisterProtocal(14702, 'handle14702') --幻光幻化
  27. self:RegisterProtocal(14703, 'handle14703') --幻光激活
  28. self:RegisterProtocal(14704, 'handle14704') --幻光新数据信息
  29. self:RegisterProtocal(14708, 'handle14708') --幻光登录天数更新
  30. end
  31. function LightController:AddEvents()
  32. local function onRequestHandler(...)
  33. local args = {...}
  34. if args[1] == 16701 or args[1] == 14701 or args[1] == 14702 or args[1] == 14703 then
  35. self:SendFmtToGame(args[1], "h", args[2])
  36. else
  37. self:SendFmtToGame(args[1])
  38. end
  39. end
  40. self.model:Bind(LightModel.REQUEST_CCMD_EVENT, onRequestHandler)
  41. local function gameStartHandler()
  42. self.model:ResetData()
  43. local delay = function()
  44. self.model.is_game_start = true
  45. if GetModuleIsOpen(147,nil,true) then
  46. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700)
  47. end
  48. end
  49. setTimeout(delay,1)
  50. end
  51. GlobalEventSystem:Bind(EventName.GAME_START, gameStartHandler)
  52. local function role_lv_up(level)
  53. if GetModuleOpenLevel( 147,0,true) == level then
  54. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700)
  55. end
  56. end
  57. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, role_lv_up)
  58. local function ANS_FINISHED_TASK_LIST( task_id )
  59. if task_id == Config.Moduleid[147].task_id then
  60. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700)
  61. end
  62. end
  63. GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST,ANS_FINISHED_TASK_LIST)
  64. local onOpenLightActiveView = function (cur_select_right)--幻光展示界面
  65. if self.LightActiveView == nil then
  66. self.LightActiveView = LightActiveView.New()
  67. end
  68. if self.LightActiveView:HasOpen() then
  69. else
  70. self.LightActiveView:Open(cur_select_right)
  71. end
  72. end
  73. self.model:Bind(LightModel.OPEN_LIGHT_ACTIVE_VIEW, onOpenLightActiveView)
  74. local OPEN_SUCCESS_VIEW = function (cur_select_right, grade, star)--幻光展示界面
  75. if self.lightsuccessview == nil then
  76. self.lightsuccessview = LightSuccessView.New()
  77. self.lightsuccessview:Open(cur_select_right, grade, star)
  78. end
  79. end
  80. self.model:Bind(LightModel.OPEN_SUCCESS_VIEW, OPEN_SUCCESS_VIEW)
  81. end
  82. --幻光基础信息
  83. function LightController:handle14700( )
  84. local scmd = SCMD14700.New(true)
  85. self.model:SetLoginDay( scmd.days )
  86. self.model:SetLightInfo( scmd.visus )
  87. self:CheckLightRedDot()
  88. self.model:Fire(LightModel.ANS_LIGHT_BASE)
  89. -------------------------
  90. local role = Scene.Instance:GetMainRole()
  91. if role then
  92. role:RefreshLightEffect()
  93. end
  94. -------------------------
  95. end
  96. --幻光升级
  97. function LightController:handle14701( )
  98. local scmd = SCMD14701.New(true)
  99. if scmd.result == 1 then
  100. Message.show("升级成功")
  101. GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
  102. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700)
  103. if scmd.grade > 1 and scmd.lv == 1 then
  104. self.model:Fire(LightModel.OPEN_SUCCESS_VIEW,scmd.id,scmd.grade,scmd.lv)
  105. end
  106. self.model:Fire(LightModel.ANS_LIGHT_UPGRADE,scmd.lv)
  107. else
  108. ErrorCodeShow(scmd.result)
  109. self.model:Fire(LightModel.ANS_LIGHT_UPGRADE)
  110. end
  111. end
  112. --幻光幻化
  113. function LightController:handle14702( )
  114. local scmd = SCMD14702.New(true)
  115. if scmd.result == 1 then
  116. GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
  117. if scmd.opty == 1 then
  118. Message.show("穿戴成功")
  119. else
  120. Message.show("取消穿戴")
  121. end
  122. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700)
  123. else
  124. ErrorCodeShow(scmd.result)
  125. end
  126. end
  127. --幻光激活
  128. function LightController:handle14703( )
  129. local scmd = SCMD14703.New(true)
  130. if scmd.result == 1 then
  131. GlobalEventSystem:Fire(EventName.PLAY_UI_EFFECT_SOUND,LuaSoundManager.SOUND_UI.SUCCESS)
  132. Message.show("激活成功")
  133. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14702,scmd.id)
  134. SkillManager.Instance:Fire(SkillManager.UPDATE_SKILL_LIST)
  135. self.model:Fire(LightModel.OPEN_SUCCESS_VIEW,scmd.id,0,0)
  136. -------------------------
  137. --触发一下升级特效
  138. self.model:Fire(LightModel.ANS_LIGHT_UPGRADE,1)
  139. -------------------------
  140. else
  141. ErrorCodeShow(scmd.result)
  142. end
  143. end
  144. --幻光新数据信息
  145. function LightController:handle14704( )
  146. local scmd = SCMD14704.New(true)
  147. self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14700)
  148. GlobalEventSystem:Fire(EventName.GET_DAILY_LIGHT_SKILL)
  149. end
  150. --幻光登录天数更新
  151. function LightController:handle14708( )
  152. local scmd = SCMD14708.New(true)
  153. self.model:SetLoginDay( scmd.days )
  154. self:CheckLightRedDot()
  155. self.model:Fire(LightModel.ANS_LIGHT_BASE)
  156. end
  157. function LightController:CheckLightRedDot( )
  158. local function call_backack( )
  159. self.model:GetLightAllRed(true)
  160. -------------------------
  161. NewMainRoleModel:GetInstance():Fire(NewMainRoleModel.UPDATE_RED_DOT, NewMainRoleModel.TabId.Light)
  162. end
  163. TimeManager.GetInstance():StartTime("LightControllerLightCheckRedDotTimeManager", 0.5, call_backack)
  164. end