gameStateRole.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. local gameStateRole = class('gameStateRole')
  2. function gameStateRole:ctor()
  3. end
  4. function gameStateRole:getStateType()
  5. return global.MMO.GAME_STATE_ROLE
  6. end
  7. function gameStateRole:onEnter()
  8. local function updater( delta )
  9. global.gameEnvironment:GetNetClient():Tick()
  10. global.FrameAnimManager:Tick( delta )
  11. global.ResDownloader:Tick( delta )
  12. end
  13. self._scheduleId = Schedule( updater, 0.05 )
  14. -- loading mediator
  15. local LoadingMediator = requireMediator( "loading_layer/LoadingMediator" )
  16. local loadingMediator = LoadingMediator.new()
  17. global.Facade:registerMediator( loadingMediator )
  18. global.Facade:sendNotification(global.NoticeTable.Layer_Notice_Open)
  19. global.Facade:sendNotification(global.NoticeTable.Layer_Login_Version_Open)
  20. global.Facade:sendNotification(global.NoticeTable.Layer_Login_Role_Open)
  21. global.userInputController:InitOnEnterRole()
  22. return 1
  23. end
  24. function gameStateRole:onEnd()--重启
  25. global.Facade:sendNotification( global.NoticeTable.ReleaseMemory)
  26. end
  27. function gameStateRole:onExit()
  28. if self._scheduleId ~= -1 then
  29. UnSchedule(self._scheduleId)
  30. self._scheduleId = -1
  31. end
  32. global.Facade:sendNotification(global.NoticeTable.Layer_Notice_Close)
  33. global.Facade:sendNotification(global.NoticeTable.Layer_Login_Version_Close)
  34. global.Facade:sendNotification(global.NoticeTable.Layer_Login_Role_Close)
  35. global.Facade:sendNotification(global.NoticeTable.Layer_CommonTips_Close)
  36. -- release texture cache
  37. global.TextureCache:removeUnusedTextures()
  38. global.FrameAnimManager:unloadUnusedAnimData()
  39. return 1
  40. end
  41. return gameStateRole