//--------------------------------------------------------------------- public void Launch() { // 计算PathMgr中的动态目录 bool version_persistent = false; if (!string.IsNullOrEmpty(Config.VersionCommonPersistent) && !string.IsNullOrEmpty(Config.VersionDataPersistent)) { version_persistent = true; } if (!version_persistent || PathMgr.ForceUseDirResourcesLaunch) { PathMgr.DirLaunchLua = "Lua/Launch/"; PathMgr.DirLaunchLuaType = DirType.Resources; PathMgr.DirLaunchAb = "Resources.KingTexasLaunch/"; PathMgr.DirLaunchAbType = DirType.Resources; } else { PathMgr.DirLaunchLua = PathMgr.CombinePersistentDataPath("Lua/Launch/"); PathMgr.DirLaunchLuaType = DirType.Raw; PathMgr.DirLaunchAb = PathMgr.CombinePersistentDataPath("Resources.KingTexasLaunch/"); PathMgr.DirLaunchAbType = DirType.Raw; } if (PathMgr.ForceUseDirDataOss) { string p = Path.Combine(Environment.CurrentDirectory, "./DataOss/"); var di = new DirectoryInfo(p); string p1 = di.FullName.Replace('\\', '/'); PathMgr.DirLuaRoot = p1 + "Common/Lua/"; PathMgr.DirRawRoot = p1 + "Common/Raw/"; PathMgr.DirAbRoot = p1 + Config.Platform + "/Resources.KingTexas/"; } else { PathMgr.DirLuaRoot = PathMgr.CombinePersistentDataPath("Lua/"); PathMgr.DirRawRoot = PathMgr.CombinePersistentDataPath("Raw/"); PathMgr.DirAbRoot = PathMgr.CombinePersistentDataPath("Resources.KingTexas/"); } #if UNITY_EDITOR string info1 = string.Format("DirLaunchLua={0}, DirLaunchLuaType={1}", PathMgr.DirLaunchLua, PathMgr.DirLaunchLuaType); Debug.Log(info1); string info2 = string.Format("DirLaunchAb={0}, DirLaunchAbType={1}", PathMgr.DirLaunchAb, PathMgr.DirLaunchAbType); Debug.Log(info2); Debug.Log("DirLuaRoot=" + PathMgr.DirLuaRoot); Debug.Log("DirRawRoot=" + PathMgr.DirRawRoot); Debug.Log("DirAbRoot=" + PathMgr.DirAbRoot); #endif PathMgr.DirAbUi = PathMgr.DirAbRoot + "Ui/"; // "Resources.KingTexas/Ui/",需动态计算 PathMgr.DirAbCard = PathMgr.DirAbRoot + "Cards/"; // "Resources.KingTexas/Cards/",需动态计算 PathMgr.DirAbAudio = PathMgr.DirAbRoot + "Audio/"; // "Resources.KingTexas/Audio/",需动态计算 PathMgr.DirAbItem = PathMgr.DirAbRoot + "Item/"; // "Resources.KingTexas/Item/",需动态计算 PathMgr.DirAbParticle = PathMgr.DirAbRoot + "Particle/"; // "Resources.KingTexas/Particle/",需动态计算 LuaMgr.Launch(); }
//--------------------------------------------------------------------- public void Launch() { // 计算PathMgr中的动态目录 bool version_persistent = false; if (!string.IsNullOrEmpty(Config.VersionCommonPersistent) && !string.IsNullOrEmpty(Config.VersionDataPersistent)) { version_persistent = true; } if (!version_persistent) { PathMgr.DirLaunchAb = "Resources.KingTexasLaunch/"; PathMgr.DirLaunchAbType = DirType.Resources; } else { PathMgr.DirLaunchAb = PathMgr.CombinePersistentDataPath("Resources.KingTexasLaunch/"); PathMgr.DirLaunchAbType = DirType.Raw; } if (IsEditorDebug) { string p = Path.Combine(System.Environment.CurrentDirectory, "./DataOss/"); var di = new DirectoryInfo(p); string p1 = di.FullName.Replace('\\', '/'); string lua_root = System.Environment.CurrentDirectory + "/Assets/Script.Lua/"; PathMgr.DirLuaRoot = lua_root.Replace('\\', '/'); PathMgr.DirRawRoot = p1 + "Common/Raw/"; PathMgr.DirAbRoot = p1 + Config.Platform + "/Resources.KingTexas/"; } else { PathMgr.DirLuaRoot = PathMgr.CombinePersistentDataPath("Lua/"); PathMgr.DirRawRoot = PathMgr.CombinePersistentDataPath("Raw/"); PathMgr.DirAbRoot = PathMgr.CombinePersistentDataPath("Resources.KingTexas/"); } PathMgr.DirCsRoot = PathMgr.CombinePersistentDataPath("Cs/"); PathMgr.DirAbUi = PathMgr.DirAbRoot + "Ui/"; // "Resources.KingTexas/Ui/",需动态计算 PathMgr.DirAbCard = PathMgr.DirAbRoot + "Cards/"; // "Resources.KingTexas/Cards/",需动态计算 PathMgr.DirAbAudio = PathMgr.DirAbRoot + "Audio/"; // "Resources.KingTexas/Audio/",需动态计算 PathMgr.DirAbItem = PathMgr.DirAbRoot + "Item/"; // "Resources.KingTexas/Item/",需动态计算 PathMgr.DirAbParticle = PathMgr.DirAbRoot + "Particle/"; // "Resources.KingTexas/Particle/",需动态计算 LuaMgr.Launch(!version_persistent); CsRuntime = new CasinosILRuntime(); CsRuntime.Create(); }
//--------------------------------------------------------------------- public void Close() { if (TimerShaft != null) { TimerShaft.Destroy(); TimerShaft = null; } if (SoundMgr != null) { SoundMgr.destroy(); SoundMgr = null; } if (HeadIconMgr != null) { HeadIconMgr.destroy(); HeadIconMgr = null; } if (SpineMgr != null) { SpineMgr.Destroy(); SpineMgr = null; } AsyncAssetLoaderMgr = null; if (AsyncAssetLoadGroup != null) { AsyncAssetLoadGroup.destroy(); AsyncAssetLoadGroup = null; } if (LuaMgr != null) { LuaMgr.Release(); LuaMgr = null; } if (MemoryStream != null) { MemoryStream.Close(); MemoryStream = null; } Screen.sleepTimeout = SleepTimeout.SystemSetting; }
//--------------------------------------------------------------------- public void Update(float elapsed_tm) { if (SoundMgr != null) { SoundMgr.Update(); } if (FTMgr != null) { FTMgr.Update(elapsed_tm); } if (DelayMgr != null) { DelayMgr.Update(elapsed_tm); } if (NetMgr != null) { NetMgr.Update(elapsed_tm); } if (AsyncAssetLoaderMgr != null) { AsyncAssetLoaderMgr.Update(Time.deltaTime); } if (LuaMgr != null) { LuaMgr.Update(elapsed_tm); } if (TimerShaft != null) { TimerShaft.ProcessTimer((ulong)Stopwatch.ElapsedMilliseconds); } if (Input.GetKeyDown(KeyCode.Escape)) { LuaMgr._CSharpCallOnAndroidQuitConfirm(); } }
//--------------------------------------------------------------------- public void Update(float elapsed_tm) { if (SoundMgr != null) { SoundMgr.Update(); } //if (FTMgr != null) //{ // FTMgr.Update(elapsed_tm); //} if (DelayMgr != null) { DelayMgr.Update(elapsed_tm); } if (NetMgr != null) { NetMgr.Update(elapsed_tm); } if (LuaMgr != null) { LuaMgr.Update(elapsed_tm); } if (CsRuntime != null) { CsRuntime.Update(); } //if (TimerShaft != null) //{ // TimerShaft.ProcessTimer((ulong)Stopwatch.ElapsedMilliseconds); //} //if (Input.GetKeyDown(KeyCode.Escape)) //{ // //LuaMgr._CSharpCallOnAndroidQuitConfirm(); //} }
//------------------------------------------------------------------------- public void OnApplicationFocus(bool focus_status) { LuaMgr._CSharpCallOnApplicationFocus(focus_status); }
//------------------------------------------------------------------------- public void OnApplicationPause(bool pause) { LuaMgr._CSharpCallOnApplicationPause(pause); }
//--------------------------------------------------------------------- public CasinosContext(bool force_use_resouceslaunch, bool force_use_dataoss) { Instance = this; _eEditorRunSourcePlatform editor_runsorce = _eEditorRunSourcePlatform.Android; #if UNITY_STANDALONE_WIN editor_runsorce = _eEditorRunSourcePlatform.PC; #elif UNITY_ANDROID && UNITY_EDITOR editor_runsorce = _eEditorRunSourcePlatform.Android; #elif UNITY_ANDROID editor_runsorce = _eEditorRunSourcePlatform.Android; #elif UNITY_IPHONE editor_runsorce = _eEditorRunSourcePlatform.IOS; #endif #if UNITY_EDITOR IsEditor = true; #else IsEditor = false; #endif #if UNITY_IPHONE || UNITY_STANDALONE_OSX || UNITY_DASHBOARD_WIDGET || UNITY_STANDALONE_LINUX || UNITY_WEBPLAYER IsSqliteUnity = true; #else IsSqliteUnity = false; #endif #if UNITY_IOS string version = UnityEngine.iOS.Device.systemVersion; var arr_version = version.Split('.'); int first_version_code = 0; if (arr_version.Length > 0) { int.TryParse(arr_version[0].ToString(), out first_version_code); } if (first_version_code < 9) { UseHttps = false; } else { UseHttps = true; } UnityIOS = true; UnityAndroid = false; #elif UNITY_ANDROID UseHttps = false; UnityAndroid = true; UnityIOS = false; #elif UNITY_STANDALONE_WIN #endif Stopwatch = new System.Diagnostics.Stopwatch(); Stopwatch.Start(); TimerShaft = new TimerShaft(); MemoryStream = new MemoryStream(); SB = new StringBuilder(); FTMgr = new FTMgr(); PathMgr = new PathMgr(editor_runsorce, force_use_resouceslaunch, force_use_dataoss);// 初始化PathMgr Config = new CasinosConfig(editor_runsorce); NativeMgr = new NativeMgr(); SpineMgr = new SpineMgr(); // 初始化系统参数 { #if UNITY_EDITOR Application.runInBackground = false; Screen.sleepTimeout = SleepTimeout.SystemSetting; QualitySettings.vSyncCount = 0; Application.targetFrameRate = -1; #else Application.runInBackground = true; Screen.sleepTimeout = SleepTimeout.NeverSleep; QualitySettings.vSyncCount = 1; Application.targetFrameRate = 60; #endif } if (NativeAPIMsgReceiverListner == null) { NativeAPIMsgReceiverListner = new NativeAPIMsgReceiverListener(); } if (AsyncAssetLoaderMgr == null) { AsyncAssetLoaderMgr = new AsyncAssetLoaderMgr(); } AsyncAssetLoadGroup = AsyncAssetLoaderMgr.createAsyncAssetLoadGroup(); NetMgr = new NetMgr(); PlayerPrefs = new CasinosPlayerPrefs(); TextureMgr = new TextureMgr(); UIObjectFactory.SetLoaderExtension(typeof(GLoaderEx)); LuaMgr = new LuaMgr(); SoundMgr = new SoundMgr(); HeadIconMgr = new HeadIconMgr(); }
//--------------------------------------------------------------------- public void Close() { if (TimerShaft != null) { TimerShaft.Destroy(); TimerShaft = null; } if (SoundMgr != null) { SoundMgr.destroy(); SoundMgr = null; } if (HeadIconMgr != null) { HeadIconMgr.destroy(); HeadIconMgr = null; } if (SpineMgr != null) { SpineMgr.Destroy(); SpineMgr = null; } if (AsyncAssetLoadGroup != null) { AsyncAssetLoadGroup.destroy(); AsyncAssetLoadGroup = null; } if (AsyncAssetLoaderMgr != null) { AsyncAssetLoaderMgr.Close(); AsyncAssetLoaderMgr = null; } if (NetMgr != null) { NetMgr.Close(); NetMgr = null; } if (NativeAPIMsgReceiverListner != null) { NativeAPIMsgReceiverListner.Close(); NativeAPIMsgReceiverListner = null; } if (LuaMgr != null) { LuaMgr.Release(); LuaMgr = null; } if (DelayMgr != null) { DelayMgr.Close(); DelayMgr = null; } if (MemoryStream != null) { MemoryStream.Close(); MemoryStream = null; } Screen.sleepTimeout = SleepTimeout.SystemSetting; }
//--------------------------------------------------------------------- public void Close() { //if (TimerShaft != null) //{ // TimerShaft.Destroy(); // TimerShaft = null; //} if (SoundMgr != null) { SoundMgr.Destroy(); SoundMgr = null; } if (HeadIconMgr != null) { HeadIconMgr.Destroy(); HeadIconMgr = null; } if (SpineMgr != null) { SpineMgr.Destroy(); SpineMgr = null; } if (NetMgr != null) { NetMgr.Close(); NetMgr = null; } if (NativeAPIMsgReceiverListner != null) { NativeAPIMsgReceiverListner.Close(); NativeAPIMsgReceiverListner = null; } if (CsRuntime != null) { CsRuntime.Destroy(); CsRuntime = null; } if (LuaMgr != null) { LuaMgr.Release(); LuaMgr = null; } if (DelayMgr != null) { DelayMgr.Close(); DelayMgr = null; } if (MemoryStream != null) { MemoryStream.Close(); MemoryStream = null; } Screen.sleepTimeout = SleepTimeout.SystemSetting; }