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

97 lines
2.3 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())
2021-07-12 10:28:57 +08:00
-- 关闭多点触控
UnityEngine.Input.multiTouchEnabled = false
--
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()
2021-08-24 15:34:50 +08:00
-- 默认30帧
if PlayerPrefs.HasKey("ResLution") then
UnityEngine.Application.targetFrameRate = PlayerPrefs.GetInt("ResLution") == 0 and 30 or 60
else
UnityEngine.Application.targetFrameRate = 30
end
2021-06-16 17:29:17 +08:00
-- 延迟
Timer.New(function()
UIManager.OpenPanel(UIName.LoginPanel)
UIManager.OpenPanel(UIName.HorseRaceLampView)
end, 0.5):Start()
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