97 lines
2.3 KiB
Lua
97 lines
2.3 KiB
Lua
require "PreLoad"
|
|
require "Logic/GameEvent"
|
|
|
|
--管理器--
|
|
Game = {}
|
|
local this = Game
|
|
|
|
--初始化完成,发送链接服务器信息--
|
|
function Game.Initialize()
|
|
math.randomseed(os.time())
|
|
|
|
-- 关闭多点触控
|
|
UnityEngine.Input.multiTouchEnabled = false
|
|
--
|
|
this.CurPlatform = tostring(UnityEngine.Application.platform)
|
|
U3d.Application.runInBackground = true
|
|
Screen.sleepTimeout = U3d.SleepTimeout.NeverSleep
|
|
this.GlobalEvent = EventManager.New()
|
|
this.InitManagers()
|
|
-- 默认30帧
|
|
if PlayerPrefs.HasKey("ResLution") then
|
|
UnityEngine.Application.targetFrameRate = PlayerPrefs.GetInt("ResLution") == 0 and 30 or 60
|
|
else
|
|
UnityEngine.Application.targetFrameRate = 30
|
|
end
|
|
|
|
-- 延迟
|
|
Timer.New(function()
|
|
UIManager.OpenPanel(UIName.LoginPanel)
|
|
UIManager.OpenPanel(UIName.HorseRaceLampView)
|
|
end, 0.5):Start()
|
|
end
|
|
|
|
--初始化管理器
|
|
local managers = require("Common/Managers")
|
|
function Game.InitManagers()
|
|
Log("===============>初始化管理器")
|
|
Framework.Initialize()
|
|
this.managerList = {}
|
|
for i, v in ipairs(managers) do
|
|
this.managerList[i] = require("Modules/"..v)
|
|
|
|
if this.managerList[i].Initialize then
|
|
this.managerList[i].Initialize()
|
|
end
|
|
end
|
|
|
|
--
|
|
UpdateBeat:Add(this.LateUpdate, this)
|
|
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()
|
|
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
|
|
|
|
--应用程序暂停/恢复
|
|
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 |