------------------------------------------------ --作者: yangqf --日期: 2021-02-22 --文件: SitDownSystem.lua --模块: SitDownSystem --描述: 打坐系统 ------------------------------------------------ local SitDownSystem = { --打坐开始时间 SitDownStartTime = 0, --打坐期间增加的经验 总值 TotalExp = 0, --经验加成百分比,百分比数值 例150%,值为150 CurExpAddRate = 0, } --请求开始打坐 function SitDownSystem:ReqStartSitDown() local _mapCfg = GameCenter.MapLogicSystem.MapCfg if _mapCfg == nil then return end if _mapCfg.MapExp == 1 then Utils.ShowPromptByEnum("C_EXPCOPY_CANNOT_SITDOWN") return end local _lp = GameCenter.GameSceneSystem:GetLocalPlayer() if _lp ~= nil and _lp.IsOnMount then --判断是否可以在坐骑上打坐 local _mountId = _lp.Skin:GetSkinPartCfgID(FSkinPartCode.Mount) local _cfg = DataConfig.DataHuaxingHorse[_mountId] local _doMountDown = true if _cfg ~= nill and _cfg.CanSitDown ~= 0 then _doMountDown = false end if _doMountDown then _lp:MountDown() end end GameCenter.Network.Send("MSG_Hook.ReqStartSitDown", {}) end --请求结束打坐 function SitDownSystem:ReqEndSitDown() GameCenter.Network.Send("MSG_Hook.ReqEndSitDown", {}) end --返回开始打坐消息 function SitDownSystem:ResStartSitDown(result) if result.canSitDown then local _player = GameCenter.GameSceneSystem:FindPlayer(result.roleId) if _player ~= nil then _player:Action_SitDown(); --如果角色正在打坐了,那么就打开获得经验的面板 if _player:IsLocalPlayer() then self.SitDownStartTime = GameCenter.HeartSystem.ServerTime GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_SITDOWN_START) end end end end --同步经验值和飘字 x秒同步一次,x由配置表控制(经验地图、打坐的同步频率不同,global表:1480, 1481) function SitDownSystem:ResSyncExpAdd(result) local _lp = GameCenter.GameSceneSystem:GetLocalPlayer() if _lp == nil then return end self.TotalExp = self.TotalExp + result.addExp self.CurExpAddRate = result.rate GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_SHOWEXP_UPDATE, result.addExp) end --返回结束打坐 function SitDownSystem:ResEndSitDown(result) if result.success then local _player = GameCenter.GameSceneSystem:FindPlayer(result.roleId) if _player ~= nil then if _player.IsSitDown then _player:Stop_Action() end if _player:IsLocalPlayer() then self.SitDownStartTime = 0 self.TotalExp = 0 GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_SITDOWN_END) end end end end return SitDownSystem