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

131 行
3.8 KiB

  1. require("game.proto.102.Require102")
  2. require("game.setting.SettingModel")
  3. SettingController = SettingController or BaseClass(BaseController)
  4. function SettingController:__init()
  5. SettingController.Instance = self
  6. self.model = SettingModel:getInstance()
  7. self:RegisterProtocals()
  8. self:InitEvent()
  9. end
  10. function SettingController:RegisterProtocals()
  11. self:RegisterProtocal(10202,"on10202")
  12. self:RegisterProtocal(10203,"on10203")
  13. self:RegisterProtocal(10204,"on10204")
  14. self:RegisterProtocal(10205,"on10205")
  15. self:RegisterProtocal(10207,"on10207") --服务器跨天
  16. self:RegisterProtocal(10208,"on10208") --战场信息:连杀信息
  17. self:RegisterProtocal(10209,"on10209") --战场信息-击杀推送
  18. end
  19. function SettingController:on10204()
  20. local vo = SCMD10204.New(true)
  21. if vo.error_code ~= 1 then
  22. ErrorCodeShow(vo.error_code)
  23. end
  24. end
  25. --大类型数据返回
  26. function SettingController:on10202()
  27. local vo = SCMD10202.New(true)
  28. self.model:SetTotalSettingInfo(vo)
  29. if vo.type == 1 then --只需要请求一次
  30. ChatModel:getInstance().require_11010_times = 3
  31. ChatModel:getInstance():Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_WORLD)
  32. ChatModel:getInstance():Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_CECRET)
  33. ChatModel:getInstance():Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_CROSS)
  34. ChatModel:getInstance():Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_COUNTRY)
  35. local guild_id = RoleManager.Instance:GetMainRoleVo().guild_id
  36. if guild_id and guild_id ~=0 then
  37. ChatModel:getInstance().require_11010_times = 4
  38. ChatModel:getInstance():Fire(ChatModel.REQUEST_CACHE_EVENT, ChatModel.CHANNEL_GUILD)
  39. end
  40. end
  41. end
  42. function SettingController:on10205()
  43. local vo = SCMD10205.New(true)
  44. ErrorCodeShow(vo.error_code, vo.args)
  45. --重置寻宝状态
  46. if vo.error_code == 1020002 then
  47. TreasureHuntModel:getInstance():ChangeVar("bool_hunting", false)
  48. end
  49. end
  50. function SettingController:on10207()
  51. local vo = SCMD10207.New(true)
  52. GlobalEventSystem:Fire(EventName.CHANE_DAY, vo.type)
  53. end
  54. --设置小类型返回
  55. function SettingController:on10203()
  56. local vo = SCMD10203.New(true)
  57. if vo then
  58. if vo.error_code == 1 then -- 1 表示成功
  59. self.model:SetSettingInfo(vo.type,vo.subtype,vo.is_open)
  60. SettingModel:getInstance():Fire(SettingModel.BROADCAST_SETTING_CHANGE)
  61. else
  62. ErrorCodeShow(vo.error_code)
  63. end
  64. end
  65. end
  66. function SettingController:InitEvent()
  67. local engine_ver = EnglineVersion and tonumber(AppConst.EnglineVer) or 10000
  68. --游戏登陆发送聊天设置请求
  69. local game_start = function ()
  70. self:SendFmtToGame(10202,"c",1)
  71. self:SendFmtToGame(10202,"c",2)
  72. self:SendFmtToGame(10204, "l", engine_ver)
  73. end
  74. GlobalEventSystem:Bind(EventName.GAME_START, game_start)
  75. --请求所有设置信息
  76. local function onRequestTotalSetting(type)
  77. self:SendFmtToGame(10202,"c", type)
  78. end
  79. GlobalEventSystem:Bind(EventName.REQUEST_TOTAL_TYPE_SETTING,onRequestTotalSetting)
  80. --请求所有设置信息
  81. local function onRequestSetSubType(type,subtype,is_open)
  82. self:SendFmtToGame(10203, "ccc", type,subtype,is_open)
  83. end
  84. self.model:Bind(SettingModel.RequestSetSubtype,onRequestSetSubType)
  85. end
  86. function SettingController:on10208()
  87. local vo = SCMD10208.New(true)
  88. local data =
  89. {
  90. num = vo.kill,
  91. pos_x = -100,
  92. pos_y = 0,
  93. }
  94. GlobalEventSystem:Fire(EventName.SHOW_DYNAMIC_FIGHT_KILL_COMBO_TIP, false, true, data)
  95. end
  96. function SettingController:on10209()
  97. local vo = {
  98. killer = {},
  99. deader = {},
  100. }
  101. PictureProtoVo.ReadFmt(vo.killer)
  102. PictureProtoVo.ReadFmt(vo.deader)
  103. local kill_type = vo.type == 1 and 2 or 1
  104. local data = {
  105. role_vo_1 = vo.killer, --我方
  106. role_vo_2 = vo.deader, --敌方
  107. type = kill_type, --UI类型 2是击杀 1是终结
  108. desc = "",
  109. is_break = 1,
  110. max_num = 2,
  111. need_cut_str = true,
  112. }
  113. GlobalEventSystem:Fire(EventName.SHOW_DYNAMIC_FIGHT_TIP, data)
  114. end