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

147 rivejä
5.4 KiB

1 kuukausi sitten
  1. require("game.proto.425.Require425")
  2. require("game.dance.DanceModel")
  3. -- 主界面舞姿选择界面
  4. require("game.dance.DanceMainUISelectPoseView")
  5. require("game.dance.DanceMainUISelectPoseItem")
  6. -- 舞姿界面
  7. require("game.dance.DancePoseView")
  8. require("game.dance.DancePoseItem")
  9. DanceController = DanceController or BaseClass(BaseController, true)
  10. local DanceController = DanceController
  11. --DanceController.IsDebug = true
  12. function DanceController:__init()
  13. DanceController.Instance = self
  14. self.model = DanceModel:getInstance()
  15. self:AddEvents()
  16. self:RegisterAllProtocal()
  17. end
  18. function DanceController:__delete()
  19. end
  20. function DanceController:RegisterAllProtocal( )
  21. local register_cfg = {
  22. [42500] = { -- 舞姿总览
  23. handler = function(self, vo)
  24. self.model:SetDancePosesData(vo)
  25. self.model:CheckDanceRed()
  26. self.model:Fire(DanceModel.UPDATE_DANCE_POSES_DATA)
  27. end,
  28. },
  29. [42501] = { -- 舞姿激活
  30. handler = function(self, vo)
  31. if vo.res == 1 then
  32. Message.show("激活成功", "success")
  33. self.model:UpdateDancePoseList(vo.id)
  34. self.model:CheckDanceRed(vo.id)
  35. self.model:Fire(DanceModel.ACTIVATED_DANCE_POSE, vo.id)
  36. else
  37. ErrorCodeShow(vo.res)
  38. end
  39. end,
  40. },
  41. [42502] = { -- 设置默认舞姿
  42. handler = function(self, vo)
  43. if vo.res == 1 then
  44. Message.show("设置默认舞姿成功", "success")
  45. self.model:UpdateDefaultDancePose(vo.id)
  46. self.model:Fire(DanceModel.UPDATE_DEFAULT_DANCE_POSE, vo.id)
  47. else
  48. ErrorCodeShow(vo.res)
  49. end
  50. end,
  51. },
  52. [42503] = { -- 是否随机舞姿
  53. handler = function(self, vo)
  54. self.model:UpdateRandomDanceFlag(vo.type)
  55. self.model:Fire(DanceModel.UPDATE_RANDOM_DANCE_FLAG)
  56. end,
  57. },
  58. }
  59. self:RegisterProtocalByCFG(register_cfg)
  60. end
  61. function DanceController:AddEvents()
  62. --请求基本信息
  63. local function onRequestEvent(...)
  64. local args = {...}
  65. if args[1] == 42501 or args[1] == 42502 then
  66. self:SendFmtToGame(args[1], "i", args[2])
  67. elseif args[1] == 42503 then
  68. self:SendFmtToGame(args[1], "c", args[2])
  69. else
  70. self:SendFmtToGame(args[1])
  71. end
  72. end
  73. self.model:Bind(DanceModel.REQUEST_CCMD_EVENT, onRequestEvent)
  74. local function onGameStart()
  75. if GetModuleIsOpen(425) then
  76. self.model:Fire(DanceModel.REQUEST_CCMD_EVENT, 42500)
  77. end
  78. end
  79. GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
  80. local function onLevelUp(lv)
  81. if lv == Config.Moduleid[425].open_lv then
  82. onGameStart()
  83. end
  84. end
  85. RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
  86. -- 打开舞姿选择界面
  87. local function openDanceMainUISelectPoseView(show, pos)
  88. self:OpenView("DanceMainUISelectPoseView", show, pos)
  89. end
  90. self.model:Bind(DanceModel.OPEN_DANCE_POSE_SELECT_VIEW, openDanceMainUISelectPoseView)
  91. -- 打开舞姿界面
  92. local function openDancePoseView(show, dance_id, type_id)
  93. self:OpenView("DancePoseView", show, dance_id, type_id)
  94. end
  95. self.model:Bind(DanceModel.OPEN_DANCE_POSE_VIEW, openDancePoseView)
  96. ---- 2021年4月13日新增 统一场景中开始跳舞的接口 ----
  97. -- do_dance true:跳舞 false:取消跳舞 dance_id:舞姿id
  98. local function CHANGE_DANCE_STATUS(do_dance, dance_id)
  99. if do_dance then
  100. local main_role = Scene.Instance:GetMainRole()
  101. if not main_role then return end
  102. local default_dance_id = self.model:GetDefaultDancesPoseId()
  103. if not dance_id or not self.model:GetDancePosesActivatedList(dance_id) then -- 未激活的舞姿不给用,需要切换成默认舞姿
  104. dance_id = default_dance_id
  105. end
  106. if main_role.dance_status and dance_id and main_role.dance_status == dance_id then -- 舞姿相同,啥也不干
  107. return
  108. end
  109. if main_role:IsInState(PoseState.ATTACK) then
  110. Message.show("正在战斗中,请停下战后再跳舞!")
  111. return
  112. elseif main_role:IsSwimState() then -- 处于游泳状态
  113. Message.show("水中无法使用跳舞动作")
  114. return
  115. elseif main_role:IsInState(PoseState.DIZZY)
  116. or main_role:IsInState(PoseState.DEAD)
  117. or main_role:IsInState(PoseState.COLLECT)
  118. or main_role:IsInState(PoseState.FLY_SHOE)
  119. or main_role:IsInState(PoseState.JUMP) then
  120. Message.show("当前状态无法跳舞")
  121. return
  122. end
  123. -- 上了坐骑就得先下来
  124. local is_ride = RoleManager:getInstance():GetMainRoleVo() and (RoleManager:getInstance():GetMainRoleVo().is_ride ~= 0)
  125. if is_ride then
  126. GlobalEventSystem:Fire(EventName.HIDE_HORSE)
  127. end
  128. self:SendFmtToGame(12025, "c", dance_id)
  129. else
  130. self:SendFmtToGame(12025, "c", 0)
  131. end
  132. end
  133. self.model:Bind(DanceModel.CHANGE_DANCE_STATUS, CHANGE_DANCE_STATUS)
  134. end