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

242 lines
7.3 KiB

пре 4 недеља
  1. -- require("game.proto.416.Require416")
  2. require("game.hopeGift.HopeGiftConst")
  3. require("game.hopeGift.HopeGiftModel")
  4. require("game.hopeGift.view.HopeGiftMainView")--臻享礼包主界面
  5. require("game.hopeGift.view.HopeGiftMainTab")--明日之主界面页签
  6. require("game.hopeGift.view.HopeGiftMainSubTab")--明日之主界面子页签
  7. require("game.hopeGift.view.HopeGiftSubView")--臻享礼包子界面
  8. require("game.hopeGift.view.HopeGiftAwardShowView")--臻享礼包奖励展示界面
  9. require("game.hopeGift.view.HopeGiftAwardShowItem")--臻享礼包奖励展示item
  10. require("game.hopeGift.view.HopeGiftMainAwardCon")--臻享礼包奖励动画奖励Con
  11. require("game.hopeGift.view.HopeGiftMainModelItem")--臻享礼包模型展示item
  12. HopeGiftController = HopeGiftController or BaseClass(BaseController)
  13. HopeGiftController.Is_Debug = false
  14. function HopeGiftController:__init()
  15. HopeGiftController.Instance = self
  16. self.model = HopeGiftModel:getInstance()
  17. self.mainVo = RoleManager.Instance.mainRoleInfo
  18. self:RegisterAllProtocals()
  19. self:AddAllEvents()
  20. end
  21. function HopeGiftController:__delete()
  22. end
  23. function HopeGiftController:AddAllEvents()
  24. local function game_start_func()
  25. end
  26. GlobalEventSystem:Bind(EventName.GAME_START,game_start_func)
  27. local onHopeGiftAwardShowView = function (sub_type)
  28. if self.HopeGiftAwardShowView == nil then
  29. self.HopeGiftAwardShowView = HopeGiftAwardShowView.New()
  30. end
  31. if self.HopeGiftAwardShowView:HasOpen() then
  32. else
  33. self.HopeGiftAwardShowView:Open(sub_type)
  34. end
  35. end
  36. self.model:Bind(HopeGiftModel.OPEN_HOPE_GIFT_AWARD_SHOW_VIEW, onHopeGiftAwardShowView)
  37. -- local function CheckRedPoint( ... )
  38. -- end
  39. -- GlobalEventSystem:Bind(GoodsModel.CHANGE_BAGLIST,game_start_func)
  40. local function change_day_func(type)
  41. if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
  42. local base_type = CustomActivityModel.CustomActBaseType.HOPE_GIFT
  43. local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
  44. for k, v in pairs(act_list) do
  45. self.model:Fire(HopeGiftModel.REQUEST_INFO,33136,v.sub_type)
  46. end
  47. end
  48. end
  49. GlobalEventSystem:Bind(EventName.CHANE_DAY, change_day_func)
  50. local function request_info(request_id , ... )
  51. if not HopeGiftController.Is_Debug then
  52. local fun_name = string.format("send%s",request_id)
  53. if self[fun_name] then
  54. print('----in HopeGiftController.lua,line 44 request_id',request_id , ...)
  55. self[fun_name](self,...)
  56. end
  57. elseif request_id == 33136 or request_id == 33137 or request_id == 33138 then
  58. local fun_name = string.format("handle%s",request_id)
  59. if self[fun_name] then
  60. print('----in HopeGiftController.lua,line 96 request_idIs_Debug',request_id , ...)
  61. self[fun_name](self,...)
  62. end
  63. end
  64. end
  65. self.model:Bind(HopeGiftModel.REQUEST_INFO,request_info)
  66. local function init_open_day( ... )--开服天数初始化
  67. end
  68. GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day)
  69. --升级
  70. local function onLevelUp(level)
  71. end
  72. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
  73. local updateInfo = function (base_type,sub_type)
  74. if base_type == CustomActivityModel.CustomActBaseType.HOPE_GIFT then
  75. self.model:Fire(HopeGiftModel.REQUEST_INFO,33136,sub_type)
  76. end
  77. end
  78. CustomActivityModel:getInstance():Bind(CustomActivityModel.UPDATE_ACTIVITY_INFO,updateInfo)
  79. end
  80. function HopeGiftController:RegisterAllProtocals()
  81. self:RegisterProtocal(33136, "handle33136") -- 臻享礼包:轮次信息
  82. self:RegisterProtocal(33137, "handle33137") -- 臻享礼包:领取钥匙
  83. self:RegisterProtocal(33138, "handle33138") -- 臻享礼包:抽奖
  84. end
  85. -- ################# 臻享礼包:轮次信息 ############
  86. -- protocol=33136
  87. -- {
  88. -- c2s{
  89. -- sub_type:int8 // 定制活动子类型
  90. -- }
  91. -- s2c{
  92. -- sub_type:int8 // 定制活动子类型
  93. -- round:int8 // 当前抽奖轮次
  94. -- day_lucky_limit:int8 // 今日抽奖上限:0否1是
  95. -- already_get_list:array{
  96. -- grade_id:int8 // 每个档位ID
  97. -- get_num:int16 // 当前已领取钥匙数量
  98. -- status:int8 // 今日领取钥匙状态1已领取0未领取
  99. -- }
  100. -- get_id:array{
  101. -- award_id:int16 // 当前轮次已经抽取到的奖励id
  102. -- }
  103. -- }
  104. -- }
  105. function HopeGiftController:send33136(sub_type)
  106. self:SendFmtToGame(33136,"c",sub_type)
  107. end
  108. function HopeGiftController:handle33136()
  109. local scmd = {}
  110. if not HopeGiftController.Is_Debug then
  111. scmd = SCMD33136.New(true)
  112. else
  113. scmd = {
  114. sub_type = 1,
  115. round = 1,
  116. }
  117. local already_get_list = {}
  118. for i=1,4 do
  119. already_get_list[i] = {}
  120. already_get_list[i].grade_id = i
  121. already_get_list[i].get_num = 0
  122. already_get_list[i].status = 0
  123. end
  124. scmd.already_get_list = already_get_list
  125. local get_id = {}
  126. for i=1,10 do
  127. -- get_id[i] = {}
  128. -- get_id[i].award_id = i
  129. end
  130. scmd.get_id = get_id
  131. end
  132. self.model:SetHopeGiftInfo(scmd)
  133. VipModel:getInstance():IsNeedRed(VipModel.TabType.HopeGift,nil,scmd.sub_type)
  134. -- print("huangcong:HopeGiftController [117]: ",scmd.day_lucky_limit)
  135. -- PrintTable(scmd)
  136. end
  137. -- ################# 臻享礼包:领取钥匙 ############
  138. -- protocol=33137
  139. -- {
  140. -- c2s{
  141. -- sub_type:int8 // 定制活动子类型
  142. -- }
  143. -- s2c{
  144. -- res:int32
  145. -- sub_type:int8 // 定制活动子类型
  146. -- }
  147. -- }
  148. function HopeGiftController:send33137(sub_type)
  149. self:SendFmtToGame(33137,"c",sub_type)
  150. end
  151. function HopeGiftController:handle33137()
  152. local scmd = {}
  153. if not HopeGiftController.Is_Debug then
  154. scmd = SCMD33137.New(true)
  155. else
  156. scmd = {}
  157. end
  158. if scmd.res == 1 then
  159. local goods_name = GoodsModel:getInstance():getGoodsName(self.model.cost_id, true)
  160. local str = string.format("获得 %s x%s",goods_name,self.model.return_day_sum_num)
  161. Message.show(str,"success")
  162. self.model:SetHopeGiftIsAction(false,scmd.sub_type)
  163. self.model:Fire(HopeGiftModel.REQUEST_INFO,33136,scmd.sub_type)
  164. else
  165. ErrorCodeShow(scmd.res)
  166. end
  167. -- print("huangcong:HopeGiftController [117]: ",scmd)
  168. -- PrintTable(scmd)
  169. end
  170. -- ################# 臻享礼包:抽奖 ############
  171. -- protocol=33138
  172. -- {
  173. -- c2s{
  174. -- sub_type:int8 // 定制活动子类型
  175. -- num:int8 // 抽奖次数
  176. -- }
  177. -- s2c{
  178. -- res:int32
  179. -- sub_type:int8 // 定制活动子类型
  180. -- day_lucky_limit:int8 // 今日抽奖上限:0否1是
  181. -- get_id:array{
  182. -- award_id:int16 // 抽取到的奖励id
  183. -- }
  184. -- }
  185. -- }
  186. function HopeGiftController:send33138(sub_type,num)
  187. self:SendFmtToGame(33138,"cc",sub_type,num)
  188. end
  189. function HopeGiftController:handle33138()
  190. local scmd = {}
  191. if not HopeGiftController.Is_Debug then
  192. scmd = SCMD33138.New(true)
  193. else
  194. scmd = {
  195. res = 1,
  196. sub_type = 1,
  197. }
  198. local get_id = {}
  199. for i=1,1 do
  200. get_id[i] = {}
  201. get_id[i].award_id = 9
  202. end
  203. scmd.get_id = get_id
  204. end
  205. -- print("huangcong:HopeGiftController [start:213] :", scmd)
  206. -- PrintTable(scmd)
  207. -- print("huangcong:HopeGiftController [end]")
  208. if scmd.res == 1 then
  209. self.model:Fire(HopeGiftModel.UPDATE_LUCKY_INFO,scmd.get_id,scmd.sub_type)
  210. else
  211. self.model:SetHopeGiftIsAction(false,scmd.sub_type)
  212. ErrorCodeShow(scmd.res)
  213. end
  214. -- print("huangcong:HopeGiftController [117]: ",scmd)
  215. -- PrintTable(scmd)
  216. end