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

1793 lines
58 KiB

  1. require("game.scene.SceneManager")
  2. require("game.particalEffect.ParticleManager")
  3. require("game.scene.SceneLoadView")
  4. require("game.proto.121.Require121")
  5. require("game.scene.ChangeSceneMovie")
  6. require("game.scene.ChangeSceneMovieRT")
  7. SceneController=SceneController or BaseClass(BaseController)
  8. local SceneController = SceneController
  9. local GlobalEventSystem = GlobalEventSystem
  10. local SceneManager = SceneManager
  11. local lua_viewM = lua_viewM
  12. local print = print
  13. local math_floor = math.floor
  14. function SceneController:__init()
  15. SceneController.Instance = self
  16. OperateManager.New()
  17. MainCamera.New()
  18. self.scene_mgr = SceneManager:getInstance()
  19. self.scene = Scene:getInstance()
  20. self:RegisterAllProtocals()
  21. self:RegisterAllEvents()
  22. Runner.Instance:AddRunObj(self, 1)
  23. Runner.Instance:AddLateRunObj(self)
  24. --用于计算持续无缝切换的次数,超过三次则强制执行正常切换场景
  25. self.continuity_noloading_times = 0
  26. --是否忽略上面那个参数的计数
  27. self.ignore_count_loading_time = false
  28. self.frame_index = 0
  29. end
  30. function SceneController:__delete()
  31. end
  32. function SceneController:RegisterAllProtocals()
  33. --[[@tips
  34. NOTICE_SCENE_LOAD_WILL_COMPLETE事件请求12035协议
  35. 12035广13009
  36. 13009SCENE_LOAD_VIEW_COMPLETE事件
  37. ]]
  38. self:RegisterProtocal2(12001, SceneController.handler12001) --走路
  39. self:RegisterProtocal2(12002, SceneController.handler12002) --加载场景信息
  40. self:RegisterProtocal2(12003, SceneController.handler12003) --通知场景玩家有某个玩家进入
  41. self:RegisterProtocal2(12004, SceneController.handler12004) --有玩家离开场景
  42. self:RegisterProtocal2(12005, SceneController.handler12005) --切换到新场景 0服务器传送 1小飞鞋 2世界传送(到出生点) 3传统传送门 4任意城市传送门
  43. self:RegisterProtocal2(12006, SceneController.handler12006) --清除场景对象
  44. self:RegisterProtocal2(12007, SceneController.handler12007) --怪物进入
  45. self:RegisterProtocal2(12008, SceneController.handler12008) --场景对象移动
  46. self:RegisterProtocal2(12009, SceneController.handler12009) --角色血量变化
  47. self:RegisterProtocal2(12010, SceneController.handler12010) --场景角色属性更改
  48. self:RegisterProtocal2(12011, SceneController.handler12011) --9宫格加载用户
  49. self:RegisterProtocal2(12012, SceneController.handler12012) --9宫格加载场景对象
  50. self:RegisterProtocal2(12013, SceneController.handler12013) --广播玩家进入飘窗提示
  51. self:RegisterProtocal(12014, "handler12014")
  52. self:RegisterProtocal(12015, "handler12015")
  53. self:RegisterProtocal(12016, "handler12016")--通用状态变更通知
  54. self:RegisterProtocal(12020, "handler12020")
  55. self:RegisterProtocal(12023, "handler12023")
  56. self:RegisterProtocal(12025, "handler12025") -- 玩家动作播放
  57. self:RegisterProtocal(12027, "handler12027") -- 玩家动作播放
  58. self:RegisterProtocal(12070, "handler12070")
  59. self:RegisterProtocal(12071, "handler12071")
  60. self:RegisterProtocal(12072, "handler12072")
  61. self:RegisterProtocal(12073, "handler12073")
  62. self:RegisterProtocal(12075, "handler12075")
  63. self:RegisterProtocal(12076, "handler12076")
  64. self:RegisterProtocal(12078, "handler12078")
  65. self:RegisterProtocal(12080, "handler12080")
  66. self:RegisterProtocal(12081, "handler12081")
  67. self:RegisterProtocal(12082, "handler12082")
  68. self:RegisterProtocal(12083, "handler12083")
  69. self:RegisterProtocal(12084, "handler12084")
  70. self:RegisterProtocal(12085, "handler12085")
  71. self:RegisterProtocal(12086, "handler12086")
  72. --npc
  73. self:RegisterProtocal(12100, "handler12100") --动态npc信息
  74. self:RegisterProtocal(12103, "handler12103") --场景中动态改变NPC状态
  75. --场景掉落
  76. self:RegisterProtocal(12017, "handler12017") --物品包掉落
  77. self:RegisterProtocal(12018, "handler12018") --玩家上线后能看到身边周围的怪物掉落
  78. self:RegisterProtocal(12019, "handler12019") --场景/九宫格物品消失,相对于其他玩家
  79. self:RegisterProtocal(12024, "handler12024") --攻防双方都飘字的血量变化
  80. self:RegisterProtocal(12034, "handler12034") --请求超链接坐标切场景
  81. self:RegisterProtocal(12030, "handler12030") --改变动态区域属性
  82. self:RegisterProtocal(12032, "handler12032") --改变动态特效属性
  83. self:RegisterProtocal(12033, "handler12033") --小飞鞋
  84. self:RegisterProtocal(12022, "handler12022") --boss归属
  85. self:RegisterProtocal(12089, "handler12089") --场景活动标识改变
  86. self:RegisterProtocal(12090, "handler12090") --怪物非常用属性修改
  87. self:RegisterProtocal(12099, "handler12099") --移动协议错误通知(0非错误[实际上不通知],1错误目标场景,2CD时间,3距离超限)
  88. end
  89. --[[
  90. .
  91. zsm
  92. ]]
  93. function SceneController:Update(now_time, elapse_time)
  94. -- --对于服务端战斗场景,每帧都创建一个怪
  95. -- local delay_num = SceneManager.Instance:GetDelayMonsterNum()
  96. -- if delay_num > 0 and (self.create_delay_time == nil or now_time - self.create_delay_time > 0.1) then
  97. -- SceneManager.Instance:AddDelaydMonsterVo()
  98. -- self.create_delay_time = now_time
  99. -- end
  100. -- --每帧创建一个玩家
  101. -- local delay_role_num = SceneManager.Instance:GetDelayRoleNum()
  102. -- if delay_role_num > 0 and (self.create_role_delay_time == nil or now_time - self.create_role_delay_time > 0.1) then
  103. -- SceneManager.Instance:AddDelayRoleVo()
  104. -- self.create_role_delay_time = now_time
  105. -- end
  106. -- self.scene:Update(now_time, elapse_time)
  107. self.frame_index = self.frame_index + 1
  108. -- if G_DEBUG_UPDATE_STEP and self.frame_index % G_DEBUG_UPDATE_STEP ~= 0 then
  109. -- return
  110. -- end
  111. if self.frame_index % (lua_viewM:GetFrameUpdateCount() + 3) == 0 then
  112. --对于服务端战斗场景,每帧都创建一个怪
  113. self.scene_mgr:AddDelaydMonsterVo()
  114. end
  115. if self.scene_mgr:IsMainCityorYieldScene() then
  116. if self.frame_index % (lua_viewM:GetFrameUpdateCount() + 13) == 0 then
  117. self.scene_mgr:AddDelayRoleVo()
  118. end
  119. else
  120. --每帧创建一个玩家
  121. self.scene_mgr:AddDelayRoleVo()
  122. end
  123. self.scene:Update(now_time, elapse_time)
  124. end
  125. function SceneController:LoadSceneInfoRequest(scene_id)
  126. -- 先请求NPC列表再请求12002
  127. self:SendFmtToGame(12100, "i", scene_id or SceneManager.Instance:GetSceneId())
  128. end
  129. function SceneController:handler12001()
  130. local self = SceneController.Instance
  131. local rx,ry,role_id,fly_flag = self:ReadFmt("hhlc")
  132. local args_1, args_2, args_3, args_4 = 0
  133. if fly_flag ~= MOVE_TYPE.NORMOL_MOVE then --非正常走路
  134. args_1, args_2, args_3, args_4 = self:ReadFmt("hhhh")
  135. end
  136. -- if fly_flag == 4 then
  137. -- print(">>>>>> TASK_JUMP >>> ", args_1, args_2, args_3, args_4)
  138. -- end
  139. -- if fly_flag == 0 then
  140. -- print(">>>>>> NORMOL_MOVE >>> ", args_1, args_2, args_3, args_4)
  141. -- end
  142. if role_id ~= RoleManager.Instance:GetMainRoleId() then
  143. self.scene:RoleMove(role_id, rx, ry, fly_flag, args_1, args_2, args_3, args_4)
  144. end
  145. end
  146. -----------------加载场景信息反馈(12002)------------
  147. function SceneController:handler12002()
  148. local self = SceneController.Instance
  149. print("----------handler12002---------")
  150. if SceneManager.Instance:IsSceneStart() then
  151. return
  152. end
  153. SceneManager.Instance:ClearAllVo()
  154. --处理传送阵和NPC,里面会判断是否需要重新加载
  155. SceneManager.Instance:LoadNpcsAndDoors()
  156. --处理场景内的跳点
  157. SceneManager.Instance:LoadJumpPoints()
  158. --处理玩家
  159. SceneManager.Instance:ResetCachedRoleList() --重置缓存队列
  160. local add_num = self:ReadFmt("h")
  161. for i = 1, add_num do
  162. self:handler12003()
  163. end
  164. --处理怪物
  165. add_num = self:ReadFmt("h")
  166. for i = 1, add_num do
  167. self:handler12007()
  168. end
  169. --处理其他场景对象
  170. add_num = self:ReadFmt("h")
  171. for i = 1, add_num do
  172. self:handler12014()
  173. end
  174. --假人
  175. add_num = self:ReadFmt("h")
  176. for i = 1, add_num do
  177. self:handler12015()
  178. end
  179. --请求动态区域信息
  180. self:handler12030()
  181. --场景开始流程
  182. SceneManager.Instance:SceneStart()
  183. --场景中的怪物类型,如果没有加载过,就要
  184. -- local scene_id = SceneManager.Instance:GetSceneId()
  185. -- local monster_types = SceneManager.Instance:GetMonsterTypeInScene(scene_id)
  186. -- if monster_types then
  187. -- for _, type_vo in pairs(monster_types) do
  188. -- SceneManager.Instance:AddMonsterType(type_vo)
  189. -- end
  190. -- end
  191. --请求上线时要显示的掉落
  192. self:SendFmtToGame(12018)
  193. if Scene.Instance:IsProgressLoadFinish() then
  194. --通知服务器完成了场景切换
  195. self:SendFmtToGame(12035)
  196. GlobalEventSystem:Fire(SceneEventType.REQUEST_DYNAMIC_EFFECT)
  197. end
  198. --通知npc加载完成
  199. GlobalEventSystem:Fire(EventName.NPC_LOAD_FINISH)
  200. --无缝加载之后的同步坐标,服务端限制了只能在12002协议之后生效
  201. if self.is_no_loading_scene then
  202. local function on_delay( )
  203. self:SendFmtToGame(12035)
  204. if not SceneManager.Instance:IsOneTowerScene() then
  205. local pos_x, pos_y, angel = SceneManager:getInstance():GetCacheMainRolePos( )
  206. if pos_x and pos_y and angel then
  207. GlobalEventSystem:Fire(SceneEventType.MOVEREQUEST, pos_x, pos_y, MOVE_TYPE.BLINK)
  208. SceneManager:getInstance():ResetCacheMainRolePos( )
  209. end
  210. end
  211. end
  212. on_delay()
  213. end
  214. end
  215. --请求切换场景
  216. function SceneController:requestChangeScene( scene_id, call_back_type, send_type, pos_x, pos_y)
  217. if self.fly_shoe_event_id or self.fly_shoe__delay_event_id then
  218. return
  219. end
  220. pos_x = pos_x or 0
  221. pos_y = pos_y or 0
  222. pos_x = pos_x < 0 and 0 or math.floor(pos_x)
  223. pos_y = pos_y < 0 and 0 or math.floor(pos_y)
  224. self.scene_mgr:SetCurrentReqChangeSceneId(scene_id)
  225. self:SendFmtToGame(12005, "iicchh", 0,scene_id, call_back_type or 0, send_type or 0, pos_x, pos_y)
  226. end
  227. --脱离卡死加载场景,由客户端触发
  228. function SceneController:OutOfStuck()
  229. local func = function ()
  230. local scene_id = SceneManager.Instance:GetSceneId()
  231. OperateManager.Instance:StopMove(true)
  232. SceneManager.Instance:ClearAllVo()
  233. self.scene:ClearScene(false)
  234. self.scene:CreateMainRole()
  235. local main_role = Scene.Instance:GetMainRole()
  236. local vo = ConfigItemMgr.Instance:GetSceneItem(scene_id)
  237. main_role:SetRealPos(vo.x, vo.y,true)
  238. GlobalEventSystem:Fire(SceneEventType.OPEN_SCENE_LOAD_VIEW)
  239. self:SendFmtToGame(12001, "ihhchhhh", scene_id,Util.Int(vo.x),Util.Int(vo.y),flag or 0,Util.Int(vo.x), Util.Int(vo.y), Util.Int(start_fly_x), Util.Int(start_fly_y))
  240. self:LoadSceneInfoRequest()
  241. end
  242. SceneManager.Instance:ShowPreChangeSceneView( func )
  243. end
  244. function SceneController:handler12003()
  245. local self = SceneController.Instance
  246. local role_vo = RoleVo.New()
  247. role_vo:ReadFromProtocal()
  248. local grid_x, grid_y = role_vo.pos_x / SceneObj.LogicRealRatio.x, role_vo.pos_y / SceneObj.LogicRealRatio.y
  249. if self.scene_mgr:IsBlockXY(grid_x, grid_y) then
  250. local end_pos = SourceOperateMove.FindNoBlockPos(co.TableXY(grid_x, grid_y))
  251. role_vo.pos_x = end_pos.x * SceneObj.LogicRealRatio.x
  252. role_vo.pos_y = end_pos.y * SceneObj.LogicRealRatio.y
  253. if role_vo.role_id == RoleManager.Instance:GetMainRoleId() then
  254. local main_role = self.scene.main_role
  255. if main_role then
  256. main_role:SetRealPos(role_vo.pos_x,role_vo.pos_y,true)
  257. main_role:SetGhostMode(false)
  258. end
  259. --角色复活,刷新左上角血量
  260. GlobalEventSystem:Fire(EventName.MAINROLE_RESURGENCE,role_vo.role_id,role_vo.hp,role_vo.maxHp)
  261. end
  262. end
  263. SceneManager.Instance:AddRoleVo(role_vo, true)
  264. end
  265. function SceneController:handler12004()
  266. local self = SceneController.Instance
  267. local role_id = self:ReadFmt("l")
  268. SceneManager.Instance:DeleteRoleVo(role_id)
  269. end
  270. function SceneController:handler12005()
  271. if not SceneController.Instance.is_game_started then
  272. return
  273. end
  274. local self = SceneController.Instance
  275. local instance_id, --场景实例ID(int32)
  276. pos_x, --进入场景的X坐标(int16)
  277. pos_y, --进入场景的Y坐标(int16)
  278. error_code, --错误信息(int32)
  279. dun_id,
  280. call_back_type,
  281. send_type = self:ReadFmt("ihhiicc")
  282. print("----------handler12005---------",call_back_type, instance_id, SceneManager.Instance.last_scene_id, dun_id, pos_x, pos_y)
  283. self:RemoveSendFmtCheckout(12002)--移除12002协议超时检测
  284. --防止同时刻因为请求了小飞鞋切场景,然后服务器还返回的,导致客户端正常切场景失败
  285. if instance_id == 0 and error_code == 1200017 and self.fly_shoe_event_id then
  286. ErrorCodeShow(error_code)
  287. return
  288. end
  289. --无尽回廊 爬塔时切换场景不要关闭其他界面
  290. local dun_tower_not_close_all_view = false
  291. if SceneManager.Instance:IsOneTowerNormalDungeon(dun_id) then
  292. if SceneManager.Instance:IsOneTowerNormalDungeon() then
  293. dun_tower_not_close_all_view = true
  294. end
  295. end
  296. TaskModel:getInstance().proto_count = 0
  297. self.last_send_pos = false
  298. if self.fly_shoe_event_id then
  299. GlobalTimerQuest:CancelQuest(self.fly_shoe_event_id)
  300. self.fly_shoe_event_id = nil
  301. end
  302. if self.fly_shoe__delay_event_id then
  303. GlobalTimerQuest:CancelQuest(self.fly_shoe__delay_event_id)
  304. self.fly_shoe__delay_event_id = nil
  305. end
  306. if not dun_tower_not_close_all_view then
  307. EventSystem.Fire(GlobalEventSystem,EventName.CLOSE_MAPPANEL_VIEW)
  308. EventSystem.Fire(GlobalEventSystem,EventName.CLOSE_ALL_VIEW)
  309. end
  310. local is_no_loading_scene = self.scene_mgr:NoLoadingViewScene(instance_id)
  311. if is_no_loading_scene and not SceneManager.Instance:IsOneTowerScene() then
  312. self.scene_mgr:SetCacheMainRolePos()
  313. end
  314. self.is_no_loading_scene = is_no_loading_scene
  315. self.temp_instance_id = instance_id
  316. if instance_id ~= 0 and (send_type or self.scene_mgr:IsDungeonScene() or self.scene_mgr:IsDungeonScene(instance_id)) and not is_no_loading_scene then --使用飞鞋传送
  317. GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT, false, true)
  318. local function delay_method( )
  319. local main_role = self.scene:GetMainRole()
  320. if main_role then
  321. -- if (send_type == 3 or send_type == 4) then
  322. -- main_role:DoTransfer(nil, 2, nil)
  323. -- else
  324. if self.temp_instance_id and self.temp_instance_id ~= 0 then
  325. main_role:DoFlyShoeEffect(nil, 2, nil, true)
  326. end
  327. --end
  328. end
  329. self.fly_shoe__delay_event_id = nil
  330. end
  331. local do_fly = true --静默重连,不需要飞行
  332. if UserMsgAdapter and UserMsgAdapter.Instance:GetIsAutoConnecting( ) then
  333. do_fly = false
  334. end
  335. if do_fly then
  336. self.fly_shoe__delay_event_id = setTimeout(delay_method, 0.01)--不延迟一下的话不会飞,只会跳一下(偶发)
  337. end
  338. local function fly_end( )
  339. if is_no_loading_scene and error_code == 1 then
  340. --ChangeSceneMovie:getInstance():TryOpen()
  341. end
  342. self:ChangeScene(self.temp_instance_id,pos_x,pos_y,dun_id, error_code)
  343. self.fly_shoe_event_id = nil
  344. end
  345. local time = (send_type == 3 or send_type == 4) and Config.otherFightInfo.jump_action_time["transferout"] or Config.otherFightInfo.jump_action_time["flyup"]
  346. if not self.has_enter_game then
  347. self.has_enter_game = true
  348. time = 0.01
  349. end
  350. self.fly_shoe_event_id = setTimeout(fly_end, time)
  351. if AutoFightManager:getInstance().next_fly_pos then
  352. AutoFightManager:getInstance().next_fly_pos.x = pos_x
  353. AutoFightManager:getInstance().next_fly_pos.y = pos_y
  354. end
  355. if SceneManager.Instance:IsOneTowerDungeon(dun_id) then--爬塔副本连续挑战需要保存副本ID
  356. SceneManager.Instance:SetCurrDunId(dun_id)
  357. end
  358. else
  359. if is_no_loading_scene and error_code == 1 then
  360. --ChangeSceneMovie:getInstance():TryOpen()
  361. end
  362. AutoFightManager:getInstance().next_fly_pos = nil
  363. self:ChangeScene(self.temp_instance_id,pos_x,pos_y,dun_id, error_code)
  364. end
  365. end
  366. function SceneController:ChangeScene(instance_id,pos_x,pos_y,dun_id, error_code)
  367. -- print("tanar: [SceneController 404]=> instance_id: ",instance_id)
  368. -- print("tanar: [SceneController 405]=> SceneManager.Instance.last_scene_id: ",SceneManager.Instance.last_scene_id)
  369. if instance_id ~= 0 then
  370. self.cache_move_error_type = {}
  371. local main_role_vo = RoleManager.Instance.mainRoleInfo
  372. main_role_vo.pos_x = pos_x
  373. main_role_vo.pos_y = pos_y
  374. OperateManager.Instance:StopMove(true) --, 先清掉当前场景的操作包,避免继续移动寻路
  375. local last_id = SceneManager.Instance:GetSceneId()
  376. SceneManager.Instance:SetCurrentSceneId(instance_id)
  377. SceneManager.Instance:SetCurrDunId(dun_id)
  378. if self.change_scene_event_id then
  379. GlobalTimerQuest:CancelQuest(self.change_scene_event_id)
  380. self.change_scene_event_id = nil
  381. end
  382. GlobalEventSystem:Fire(SceneEventType.OPEN_SCENE_LOAD_VIEW)
  383. SceneManager.Instance:ClearAllVo() --必须要先移除vo再移除场景对象元素 派发dispose方法来移除所有针对场景元素的引用
  384. if SceneManager.Instance.last_scene_id ~= instance_id then
  385. local delay_fun = function ()
  386. self.scene:ClearScene()
  387. self.scene:SceneLoadingEnter(instance_id) --预加载,申请12002切换场景
  388. self.scene:CreateMainRole()
  389. self.scene:ChangeMainRoleScale()
  390. -- if AutoFightManager:getInstance().next_fly_pos
  391. -- or self.scene_mgr:IsDungeonScene(instance_id)
  392. -- or self.scene_mgr:IsDungeonScene(self.scene_mgr:GetLastSceneId())then
  393. -- if self.scene.main_role then
  394. -- self.scene.main_role:SetModelHideFlag(SceneObj.ModelHideFlag.Fly, true)
  395. -- end
  396. -- end
  397. GlobalEventSystem:Fire(SceneEventType.SCENE_CHANGED, instance_id)
  398. end
  399. self.change_scene_event_id = setTimeout(delay_fun, 0.001)
  400. else
  401. local delay_fun = function ()
  402. --同场景传送时不用清传送门和NPC
  403. self.scene:ClearScene(false)
  404. self.scene:SceneLoadingEnter(instance_id)
  405. self.scene:CreateMainRole()
  406. end
  407. self.change_scene_event_id = setTimeout(delay_fun, 0.001)
  408. GlobalEventSystem:Fire(SceneEventType.SCENE_REENTER, instance_id)
  409. end
  410. else
  411. if instance_id == 0 then
  412. GlobalEventSystem:Fire(EventName.PLAY_MAINUI_MOVIE_CENTER_EVENT)
  413. ErrorCodeShow(error_code)
  414. if error_code == 1200011 then
  415. AutoFightManager:getInstance():FindVoCallTypeFun(call_back_type)
  416. end
  417. else
  418. Message.show(error_str,"场景配置不存在")
  419. end
  420. end
  421. end
  422. --服务器通知清除场景对象
  423. function SceneController:handler12006()
  424. local self = SceneController.Instance
  425. --竞技场不通过服务器清除场景对象
  426. if SceneManager.Instance:IsPkRankFightScene() then return end
  427. local instance_id = self:ReadFmt("i")
  428. local vo = SceneManager.Instance:DeleteMonsterVo(instance_id)
  429. if vo == nil then
  430. vo = SceneManager.Instance:DeletePartnerVo(instance_id)
  431. if vo == nil then
  432. vo = SceneManager.Instance:DeleteOtherVo(instance_id)
  433. if vo == nil then
  434. vo = SceneManager.Instance:DeleteRoleVo(instance_id)
  435. end
  436. end
  437. end
  438. end
  439. --服务器通知怪物出现
  440. function SceneController:handler12007()
  441. local self = SceneController.Instance
  442. local monster_vo = SceneManager.Instance:CreateMonsterVo()
  443. monster_vo:ReadFromProtocal()
  444. local need_delay = true
  445. if monster_vo.hide_flag == 1 then
  446. need_delay = false
  447. end
  448. SceneManager.Instance:AddMonsterVo(monster_vo, need_delay)
  449. end
  450. --服务器通知场景对象移动
  451. function SceneController:handler12008()
  452. local self = SceneController.Instance
  453. local pos_x, pos_y, instance_id = self:ReadFmt("hhi")
  454. local vo = SceneManager.Instance:GetSceneObjVo(instance_id)
  455. if vo then
  456. if self.scene:IsSceneLoaded() then
  457. if vo.vo_type == SceneBaseType.Monster then
  458. self.scene:MonsterMove(instance_id, pos_x, pos_y)
  459. if RoleManager.Instance:GetMainRoleVo():GetFlagsByKey(RoleVo.Act_Flag.CONVOY) > 0 and EscortModel:getInstance():IsFollowEscortCar()
  460. and EscortModel:getInstance():IsMyEscortCar(instance_id) then
  461. local temp_x,temp_y = EscortModel:GetInstance():GetTempPos()
  462. EscortModel:GetInstance():SetTempPos(pos_x,pos_y)
  463. if temp_x and temp_y then
  464. Scene.Instance.main_role:DoMove(Vector2(temp_x,temp_y))
  465. end
  466. end
  467. elseif vo.vo_type == SceneBaseType.Partner then
  468. self.scene:PartnerMove(instance_id, pos_x, pos_y)
  469. elseif vo.vo_type == SceneBaseType.Other then
  470. self.scene:OtherMove(instance_id, pos_x, pos_y)
  471. elseif vo.vo_type == SceneBaseType.Role then
  472. self.scene:RoleMove(instance_id, pos_x, pos_y)
  473. end
  474. end
  475. else
  476. local delay_mon_vo = SceneManager.Instance:GetDelayMonsterVo(instance_id)
  477. if delay_mon_vo then
  478. delay_mon_vo.pos_x = pos_x
  479. delay_mon_vo.pos_y = pos_y
  480. end
  481. end
  482. end
  483. --角色血量变化
  484. function SceneController:handler12009( )
  485. local self = SceneController.Instance
  486. local obj_id, hp, maxHp = self:ReadFmt("lll")
  487. local objVo = SceneManager.Instance:GetSceneObjVo(obj_id)
  488. if objVo then
  489. GlobalEventSystem:Fire(EventName.EXECUTE_DELEY_FIGHT_INFO)
  490. local delta = hp - objVo.hp
  491. objVo:ChangeVar("maxHp", maxHp, nil, true)
  492. objVo:ChangeVar("hp", hp, nil, true)
  493. local obj = self.scene:GetSceneObj(obj_id)
  494. if obj then
  495. GlobalEventSystem:Fire(EventName.HP_CHANGE_FROM_SCENE, obj,delta )
  496. if hp == 0 then
  497. local obj = self.scene:GetSceneObj(obj_id)
  498. obj:DoDead()
  499. end
  500. end
  501. else
  502. print("warning! can not find a obj to handle move response!")
  503. --没找到对象,先记录血量,等怪创建之后再赋值
  504. local change_data = {
  505. hp = hp,
  506. maxHp = maxHp,
  507. }
  508. SceneManager.Instance:RecordPreMonsterData(obj_id,change_data)
  509. end
  510. end
  511. --场景角色属性更改
  512. function SceneController:handler12010()
  513. local self = SceneController.Instance
  514. local role_id, len = self:ReadFmt("lh")
  515. local list = {}
  516. for i = 1, len do
  517. local obj = {}
  518. obj.style = self:ReadFmt("c")
  519. obj.value = self:ReadFmt("s")
  520. table.insert(list, obj)
  521. end
  522. Scene.Instance:RoleOtherProChange(role_id, list)
  523. end
  524. --服务器通知九宫格加载销毁角色对象
  525. function SceneController:handler12011()
  526. local self = SceneController.Instance
  527. local add_num = self:ReadFmt("h")
  528. for i = 1,add_num do
  529. self:handler12003()
  530. end
  531. local remove_num = self:ReadFmt("h")
  532. for i = 1,remove_num do
  533. local role_id = self:ReadFmt("l")
  534. SceneManager.Instance:DeleteRoleVo(role_id)
  535. end
  536. end
  537. --服务器通知九宫格加载销毁非角色场景对象
  538. function SceneController:handler12012()
  539. local self = SceneController.Instance
  540. local add_num = self:ReadFmt("h")
  541. for i = 1, add_num do
  542. self:handler12007()
  543. end
  544. add_num = self:ReadFmt("h")
  545. for i = 1, add_num do
  546. self:handler12014()
  547. end
  548. add_num = self:ReadFmt("h")
  549. for i = 1, add_num do
  550. self:handler12015()
  551. end
  552. local remove_num = self:ReadFmt("h")
  553. for i = 1, remove_num do
  554. self:handler12006()
  555. end
  556. --触发判断屏幕场景对象数量限制显示
  557. GlobalEventSystem:Fire(SceneEventType.UPDATE_ROLE_LIMIT)
  558. end
  559. --广播玩家进入飘窗提示
  560. function SceneController:handler12013()
  561. local self = SceneController.Instance
  562. --预生成table字段
  563. local role_vo = {
  564. role_id = 0,
  565. name = "",
  566. sex = 1,
  567. career = 1,
  568. turn = 0,
  569. vip_type = 0,
  570. vip_flag = 0,
  571. level = 0,
  572. fighting = 0,
  573. picture = "",
  574. picture_ver = 0,
  575. profile_photo_id = 0,
  576. dress_id = 0,
  577. sup_vip_type = 0,
  578. }
  579. PictureProtoVo.ReadFmt(role_vo)
  580. local scene_info = SceneManager.Instance:GetSceneInfo(SceneManager.Instance:GetSceneId()) --获取场景信息
  581. local scene_name = scene_info and scene_info.name or "场景"
  582. local data = {
  583. role_vo_1 = role_vo, --我方
  584. role_vo_2 = nil, --敌方
  585. type = 1, --UI类型
  586. is_break = 1, --击杀情况(类型2需要使用)
  587. desc = string.format("进入了%s", scene_name), --描述
  588. }
  589. if SceneManager:getInstance():IsWastelandPrepareScene() then -- 废土准备场景描述要改一下
  590. data.desc = "进入了备战区"
  591. end
  592. if SceneManager:getInstance():IsShowDynamicInfoScene() then
  593. GlobalEventSystem:Fire(EventName.SHOW_DYNAMIC_INFO_TIP, data)
  594. end
  595. --造一个假的入场传闻
  596. if SceneManager.Instance:IsBeachScene() then
  597. local data = {
  598. module_id = 418,
  599. id = 7,
  600. content = role_vo.name .. "," .. role_vo.role_id
  601. }
  602. GlobalEventSystem:Fire(EventName.RECEIVE_NEW_CHUANWEN, data, 11015)--传闻
  603. end
  604. end
  605. --服务器通知普通场景对象进入
  606. function SceneController:handler12014()
  607. local other_vo = OtherVo.New()
  608. other_vo:ReadFromProtocal()
  609. SceneManager.Instance:AddOtherVo(other_vo)
  610. end
  611. --服务器通知假人进入
  612. function SceneController:handler12015()
  613. local role_vo = RoleVo.New()
  614. role_vo:ReadFakeProtacal()
  615. --校正假人坐标,避免创建出来掉到沟里
  616. local main_role = Scene.Instance.main_role
  617. if main_role and main_role.vo then
  618. local main_height = Scene.Instance:GetZoneHeight(main_role.vo.pos_x/SceneObj.LogicRealRatio.x, main_role.vo.pos_y/SceneObj.LogicRealRatio.y)
  619. local temp_height = Scene.Instance:GetZoneHeight(role_vo.pos_x/SceneObj.LogicRealRatio.x, role_vo.pos_y/SceneObj.LogicRealRatio.y)
  620. if temp_height - main_height > 10 or temp_height - main_height < -10 then
  621. role_vo.pos_x = main_role.vo.pos_x
  622. role_vo.pos_y = main_role.vo.pos_y
  623. end
  624. end
  625. SceneManager.Instance:AddDelayRoleTable(role_vo) --延迟加载
  626. if SceneManager.Instance:IsGodDungeon() then--如果是唤神副本,假人加载必须立刻刷新,不能使用栈模式先来后出的延迟加载,不然会导致旧数据覆盖新数据
  627. SceneManager.Instance:ImmeAddRoleVo(role_vo.role_id)
  628. end
  629. end
  630. --通用状态变更通知
  631. function SceneController:handler12016( )
  632. local module_id, module_sub_id, role_id, value = self:ReadFmt("iils")
  633. print("HWR:SceneController [686]: ",module_id, module_sub_id, role_id, value)
  634. if module_id == 146 then
  635. if module_sub_id == 14609 then
  636. role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
  637. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  638. if not role_vo then return end
  639. role_vo:ChangeVar("is_ride",tonumber(value))
  640. elseif module_sub_id >= 2000 + FosterConst.ModuleId.FJarvis and module_sub_id <= 2000 + FosterConst.ModuleId.FArmour then
  641. role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
  642. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  643. if not role_vo then return end
  644. local type_id = tonumber(module_sub_id) - 2000
  645. local skin_id = stringtotable(value)[1]
  646. local star = stringtotable(value)[2] or 0
  647. -- if type_id == FosterConst.ModuleId.FJarvis then
  648. -- role_vo:ChangeVar("pet_id",skin_id)
  649. -- elseif type_id == FosterConst.ModuleId.FGun then
  650. -- role_vo:ChangeVar("pet_weapon_id",skin_id)
  651. -- elseif type_id == FosterConst.ModuleId.FCloud then
  652. -- role_vo:ChangeVar("pet_wing_id",skin_id)
  653. -- elseif type_id == FosterConst.ModuleId.FArmour then
  654. -- role_vo:ChangeVar("pet_farmour",skin_id)
  655. -- end
  656. --调整皮肤的列表数据
  657. if FosterController.Instance then
  658. local temp_data = {type_id = type_id, skin_id = skin_id, star = star}
  659. FosterController.Instance:ChangeRoleForsterSunSkinInfo(temp_data,role_id)
  660. end
  661. elseif FosterController.Instance then
  662. local temp_data = {type = module_sub_id,display = module_sub_id > 1000 and stringtotable(value) or tonumber(value)}
  663. FosterController.Instance:ChangeRoleForsterInfo(temp_data,role_id, module_sub_id < 1000)
  664. end
  665. elseif module_id == 147 then
  666. if module_sub_id == 1 then
  667. role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
  668. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  669. if not role_vo then return end
  670. role_vo:ChangeVar("light_id",tonumber(value))
  671. end
  672. -- elseif module_id == 139 then -- 圣物系统
  673. -- if module_sub_id == 0 then -- 圣物头衔等级
  674. -- role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
  675. -- local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  676. -- if not role_vo then return end
  677. -- role_vo:ChangeVar("ps_lv", tonumber(value))
  678. -- end
  679. elseif module_id == 603 then -- 跨服主功能
  680. if module_sub_id == 0 then -- 军衔等级
  681. role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
  682. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  683. if not role_vo then return end
  684. role_vo:ChangeVar("military_ranks", tonumber(value))
  685. end
  686. elseif module_id == 460 and module_sub_id == 1 then -- 赏金幻魔
  687. role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
  688. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  689. if not role_vo then return end
  690. role_vo:ChangeVar("money_boss_protect_time", tonumber(value))
  691. elseif module_id == 461 and module_sub_id == 1 then
  692. role_id = role_id or RoleManager.Instance.mainRoleInfo.role_id
  693. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  694. if not role_vo then return end
  695. role_vo:ChangeVar("deserted_boss_protect_time", tonumber(value))
  696. end
  697. end
  698. --隐身字段广播
  699. function SceneController:handler12070()
  700. local target_type, id, is_hide = self:ReadFmt("clc")
  701. local vo = nil
  702. if target_type == SceneBaseType.Monster then
  703. vo = SceneManager.Instance:GetMonsterVo(id)
  704. elseif target_type == SceneBaseType.Role or target_type == SceneBaseType.Fake_Role then
  705. vo = SceneManager.Instance:GetRoleVo(id)
  706. elseif target_type == SceneBaseType.Partner then
  707. vo = SceneManager.Instance:GetPartnerVo(id)
  708. end
  709. if vo then
  710. vo:ChangeVar("hide_flag", is_hide)
  711. end
  712. end
  713. --幽灵字段广播
  714. function SceneController:handler12071()
  715. local target_type, id, is_ghost = self:ReadFmt("clc")
  716. local vo = nil
  717. if target_type == SceneBaseType.Monster then
  718. vo = SceneManager.Instance:GetMonsterVo(id)
  719. elseif target_type == SceneBaseType.Role or target_type == SceneBaseType.Fake_Role then
  720. vo = SceneManager.Instance:GetRoleVo(id)
  721. elseif target_type == SceneBaseType.Partner then
  722. vo = SceneManager.Instance:GetPartnerVo(id)
  723. end
  724. if vo then
  725. vo:ChangeVar("ghost_mode", is_ghost)
  726. end
  727. end
  728. --分组字段广播
  729. function SceneController:handler12072()
  730. local target_type, id, warGroup = self:ReadFmt("cll")
  731. local vo = nil
  732. if target_type == SceneBaseType.Monster then
  733. vo = SceneManager.Instance:GetMonsterVo(id)
  734. elseif target_type == SceneBaseType.Role or target_type == SceneBaseType.Fake_Role then
  735. vo = SceneManager.Instance:GetRoleVo(id)
  736. elseif target_type == SceneBaseType.Partner then
  737. vo = SceneManager.Instance:GetPartnerVo(id)
  738. end
  739. if vo then
  740. vo:ChangeVar("warGroup", warGroup)
  741. end
  742. end
  743. --嘲讽buff追踪对象
  744. function SceneController:handler12073()
  745. local target_type, target_id = self:ReadFmt("cl")
  746. SceneManager.Instance.chaofeng_attacker_compress_id = Scene.CompressObjId(target_type, target_id)
  747. end
  748. --展示状态广播
  749. function SceneController:handler12075()
  750. local target_type, id, state_type = self:ReadFmt("clc")
  751. -- print("Saber:SceneController [660] target_type, id, state_type: ",target_type, id, state_type)
  752. local vo = nil
  753. if target_type == SceneBaseType.Monster then
  754. vo = SceneManager.Instance:GetMonsterVo(id)
  755. elseif target_type == SceneBaseType.Role or target_type == SceneBaseType.Fake_Role then
  756. vo = SceneManager.Instance:GetRoleVo(id)
  757. elseif target_type == SceneBaseType.Partner then
  758. vo = SceneManager.Instance:GetPartnerVo(id)
  759. end
  760. if vo then
  761. -- vo:ChangeVar("state_type", state_type)
  762. vo:ChangeVar("dance_status", state_type)
  763. if id == RoleManager.Instance:GetMainRoleId() then
  764. GlobalEventSystem:Fire(EventName.MAIN_ROLE_DANCE_STATUS_CHANGE,tonumber(state_type))
  765. end
  766. end
  767. end
  768. --配对对象广播
  769. function SceneController:handler12076()
  770. local role_id,date_role_id = self:ReadFmt("ll")
  771. local vo = SceneManager.Instance:GetRoleVo(role_id)
  772. if vo then
  773. vo:ChangeVar("date_role_id", date_role_id)
  774. else
  775. print("====can't find vo,role_id:",role_id)
  776. end
  777. end
  778. --玩家figure字段更新
  779. function SceneController:handler12078()
  780. local role_id = self:ReadFmt("l")
  781. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  782. local role = Scene.Instance:GetRole(role_id)
  783. if role and role_vo then
  784. FigureProtoVo.ReadFmt(role_vo)
  785. if role_id == RoleManager.Instance:GetMainRoleId() then
  786. role_vo:ChangeFromVo(role_vo)
  787. GlobalEventSystem:Fire(EventName.MAINROLEHEAD_DATA_CHANGE, role_id)
  788. else
  789. role:InitRoleVo(role_vo)
  790. role:LoadInfoFromVo()
  791. end
  792. end
  793. end
  794. --场景对象非常用属性更改
  795. function SceneController:handler12080()
  796. local instance_id = self:ReadFmt("i")
  797. local vo, obj_type = SceneManager.Instance:GetSceneObjVo(instance_id)
  798. if vo then
  799. local len = self:ReadFmt("h")
  800. local type, value
  801. for i = 1, len do
  802. type, value = self:ReadFmt("cl")
  803. if type == 1 then
  804. vo.pick_time = value
  805. elseif type == 2 then
  806. vo.owner_team_id = value
  807. elseif type == 3 then
  808. vo:ChangeVar("can_attack", value, nil, true)
  809. elseif type == 4 then
  810. vo:ChangeVar("can_pick", value, nil, true)
  811. elseif type == 5 then
  812. --怪物回血要做表现
  813. local add_hp = value - vo.hp
  814. if add_hp > 0 then
  815. if obj_type and obj_type == SceneBaseType.Monster then
  816. local target = Scene.Instance:GetMonster(vo.instance_id)
  817. if target then
  818. FightDamageDisplayer:getInstance():ShowAddHp(add_hp, target)
  819. end
  820. end
  821. end
  822. vo:ChangeVar("hp", value, nil, true)
  823. elseif type == 6 then --PK保护结束时间搓
  824. vo:ChangeVar("protect_time", value, nil, true)
  825. elseif type == 7 then
  826. vo:ChangeVar("level", value, nil, true)
  827. end
  828. end
  829. else
  830. --没找到对象,先把改变的等级记录一下
  831. local len = self:ReadFmt("h")
  832. local type, value
  833. for i = 1, len do
  834. type, value = self:ReadFmt("cl")
  835. if type == 7 then
  836. local change_data = {
  837. level = value,
  838. }
  839. SceneManager.Instance:RecordPreMonsterData(instance_id,change_data)
  840. end
  841. end
  842. end
  843. end
  844. --场景对象血量变化
  845. function SceneController:handler12081()
  846. local id, hp = self:ReadFmt("il")
  847. local target = Scene.Instance:GetSceneObj(id)
  848. if target ~= nil then
  849. local old_hp = target.vo.hp
  850. target.vo:ChangeVar("hp", hp, true)
  851. if hp == 0 then
  852. target:ForceDoDead()
  853. end
  854. local delta = hp - old_hp
  855. if delta > 0 then
  856. GlobalEventSystem:Fire(EventName.HP_CHANGE_FROM_SCENE, target, delta)
  857. end
  858. end
  859. end
  860. -- 人物速度改变
  861. function SceneController:handler12082( )
  862. local target_type, id, speed = self:ReadFmt("clh")
  863. if target_type == SceneBaseType.Monster then
  864. local vo = SceneManager.Instance:GetMonsterVo(id)
  865. if vo then
  866. vo:ChangeVar("move_speed",speed)
  867. end
  868. elseif target_type == SceneBaseType.Role or target_type == SceneBaseType.Fake_Role then
  869. local vo = SceneManager.Instance:GetRoleVo(id)
  870. if vo then
  871. vo:ChangeVar("move_speed",speed)
  872. end
  873. elseif target_type == SceneBaseType.Partner then
  874. local vo = SceneManager.Instance:GetPartnerVo(id)
  875. if vo then
  876. vo:ChangeVar("move_speed",speed)
  877. end
  878. end
  879. end
  880. --复活切换场景
  881. function SceneController:handler12083( )
  882. local rType, rsid, rx, ry, rsname, rhp, ryb, ybyb, yptime = self:ReadFmt("cihhsliih")
  883. if rType ~= 0 then
  884. RoleManager.Instance.mainRoleInfo:ChangeVar("pos_x",rx)
  885. RoleManager.Instance.mainRoleInfo:ChangeVar("pos_y",ry)
  886. end
  887. RoleManager.Instance.mainRoleInfo:ChangeVar("hp",rhp)
  888. RoleManager.Instance.mainRoleInfo:ChangeVar("jin",ryb)
  889. RoleManager.Instance.mainRoleInfo:ChangeVar("jinLock",ybyb)
  890. print("handler12083 rType, rx, ry, rsid, osid = " ,rType, rx, ry, rsid, SceneManager.Instance:GetSceneId())
  891. local main_role = self.scene:GetMainRole()
  892. if rType == 0 then --切场景会发12083,位置是新场景的坐标
  893. elseif rType == 1 then
  894. if main_role then
  895. main_role:SetRealPos(rx,ry)
  896. local function revive_callback()
  897. main_role:Revived()
  898. end
  899. main_role:DoRevive(revive_callback)
  900. end
  901. elseif rType == 2 then
  902. self:ReIntoScene(rsid, rsname, rx, ry)
  903. end
  904. if main_role then
  905. main_role:DeilyClearTrailRenderer()
  906. main_role:SetGhostMode(false)
  907. end
  908. GlobalEventSystem:Fire(EventName.RELIVE_COMPLETE)
  909. GlobalEventSystem:Fire(EventName.CLOSERELIVEWINDOW)
  910. GlobalEventSystem:Fire(EventName.REQUEST_RELIVE_TIMES)
  911. end
  912. --攻速改变
  913. function SceneController:handler12084()
  914. local target_type, id, speed = self:ReadFmt("clh")
  915. if target_type == SceneBaseType.Monster then
  916. local vo = SceneManager.Instance:GetMonsterVo(id)
  917. if vo then
  918. vo:ChangeVar("att_speed",speed)
  919. end
  920. elseif target_type == SceneBaseType.Role or target_type == SceneBaseType.Fake_Role then
  921. local vo = SceneManager.Instance:GetRoleVo(id)
  922. if vo then
  923. vo:ChangeVar("att_speed",speed)
  924. end
  925. elseif target_type == SceneBaseType.Partner then
  926. local vo = SceneManager.Instance:GetPartnerVo(id)
  927. if vo then
  928. vo:ChangeVar("att_speed",speed)
  929. end
  930. end
  931. end
  932. --玩家区域改变
  933. function SceneController:handler12085()
  934. local role_id, safe_area_state = self:ReadFmt("lc")
  935. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  936. if role_vo then
  937. role_vo:ChangeVar("safe_area_state", safe_area_state, nil, true)
  938. end
  939. end
  940. --玩家名字改变
  941. function SceneController:handler12086()
  942. local role_id, role_name = self:ReadFmt("ls")
  943. local role_vo = SceneManager.Instance:GetRoleVo(role_id)
  944. if role_vo then
  945. role_vo:ChangeVar("name", role_name)
  946. end
  947. end
  948. --重新进入场景
  949. function SceneController:ReIntoScene( rsid, rsname, pos_x, pos_y )
  950. local old_scene = SceneManager.Instance:GetSceneId()
  951. SceneManager.Instance:SetCurrentSceneId(rsid)
  952. SceneManager.Instance:ClearAllVo()
  953. if rsid ~= old_scene then
  954. GlobalEventSystem:Fire(SceneEventType.OPEN_SCENE_LOAD_VIEW)
  955. self.scene:ClearScene()
  956. SceneManager.Instance:SceneStart()
  957. self.scene:SceneLoadingEnter(rsid)
  958. self.scene:CreateMainRole()
  959. GlobalEventSystem:Fire(SceneEventType.SCENE_CHANGED, rsid)
  960. else
  961. if self.scene:GetMainRole() then
  962. --要调用一次这个,让主角位置移过去,并且设置高度
  963. self.scene:GetMainRole():SetGhostMode(false)
  964. self.scene:GetMainRole():SetRealPos(pos_x,pos_y)
  965. self.scene:GetMainRole():Revived()
  966. local function revive_callback( )
  967. self.scene:GetMainRole():Revived()
  968. self.scene:GetMainRole():LoadInfoFromVo()
  969. end
  970. self.scene:GetMainRole():DoRevive(revive_callback)
  971. end
  972. self:LoadSceneInfoRequest(rsid)
  973. end
  974. end
  975. --[[
  976. NPC列表
  977. ## NPC
  978. :12100
  979. c >> s:
  980. int:32 ID
  981. s >> c:
  982. array(
  983. int32 NPCID
  984. int:32 ID
  985. x:32 X坐标
  986. y:32 Y坐标
  987. )
  988. ]]
  989. function SceneController:handler12100( ... )
  990. local scmd = SCMD12100.New(true)
  991. local list = {}
  992. for k,v in pairs(scmd.npc_list) do
  993. list[v.npc_id] = v
  994. end
  995. SceneManager.Instance:SetNpcList(list)
  996. --申请12002切换场景
  997. -- local send_times = 0
  998. -- local function timeout_func()
  999. -- send_times = send_times + 1
  1000. -- if send_times <= 4 and not LoginModel.Instance.is_back_from_game then
  1001. self:SendFmtToGame(12002, "")
  1002. -- self:AddSendFmtCheckout(12002, 3, timeout_func)
  1003. -- end
  1004. -- end
  1005. -- timeout_func()
  1006. end
  1007. --[[
  1008. NPC状态变更
  1009. ## NPC状态
  1010. :12103
  1011. c >> s:
  1012. s >> c:
  1013. int32 NPCID
  1014. int8 0 1
  1015. int:32 ID
  1016. x:32 X坐标
  1017. y:32 Y坐标
  1018. ]]
  1019. function SceneController:handler12103( ... )
  1020. local scmd = SCMD12103.New(true)
  1021. if scmd.npc_list then
  1022. for i,v in ipairs(scmd.npc_list) do
  1023. if v.scene_id == SceneManager.getInstance():GetSceneId() then
  1024. if v.is_show == 0 then
  1025. SceneManager.Instance:DynamicDelNpc(v.npc_id)
  1026. else
  1027. SceneManager.Instance:DynamicAddNpc(v.npc_id, v.x, v.y, v.args)
  1028. end
  1029. end
  1030. end
  1031. end
  1032. end
  1033. --[[
  1034. : Npc显示图标更新反馈
  1035. : 12020
  1036. : s
  1037. :
  1038. :
  1039. : deadline
  1040. ]]
  1041. function SceneController:handler12020( )
  1042. local npc_num = self:ReadFmt("h")
  1043. for i=1,npc_num do
  1044. local npc_ins_id, task_flag = self:ReadFmt("ic")
  1045. local npcvo = SceneManager.Instance:GetNpcVo(npc_ins_id)
  1046. if npcvo then
  1047. npcvo:ChangeVar("task_icon",tonumber(task_flag))
  1048. end
  1049. end
  1050. end
  1051. --怪物说话ai
  1052. function SceneController:handler12023( )
  1053. local monster_id = self:ReadFmt("i")
  1054. local content = self:ReadFmt("s")
  1055. local monster = Scene.Instance:GetMonster(monster_id)
  1056. if monster then
  1057. monster:CreateTalkBoard(1, content, 200, 5)
  1058. end
  1059. end
  1060. -- 玩家动作播放
  1061. function SceneController:handler12025( )
  1062. local result, action = self:ReadFmt("ic")
  1063. -- print("Saber:SceneController [1125] result, action: ",result, action)
  1064. if result == 1 then -- 动作 0取消 1社团祝火
  1065. GuildModel:getInstance()._waiting_12025_respon = false -- 是否等待12025玩家状态协议返回状态
  1066. GlobalEventSystem:Fire(EventName.MAIN_ROLE_DANCE_STATUS_CHANGE,action)
  1067. RoleManager.Instance.mainRoleInfo:ChangeVar("dance_status", action)
  1068. else
  1069. ErrorCodeShow(result)
  1070. end
  1071. end
  1072. -- 对象死亡(一般是服务端能杀死无限血怪物,要走单独的清除逻辑)
  1073. function SceneController:handler12027( )
  1074. local self = SceneController.Instance
  1075. --竞技场不通过服务器清除场景对象
  1076. local instance_id = self:ReadFmt("i")
  1077. local monster = self.scene:GetMonster(instance_id)
  1078. if monster then
  1079. -- 播放死亡动作
  1080. monster:DoDead()
  1081. local function delay_method( )
  1082. self.scene_mgr:DeleteMonsterVo(instance_id)
  1083. end
  1084. -- 延迟销毁
  1085. setTimeout(delay_method, 5)
  1086. end
  1087. end
  1088. --注册场景事件
  1089. function SceneController:RegisterAllEvents()
  1090. local gameStartHandler = function ()
  1091. SceneController.Instance.is_game_started = true
  1092. if LoginModel.Instance.reconnect_on_game == nil or LoginModel.Instance.reconnect_on_game == false then
  1093. --SceneManager:getInstance():GameStartClearCache()
  1094. else
  1095. Message.show("重连成功")
  1096. if LoginModel.Instance then
  1097. LoginModel.Instance.reconnect_on_game = false
  1098. end
  1099. GlobalEventSystem:Fire(EventName.HIDE_LOADING_VIEW)
  1100. end
  1101. SceneManager:getInstance():GameStartClearCache()
  1102. -- 登录时候由服务端主推,不要主动请求了,服务端说会覆盖坐标-20210112
  1103. -- local vo = RoleManager.Instance.mainRoleInfo
  1104. -- self:SendFmtToGame(12005, "iicchh", vo.dun_id, vo.lastSceneId, 0, 0, 0, 0)
  1105. if ClientConfig.is_simulator then
  1106. InitSimulatorSetting()
  1107. end
  1108. end
  1109. local function onSceneStart()
  1110. -- 切换场景寻路
  1111. Scene.Instance:FindContinue()
  1112. self:SendFmtToGame("12020")
  1113. end
  1114. --场景寻路
  1115. local path_find = function(findVo)
  1116. --寻路要先切换掉自动挂机状态
  1117. GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT, false, true)
  1118. Scene.Instance:FindElement(findVo)
  1119. end
  1120. local function onRequestChangeScene(scene_id, call_back_type, send_type, pos_x, pos_y,force_show_action)
  1121. local data = {
  1122. scene_id = scene_id,
  1123. call_back_type = call_back_type,
  1124. send_type = send_type,
  1125. x = pos_x,
  1126. y = pos_y,
  1127. force_show_action = force_show_action,
  1128. }
  1129. self:ClientRequestChangeScene(12005, data)
  1130. end
  1131. local moveRequestHandler = function(x, y, flag, args_1, args_2,args_3, args_4)
  1132. if not self.scene or not self.scene:GetMainRole() then return end
  1133. local rx,ry = self.scene:GetMainRole():GetRealPos()
  1134. x = x < 0 and 0 or math.floor(x)
  1135. y = y < 0 and 0 or math.floor(y)
  1136. rx = rx < 0 and 0 or math.floor(rx)
  1137. ry = ry < 0 and 0 or math.floor(ry)
  1138. args_1 = args_1 or 0
  1139. args_2 = args_2 or 0
  1140. args_3 = args_3 or 0
  1141. args_4 = args_4 or 0
  1142. if flag then
  1143. flag = flag < 0 and 0 or math.floor(flag)
  1144. else
  1145. flag = 0
  1146. end
  1147. --以前的做法是把当前的real_pos当做目标坐标,现在改为非走路类型都靠传参决定
  1148. if flag ~= 0 then
  1149. rx, ry = x, y
  1150. end
  1151. local scene_id = SceneManager.Instance:GetSceneId()
  1152. if scene_id then
  1153. scene_id = scene_id < 0 and 0 or math.floor(scene_id)
  1154. else
  1155. scene_id = 0
  1156. end
  1157. -- if flag == 4 then
  1158. -- print(">>>>>>>> 12001 >>>> ", flag, args_1, args_2, args_3, args_4)
  1159. -- end
  1160. -- if flag == 0 then
  1161. -- print("tanar: [SceneController 1101]=> rx, ry: ",rx, ry)
  1162. -- end
  1163. --相同位置不发送协议
  1164. self.last_send_pos = self.last_send_pos or {}
  1165. if self.last_send_pos.scene_id == scene_id and
  1166. self.last_send_pos.rx == rx and
  1167. self.last_send_pos.ry == ry and
  1168. self.last_send_pos.flag == flag then
  1169. return
  1170. end
  1171. self.last_send_pos = { scene_id = scene_id, rx = rx, ry = ry, flag = flag}
  1172. self:SendFmtToGame(12001, "ihhchhhh", scene_id, rx, ry, flag, args_1, args_2, args_3, args_4)
  1173. end
  1174. local function onSafeAreaChange(state)
  1175. self:SendFmtToGame(12085, "c", state)
  1176. end
  1177. local function onOutOfStuck()
  1178. self:OutOfStuck()
  1179. end
  1180. local function onFlyShoe( scene_id, x, y )
  1181. local main_role = Scene.Instance:GetMainRole()
  1182. -- if main_role:IsInState(PoseState.JUMP) then
  1183. -- Message.show("跳跃中无法使用小飞鞋")
  1184. -- else
  1185. GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT,false,true)
  1186. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  1187. -- 移动距离近,正常寻路
  1188. local cur_scene_id = SceneManager.Instance:GetSceneId()
  1189. if scene_id == cur_scene_id then
  1190. local pos = co.Vector2(x,y)
  1191. local main_role = Scene.Instance:GetMainRole()
  1192. local distance = GameMath.GetDistance(pos.x, pos.y, main_role.real_pos.x, main_role.real_pos.y, true)
  1193. print('Ych:SceneController.lua[1326] distance', distance)
  1194. local start_height = Scene.Instance:GetZoneHeight(main_role.real_pos.x / SceneObj.LogicRealRatio.x,main_role.real_pos.y / SceneObj.LogicRealRatio.y) --起跳点的高度
  1195. local end_height = Scene.Instance:GetZoneHeight(pos.x / SceneObj.LogicRealRatio.x, pos.y / SceneObj.LogicRealRatio.y)
  1196. if distance > FLY_SHOE_DISTANCE.ThreeJumpDistance or (end_height - start_height) > 5 or (start_height - end_height ) > 5 then
  1197. --飞天落地需要消耗小飞鞋
  1198. else
  1199. local fly_data = AutoFightController.getInstance():GetFlyData()
  1200. if distance < FLY_SHOE_DISTANCE.NormalMoveDistance then
  1201. local findVo = FindVo.New()
  1202. findVo.type = FindVo.POINT
  1203. findVo.sceneId = scene_id
  1204. findVo.x = x / SceneObj.LogicRealRatio.x
  1205. findVo.y = y / SceneObj.LogicRealRatio.y
  1206. findVo.call_back = fly_data and fly_data.callback
  1207. GlobalEventSystem:Fire(EventName.FIND, findVo)
  1208. --如果数走路过去,才不需要消耗小飞鞋
  1209. return
  1210. else
  1211. --多段跳需要消耗小飞鞋
  1212. end
  1213. end
  1214. end
  1215. self:SendFmtToGame(12033, "i", scene_id)
  1216. -- end
  1217. end
  1218. GlobalEventSystem:Bind(SceneManager.START,onSceneStart)
  1219. GlobalEventSystem:Bind(EventName.GAME_START, gameStartHandler)
  1220. GlobalEventSystem:Bind(SceneEventType.REQUEST_CHANGE_SCENE, onRequestChangeScene)
  1221. GlobalEventSystem:Bind(EventName.FIND, path_find)
  1222. GlobalEventSystem:Bind(SceneEventType.MOVEREQUEST, moveRequestHandler)
  1223. GlobalEventSystem:Bind(SceneEventType.SAFE_AREA_CHANGE, onSafeAreaChange)
  1224. GlobalEventSystem:Bind(SceneEventType.OUT_OF_STUCK, onOutOfStuck)
  1225. GlobalEventSystem:Bind(SceneEventType.REQUEST_USE_FLY_SHOE, onFlyShoe)
  1226. local function onRequestSceneInfo()
  1227. self:LoadSceneInfoRequest()
  1228. end
  1229. GlobalEventSystem:Bind(SceneEventType.REQUEST_SCENE_INFO, onRequestSceneInfo)
  1230. local function request_dynamic()
  1231. self:SendFmtToGame(12030)
  1232. end
  1233. GlobalEventSystem:Bind(SceneEventType.REQUEST_DYNAMIC_ARER, request_dynamic)
  1234. local function request_effect()
  1235. self:SendFmtToGame(12032)
  1236. end
  1237. GlobalEventSystem:Bind(SceneEventType.REQUEST_DYNAMIC_EFFECT, request_effect)
  1238. local function request_pos(scene_id, line, x, y)
  1239. local data = {
  1240. scene_id = scene_id,
  1241. line = line,
  1242. x = x,
  1243. y = y,
  1244. }
  1245. self:ClientRequestChangeScene(12034, data)
  1246. end
  1247. GlobalEventSystem:Bind(SceneEventType.REQUEST_POS_LINK, request_pos)
  1248. local function scene_load_completed()
  1249. if not Scene.Instance:IsNpcLoadFinish() then
  1250. return
  1251. end
  1252. --通知服务器完成了场景切换
  1253. self:SendFmtToGame(12035)
  1254. GlobalEventSystem:Fire(SceneEventType.REQUEST_DYNAMIC_EFFECT)
  1255. end
  1256. GlobalEventSystem:Bind(EventName.NOTICE_SCENE_LOAD_WILL_COMPLETE, scene_load_completed)
  1257. local function deal_with_drop_list_vo(vo,is_fake)
  1258. self:DealWithDropListVo(vo,is_fake)
  1259. end
  1260. GlobalEventSystem:Bind(SceneEventType.DEAL_WITH_SCENE_DROP_LIST_VO, deal_with_drop_list_vo)
  1261. end
  1262. --超链接场景传送
  1263. function SceneController:handler12034( )
  1264. local error_code,x,y = self:ReadFmt("ihh")
  1265. if error_code ~= 1 then
  1266. ErrorCodeShow(error_code)
  1267. else
  1268. --寻路
  1269. local findVo = FindVo.New()
  1270. findVo.sceneId = SceneManager:getInstance():GetSceneId()
  1271. findVo.type = FindVo.POINT
  1272. findVo.x = x/SceneObj.LogicRealRatio.x
  1273. findVo.y = y/SceneObj.LogicRealRatio.y
  1274. GlobalEventSystem:Fire(EventName.FIND,findVo)
  1275. end
  1276. end
  1277. --怪物掉落
  1278. function SceneController:handler12017( )
  1279. local vo = {}
  1280. local len2
  1281. vo.mon_id,
  1282. vo.expire_time_stamp,
  1283. vo.map_id,
  1284. len2 = self:ReadFmt("iiih")
  1285. vo.drop_list = vo.drop_list or {}
  1286. local vo2 = nil
  1287. for i = 1,len2 do
  1288. vo2 = {
  1289. drop_id = self:ReadFmt("i"),
  1290. drop_type = self:ReadFmt("c"),
  1291. type_id = self:ReadFmt("i"),
  1292. drop_num = self:ReadFmt("i"),
  1293. role_id = self:ReadFmt("l"),
  1294. pos_x = self:ReadFmt("h"),
  1295. pos_y = self:ReadFmt("h"),
  1296. effect = self:ReadFmt("s"),
  1297. drop_icon = self:ReadFmt("s"),
  1298. expire_time_stamp = vo.expire_time_stamp,
  1299. map_id = vo.map_id,
  1300. }
  1301. table.insert(vo.drop_list,vo2)
  1302. end
  1303. vo.pos_x = self:ReadFmt("h")
  1304. vo.pos_y = self:ReadFmt("h")
  1305. vo.boss_type = self:ReadFmt("c")
  1306. if len2 > 0 then
  1307. GlobalEventSystem:Fire(SceneEventType.DEAL_WITH_SCENE_DROP_LIST_VO, vo)
  1308. end
  1309. end
  1310. --掉落消失
  1311. function SceneController:handler12019( )
  1312. local drop_id = self:ReadFmt("i") or 0
  1313. GlobalEventSystem:Fire(SceneEventType.DISMiSS_SCENE_DROP_ITEM, drop_id)
  1314. end
  1315. --玩家上线后能看到身边周围的怪物掉落
  1316. function SceneController:handler12018( )
  1317. local vo = {}
  1318. vo.drop_list = {}
  1319. local tb = nil
  1320. local map_id = SceneManager:getInstance():GetSceneId()
  1321. local len = self:ReadFmt("h")
  1322. for i = 1,len do
  1323. tb = {
  1324. drop_id = self:ReadFmt("i"),
  1325. drop_type = self:ReadFmt("c"),
  1326. type_id = self:ReadFmt("i"),
  1327. drop_num = self:ReadFmt("i"),
  1328. role_id = self:ReadFmt("l"),
  1329. pos_x = self:ReadFmt("h"),
  1330. pos_y = self:ReadFmt("h"),
  1331. effect = self:ReadFmt("s"),
  1332. drop_icon = self:ReadFmt("s"),
  1333. expire_time_stamp = self:ReadFmt("i"),
  1334. map_id = map_id,
  1335. }
  1336. tb.no_anim = true
  1337. table.insert(vo.drop_list,tb)
  1338. end
  1339. vo.map_id = SceneManager:getInstance():GetSceneId()
  1340. if len > 0 then
  1341. GlobalEventSystem:Fire(SceneEventType.DEAL_WITH_SCENE_DROP_LIST_VO, vo)
  1342. end
  1343. end
  1344. --攻防两方都飘字的角色血量变化
  1345. function SceneController:handler12024( )
  1346. local attacker_id, obj_id, hp, maxHp = self:ReadFmt("llll")
  1347. local objVo = SceneManager.Instance:GetSceneObjVo(obj_id)
  1348. if objVo then
  1349. GlobalEventSystem:Fire(EventName.EXECUTE_DELEY_FIGHT_INFO)
  1350. local delta = hp - objVo.hp
  1351. local obj = self.scene:GetSceneObj(obj_id)
  1352. local attacker = self.scene:GetSceneObj(attacker_id)
  1353. if obj and attacker then
  1354. GlobalEventSystem:Fire(EventName.HP_CHANGE_FROM_SCENE, obj,delta,attacker)
  1355. end
  1356. objVo:ChangeVar("hp", hp)
  1357. objVo:ChangeVar("maxHp", maxHp)
  1358. if hp == 0 then
  1359. local obj = self.scene:GetSceneObj(obj_id)
  1360. obj:DoDead()
  1361. end
  1362. else
  1363. print("warning! can not find a obj to handle move response!")
  1364. end
  1365. end
  1366. --改变动态区域属性
  1367. function SceneController:handler12030( )
  1368. local len = self:ReadFmt("h") or 0
  1369. for i=1,len do
  1370. local area_id, area_type = self:ReadFmt("cc")
  1371. if area_id and area_type then
  1372. local client_index = ServerAreaIndex[area_type]
  1373. if client_index then
  1374. Scene.Instance:SetDynamicArea(area_id,client_index)
  1375. end
  1376. end
  1377. end
  1378. end
  1379. --改变场景内特效
  1380. function SceneController:handler12032( )
  1381. local scene_id = self:ReadFmt("i")
  1382. if not scene_id or SceneManager:getInstance():GetSceneId() ~= scene_id then return end
  1383. local function onChangeState(vo)
  1384. if vo.type == 0 then
  1385. SapManager:getInstance():UnRegisterObj(SapManager.ObjType.Effect, vo.eff_id)
  1386. elseif vo.type == 1 then
  1387. local mapView = MapView.Instance
  1388. if mapView then
  1389. local scene_effect = Config.ConfigSceneEffect.EffectInfo[tonumber(mapView.curMapId)]
  1390. if not scene_effect then return end
  1391. local effect = scene_effect[vo.eff_id]
  1392. if not effect then return end
  1393. effect.id = vo.eff_id
  1394. local obj =
  1395. {
  1396. id = vo.eff_id,
  1397. type = SapManager.ObjType.Effect,
  1398. pos = co.TableXY(effect.x,effect.y),
  1399. size = co.TableXY(effect.bound.size_x + effect.bound.off_x,effect.bound.size_y+ effect.bound.off_y),
  1400. data = {id = vo.eff_id,obj = effect},
  1401. }
  1402. SapManager:getInstance():RegisterObj(obj)
  1403. end
  1404. end
  1405. end
  1406. local len = self:ReadFmt("h") or 0
  1407. local vo = nil
  1408. for i=1,len do
  1409. vo = {
  1410. eff_id = self:ReadFmt("h") or 0,
  1411. type = self:ReadFmt("c")
  1412. }
  1413. onChangeState(vo)
  1414. end
  1415. end
  1416. --使用小飞鞋结果返回
  1417. function SceneController:handler12033( )
  1418. local error_code = self:ReadFmt("i")
  1419. if error_code ~= 1 then
  1420. ErrorCodeShow(error_code)
  1421. else
  1422. GlobalEventSystem:Fire(SceneEventType.REQUEST_USE_FLY_SHOE_RETURN)
  1423. end
  1424. end
  1425. --boss的归属标识
  1426. function SceneController:handler12022( )
  1427. local player_id, boss_flag = self:ReadFmt("lc")
  1428. local list = Scene.Instance.role_list
  1429. if list then
  1430. for k,v in pairs(list) do
  1431. if player_id==v:GetVo().role_id then
  1432. v:GetVo():ChangeVar("boss_flag", boss_flag)
  1433. break
  1434. end
  1435. end
  1436. end
  1437. end
  1438. --改变玩家活动通用标识
  1439. function SceneController:handler12089()
  1440. local self = SceneController.Instance
  1441. local flag = {}
  1442. flag.role_id = self:ReadFmt("l")
  1443. local len = self:ReadFmt("h")
  1444. flag.activity_flags = {}
  1445. for i = 1, len do
  1446. local obj = {}
  1447. obj.key = self:ReadFmt("c")
  1448. obj.value = self:ReadFmt("l")
  1449. table.insert(flag.activity_flags, obj)
  1450. end
  1451. self.scene:FlagChange(flag.role_id, flag.activity_flags)
  1452. end
  1453. --改变玩家活动通用标识
  1454. function SceneController:handler12090()
  1455. local instance_id = self:ReadFmt("l")
  1456. local len = self:ReadFmt("h")
  1457. local type, value,str
  1458. local vo, obj_type = SceneManager.Instance:GetSceneObjVo(instance_id)
  1459. if vo then
  1460. for i = 1, len do
  1461. type, value ,str = self:ReadFmt("cls")
  1462. if type == 1 then
  1463. vo.name = str
  1464. vo:ChangeVar("name", str, nil, true)
  1465. end
  1466. end
  1467. else
  1468. for i = 1, len do
  1469. type, value ,str = self:ReadFmt("cls")
  1470. end
  1471. --没找到对象,先记录数据,等创建出来再用
  1472. local change_data = {
  1473. name = str,
  1474. }
  1475. SceneManager.Instance:RecordPreMonsterData(instance_id,change_data)
  1476. print("warning! can not find a obj to handle move response!")
  1477. end
  1478. end
  1479. --[[
  1480. %%
  1481. %%
  1482. -define(MOTION_ERR_OK, 0). % []
  1483. -define(MOTION_ERR_SCENE, 1). %
  1484. -define(MOTION_ERR_CD, 2). % CD时间
  1485. -define(MOTION_ERR_DIS, 3). %
  1486. ]]
  1487. function SceneController:handler12099( )
  1488. self.cache_move_error_type = self.cache_move_error_type or {}
  1489. local target_scene, real_scene, target_pos_x, target_pos_y, move_type, real_pos_x, real_pos_y, code = self:ReadFmt("iihhchhc")
  1490. if code and code >= 1 then
  1491. if self.cache_move_error_type[code] then
  1492. return
  1493. end
  1494. self.cache_move_error_type[code] = true
  1495. local real_is_block = false
  1496. if SceneManager:getInstance():IsBlockXY(real_pos_x/SceneObj.LogicRealRatio.x, real_pos_y/SceneObj.LogicRealRatio.y) then
  1497. real_is_block = true
  1498. end
  1499. Message.show("移动操作失败")
  1500. local error_str = string.format("移动操作失败: target_scene = %d, real_scene = %d, target_pos_x = %d, target_pos_y = %d, move_type = %d, real_pos_x = %d, real_pos_y = %d, code = %d, real_is_block = %s",target_scene, real_scene, target_pos_x, target_pos_y, move_type, real_pos_x, real_pos_y, code, tostring(real_is_block))
  1501. GameError.Instance:SendErrorToPHP(error_str)
  1502. end
  1503. end
  1504. --场景掉落处理
  1505. --is_fake是否是副本的假掉落
  1506. function SceneController:DealWithDropListVo(vo,is_fake)
  1507. --处理掉在障碍区的坐标
  1508. local logic_x
  1509. local logic_y
  1510. local pos
  1511. for k,v in pairs(vo.drop_list) do
  1512. logic_x = v.pos_x/SceneObj.LogicRealRatio.x
  1513. logic_y = v.pos_y/SceneObj.LogicRealRatio.y
  1514. if SceneManager:getInstance():IsBlockXY(logic_x, logic_y) then
  1515. pos = SourceOperateMove.FindNoBlockPos(Vector2(logic_x, logic_y))
  1516. v.pos_x = pos.x*SceneObj.LogicRealRatio.x
  1517. v.pos_y = pos.y*SceneObj.LogicRealRatio.y
  1518. end
  1519. end
  1520. local copy_vo = {
  1521. mon_id = vo.mon_id,
  1522. -- expire_time_stamp = vo.expire_time_stamp,
  1523. map_id = vo.map_id,
  1524. pos_x = vo.pos_x,
  1525. pos_y = vo.pos_y,
  1526. boss_type = vo.boss_type,
  1527. drop_list = {}
  1528. }
  1529. local len = #vo.drop_list
  1530. local start_index = 1
  1531. local onUpdate = function ( )
  1532. if start_index <= len then
  1533. local tb = DeepCopy(copy_vo)
  1534. for i=start_index,start_index do
  1535. if i <= len then
  1536. table.insert(tb.drop_list, vo.drop_list[i])
  1537. end
  1538. end
  1539. start_index = start_index + 1
  1540. GlobalEventSystem:Fire(SceneEventType.BROADCAST_SCENE_DROP_LIST, tb)
  1541. end
  1542. end
  1543. local function delay_fun( ... )
  1544. if len > 1 then --分批掉落 每次掉落1个物品
  1545. onUpdate()
  1546. GlobalTimerQuest:AddPeriodQuest(onUpdate, 0.2, len)
  1547. else
  1548. GlobalEventSystem:Fire(SceneEventType.BROADCAST_SCENE_DROP_LIST, vo)
  1549. end
  1550. end
  1551. local time = 0.15
  1552. if is_fake then
  1553. if Status.NowTime - RoleManager.Instance.mainRoleInfo.last_level_time < 1 then
  1554. time = 0.4
  1555. end
  1556. end
  1557. setTimeout(delay_fun,time)
  1558. end
  1559. --客户端请求切换场景总入口
  1560. function SceneController:ClientRequestChangeScene(type_id, data )
  1561. local call = function()
  1562. if type_id == 12005 or type_id == -1 then
  1563. self:requestChangeScene(data.scene_id, data.call_back_type, data.send_type, data.x, data.y)
  1564. elseif type_id == 12034 then
  1565. self:SendFmtToGame(12034, "ihhh", data.scene_id, data.line, data.x, data.y)
  1566. elseif type_id == 12041 then
  1567. self:SendFmtToGame(data.id, "h", data.args)
  1568. elseif type_id == 61001 then
  1569. self:SendFmtToGame(type_id,"i", data.scene_id)
  1570. elseif type_id == 61002 then
  1571. self:SendFmtToGame(type_id)
  1572. elseif type_id == 17402 then --中午答题进入场景
  1573. self:SendFmtToGame(17402)
  1574. end
  1575. end
  1576. if type_id == 61001 then
  1577. local config = Config.Dungeoncfg[data.scene_id]
  1578. if config then
  1579. self.request_scene_id = config.scene_id
  1580. end
  1581. else
  1582. self.request_scene_id = data.scene_id
  1583. end
  1584. Scene.Instance:PreLoadMapRes(self.request_scene_id)
  1585. call()
  1586. end
  1587. function SceneController:LateUpdate(now_time, elapse_time)
  1588. self.late_update_frame_index = self.late_update_frame_index or 0
  1589. self.late_update_frame_index = self.late_update_frame_index + 1
  1590. self.late_update_update_elapse_time = self.late_update_update_elapse_time or 0
  1591. self.late_update_update_elapse_time = self.late_update_update_elapse_time + elapse_time
  1592. -- if G_DEBUG_UPDATE_STEP and self.late_update_frame_index % G_DEBUG_UPDATE_STEP ~= 0 then
  1593. -- return
  1594. -- end
  1595. if self.late_update_frame_index % lua_viewM:GetFrameUpdateCount() ~= 0 then
  1596. return
  1597. end
  1598. self.scene:LateUpdate(now_time, self.late_update_update_elapse_time)
  1599. self.late_update_update_elapse_time = 0
  1600. --计算帧率
  1601. -- if self.scene_mgr.calculate_framerate_end_time and now_time - self.scene_mgr.calculate_framerate_end_time > 0 then
  1602. -- local total_count = Time.frameCount - self.scene_mgr.calculate_framerate_start_count
  1603. -- local frame_rate = total_count / self.scene_mgr.calculate_framerate_last_time + 2
  1604. -- self.scene_mgr.curr_frame_rate = frame_rate
  1605. -- if self.is_first_set_frameRate then
  1606. -- self.is_first_set_frameRate = false
  1607. -- GlobalEventSystem:Fire(EventName.CALCULATE_FRAME_COMPLETE, frame_rate)
  1608. -- end
  1609. -- if frame_rate > 30 then
  1610. -- self.scene_mgr.calculate_framerate_end_time = false
  1611. -- self.scene_mgr:SetNextCkeckPerformanceTime(60)
  1612. -- else
  1613. -- self.scene_mgr.calculate_framerate_end_time = false
  1614. -- end
  1615. -- end
  1616. end