require("game.proto.425.Require425")
|
|
require("game.dance.DanceModel")
|
|
-- 主界面舞姿选择界面
|
|
require("game.dance.DanceMainUISelectPoseView")
|
|
require("game.dance.DanceMainUISelectPoseItem")
|
|
-- 舞姿界面
|
|
require("game.dance.DancePoseView")
|
|
require("game.dance.DancePoseItem")
|
|
|
|
|
|
DanceController = DanceController or BaseClass(BaseController, true)
|
|
local DanceController = DanceController
|
|
|
|
--DanceController.IsDebug = true
|
|
|
|
function DanceController:__init()
|
|
DanceController.Instance = self
|
|
self.model = DanceModel:getInstance()
|
|
self:AddEvents()
|
|
self:RegisterAllProtocal()
|
|
|
|
end
|
|
|
|
function DanceController:__delete()
|
|
end
|
|
|
|
function DanceController:RegisterAllProtocal( )
|
|
local register_cfg = {
|
|
[42500] = { -- 舞姿总览
|
|
handler = function(self, vo)
|
|
self.model:SetDancePosesData(vo)
|
|
self.model:CheckDanceRed()
|
|
self.model:Fire(DanceModel.UPDATE_DANCE_POSES_DATA)
|
|
end,
|
|
},
|
|
[42501] = { -- 舞姿激活
|
|
handler = function(self, vo)
|
|
if vo.res == 1 then
|
|
Message.show("激活成功", "success")
|
|
self.model:UpdateDancePoseList(vo.id)
|
|
self.model:CheckDanceRed(vo.id)
|
|
self.model:Fire(DanceModel.ACTIVATED_DANCE_POSE, vo.id)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end,
|
|
},
|
|
[42502] = { -- 设置默认舞姿
|
|
handler = function(self, vo)
|
|
if vo.res == 1 then
|
|
Message.show("设置默认舞姿成功", "success")
|
|
self.model:UpdateDefaultDancePose(vo.id)
|
|
self.model:Fire(DanceModel.UPDATE_DEFAULT_DANCE_POSE, vo.id)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end,
|
|
},
|
|
[42503] = { -- 是否随机舞姿
|
|
handler = function(self, vo)
|
|
self.model:UpdateRandomDanceFlag(vo.type)
|
|
self.model:Fire(DanceModel.UPDATE_RANDOM_DANCE_FLAG)
|
|
end,
|
|
},
|
|
}
|
|
self:RegisterProtocalByCFG(register_cfg)
|
|
end
|
|
|
|
function DanceController:AddEvents()
|
|
--请求基本信息
|
|
local function onRequestEvent(...)
|
|
local args = {...}
|
|
if args[1] == 42501 or args[1] == 42502 then
|
|
self:SendFmtToGame(args[1], "i", args[2])
|
|
elseif args[1] == 42503 then
|
|
self:SendFmtToGame(args[1], "c", args[2])
|
|
else
|
|
self:SendFmtToGame(args[1])
|
|
end
|
|
end
|
|
self.model:Bind(DanceModel.REQUEST_CCMD_EVENT, onRequestEvent)
|
|
|
|
local function onGameStart()
|
|
if GetModuleIsOpen(425) then
|
|
self.model:Fire(DanceModel.REQUEST_CCMD_EVENT, 42500)
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
|
|
|
|
local function onLevelUp(lv)
|
|
if lv == Config.Moduleid[425].open_lv then
|
|
onGameStart()
|
|
end
|
|
end
|
|
RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
|
|
|
|
-- 打开舞姿选择界面
|
|
local function openDanceMainUISelectPoseView(show, pos)
|
|
self:OpenView("DanceMainUISelectPoseView", show, pos)
|
|
end
|
|
self.model:Bind(DanceModel.OPEN_DANCE_POSE_SELECT_VIEW, openDanceMainUISelectPoseView)
|
|
|
|
-- 打开舞姿界面
|
|
local function openDancePoseView(show, dance_id, type_id)
|
|
self:OpenView("DancePoseView", show, dance_id, type_id)
|
|
end
|
|
self.model:Bind(DanceModel.OPEN_DANCE_POSE_VIEW, openDancePoseView)
|
|
|
|
---- 2021年4月13日新增 统一场景中开始跳舞的接口 ----
|
|
-- do_dance true:跳舞 false:取消跳舞 dance_id:舞姿id
|
|
local function CHANGE_DANCE_STATUS(do_dance, dance_id)
|
|
if do_dance then
|
|
local main_role = Scene.Instance:GetMainRole()
|
|
if not main_role then return end
|
|
local default_dance_id = self.model:GetDefaultDancesPoseId()
|
|
if not dance_id or not self.model:GetDancePosesActivatedList(dance_id) then -- 未激活的舞姿不给用,需要切换成默认舞姿
|
|
dance_id = default_dance_id
|
|
end
|
|
if main_role.dance_status and dance_id and main_role.dance_status == dance_id then -- 舞姿相同,啥也不干
|
|
return
|
|
end
|
|
if main_role:IsInState(PoseState.ATTACK) then
|
|
Message.show("正在战斗中,请停下战后再跳舞!")
|
|
return
|
|
elseif main_role:IsSwimState() then -- 处于游泳状态
|
|
Message.show("水中无法使用跳舞动作")
|
|
return
|
|
elseif main_role:IsInState(PoseState.DIZZY)
|
|
or main_role:IsInState(PoseState.DEAD)
|
|
or main_role:IsInState(PoseState.COLLECT)
|
|
or main_role:IsInState(PoseState.FLY_SHOE)
|
|
or main_role:IsInState(PoseState.JUMP) then
|
|
Message.show("当前状态无法跳舞")
|
|
return
|
|
end
|
|
-- 上了坐骑就得先下来
|
|
local is_ride = RoleManager:getInstance():GetMainRoleVo() and (RoleManager:getInstance():GetMainRoleVo().is_ride ~= 0)
|
|
if is_ride then
|
|
GlobalEventSystem:Fire(EventName.HIDE_HORSE)
|
|
end
|
|
self:SendFmtToGame(12025, "c", dance_id)
|
|
else
|
|
self:SendFmtToGame(12025, "c", 0)
|
|
end
|
|
end
|
|
self.model:Bind(DanceModel.CHANGE_DANCE_STATUS, CHANGE_DANCE_STATUS)
|
|
end
|