miduo_client/Assets/ManagedResources/~Lua/Logic/Game.lua

84 lines
1.9 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
require "PreLoad"
require "Logic/GameEvent"
--管理器--
Game = {}
local this = Game
--初始化完成,发送链接服务器信息--
function Game.Initialize()
math.randomseed(os.time())
2020-05-09 13:31:21 +08:00
this.CurPlatform = tostring(UnityEngine.Application.platform)
U3d.Application.runInBackground = true
Screen.sleepTimeout = U3d.SleepTimeout.NeverSleep
this.GlobalEvent = EventManager.New()
this.InitManagers()
UIManager.OpenPanel(UIName.LoginPanel)
UIManager.OpenPanel(UIName.HorseRaceLampView)
2020-05-09 13:31:21 +08:00
end
--初始化管理器
local managers = require("Common/Managers")
2020-05-09 13:31:21 +08:00
function Game.InitManagers()
Log("===============>初始化管理器")
Framework.Initialize()
this.managerList = {}
2020-05-09 13:31:21 +08:00
for i, v in ipairs(managers) do
this.managerList[i] = require("Modules/"..v)
if this.managerList[i].Initialize then
this.managerList[i].Initialize()
end
2020-05-09 13:31:21 +08:00
end
--
UpdateBeat:Add(this.LateUpdate, this)
2020-05-09 13:31:21 +08:00
end
function Game.LateUpdate()
for i, v in ipairs(this.managerList) do
if v.LateUpdate then
MyPCall(v.LateUpdate, managers[i])
end
end
end
function Game.Logout()
2021-01-26 17:08:39 +08:00
PlayerPrefs.SetInt("language",PlayerPrefs.GetInt("language_flag"))
if AppConst.isSDKLogin then
SDKMgr:Logout()
else
Game.Restart()
end
end
function Game.Restart()
Framework.Dispose()
-- 退出时把socket断掉
SocketManager.Disconnect(SocketType.LOGIN)
--
App.Instance:ReStart()
end
function Game.Quit()
Framework.Dispose()
UnityEngine.Application.Quit()
end
2020-05-09 13:31:21 +08:00
--应用程序暂停/恢复
function Game.OnApplicationPause(pauseStatus)
Log("Game.OnApplicationPause:"..tostring(pauseStatus))
end
--应用程序获得焦点/失去焦点
function Game.OnApplicationFocus(hasFocus)
Log("Game.OnApplicationFocus:"..tostring(hasFocus))
end
--应用程序退出
function Game.OnApplicationQuit()
Log("Game.OnApplicationQuit")
end