ChangeSceneCommand.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. local ChangeSceneCommand = class('ChangeSceneCommand', framework.SimpleCommand)
  2. function ChangeSceneCommand:ctor()
  3. end
  4. function ChangeSceneCommand:execute(notification)
  5. local mapID = notification:getBody()
  6. if not mapID then
  7. releasePrint( "error, change scene data is nil" )
  8. end
  9. local facade = global.Facade
  10. local mapProxy = facade:retrieveProxy( global.ProxyTable.Map )
  11. local lastMapID = mapProxy:GetLastMapID()
  12. -- 切地图刷新主玩家的一些显示,
  13. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  14. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  15. if mainPlayer and mainPlayerID then
  16. global.HUDHPManager:UpdateNow(mainPlayer)
  17. mainPlayer:SetInSafeZone(mapProxy:GetInSafeArea(mainPlayer:GetMapX(), mainPlayer:GetMapY()))
  18. end
  19. -- 清理技能特效
  20. global.skillManager:CleanupBehaviors()
  21. -- 关闭NPC面板
  22. local npcProxy = global.Facade:retrieveProxy(global.ProxyTable.NPC)
  23. npcProxy:Cleanup()
  24. -- 刷新主玩家安全区
  25. local MapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  26. MapProxy:UpdateInSafeAreaState()
  27. -- first enter world
  28. if nil == lastMapID then
  29. ClearWorldLoadingProgress()
  30. local envProxy = global.Facade:retrieveProxy( global.ProxyTable.GameEnvironment )
  31. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  32. local loginProxy = global.Facade:retrieveProxy( global.ProxyTable.Login )
  33. local account = AuthProxy:GetUID()
  34. local roleName = loginProxy:GetSelectedRoleName()
  35. local serverID = loginProxy:GetSelectedServerId()
  36. local channelID = envProxy:GetChannelID()
  37. local currentModule = global.L_ModuleManager:GetCurrentModule()
  38. local currentSubMod = currentModule:GetCurrentSubMod()
  39. local displayVer = currentModule:GetAllVersionForDisplay()
  40. local userValue = string.format( "%s|%s|%s|%s|%s|%s|%s|%s",
  41. tostring( displayVer ),
  42. tostring( channelID ),
  43. tostring( account ),
  44. tostring( roleName ),
  45. tostring( mapID ),
  46. tostring( serverID ),
  47. tostring( currentModule:GetID() ),
  48. tostring( currentSubMod:GetID() )
  49. )
  50. -- ver|channel|account|roleName|mapID|serverID
  51. if cc.PLATFORM_OS_ANDROID == global.Platform then
  52. buglyAddUserValue( "UserAccountData", userValue )
  53. else
  54. releasePrint( "__________user account data:" .. userValue )
  55. end
  56. end
  57. if lastMapID ~= mapID then
  58. -- stop all audio
  59. facade:sendNotification( global.NoticeTable.Audio_Stop_All )
  60. facade:sendNotification( global.NoticeTable.MapInfoChange, mapID, lastMapID )
  61. -- ssr
  62. ssr.ssrBridge:onMapInfoChange({mapID = mapID, lastMapID = lastMapID})
  63. -- SL
  64. if lastMapID then
  65. SLBridge:onLUAEvent(LUA_EVENT_MAPINFOCHANGE, {mapID = mapID, lastMapID = lastMapID})
  66. else
  67. SLBridge:onLUAEvent(LUA_EVENT_MAPINFOINIT, {mapID = mapID})
  68. end
  69. CheckNeedAddSLMapEffect(lastMapID, mapID)
  70. end
  71. -- ssr
  72. ssr.ssrBridge:onChangeScene({mapID = mapID, lastMapID = lastMapID})
  73. -- SL
  74. SLBridge:onLUAEvent(LUA_EVENT_CHANGESCENE, {mapID = mapID})
  75. local DataTrackProxy = global.Facade:retrieveProxy(global.ProxyTable.DataTrackProxy)
  76. DataTrackProxy:OnExpandInfoChanage()
  77. end
  78. return ChangeSceneCommand