2024-08-28 17:03:50 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Net.NetworkInformation;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2024-09-23 15:05:34 +08:00
|
|
|
|
using AOT.PostProcess.ColorFade;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
using CriWare;
|
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
|
using Framework;
|
|
|
|
|
|
using Gameplay.Net;
|
|
|
|
|
|
using Gameplay.Performance;
|
2024-09-14 14:54:56 +08:00
|
|
|
|
using Gameplay.PostProcess.ColorFade;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
using Gameplay.SubSystems;
|
|
|
|
|
|
using PhxhSDK;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
using YooAsset;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if !UNITY_EDITOR
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
using Constants = Framework.Constants;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Gameplay
|
|
|
|
|
|
{
|
|
|
|
|
|
public class GameStartLoading : LoadingExecutor
|
|
|
|
|
|
{
|
|
|
|
|
|
public static bool newMethodLogin = true;
|
|
|
|
|
|
|
|
|
|
|
|
public GameStartLoading() : base(E_LoadingType.CommonLoading)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override async UniTask<E_LoadingResult> OnExecute()
|
|
|
|
|
|
{
|
|
|
|
|
|
E_LoadingResult result;
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.1f;
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("open_loading_start", null);
|
2024-08-28 17:03:50 +08:00
|
|
|
|
|
|
|
|
|
|
await Resources.UnloadUnusedAssets();
|
|
|
|
|
|
result = await FirstRunAppCheck();
|
|
|
|
|
|
if (result != E_LoadingResult.Success)
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("app_open_loading_process", new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"process",25 }
|
|
|
|
|
|
});
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.25f;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
result = await AppVersionCheck();
|
|
|
|
|
|
if (result != E_LoadingResult.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("AppVersionCheck错误");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("app_open_loading_process", new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"process",40 }
|
|
|
|
|
|
});
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.4f;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
result = await CheckCriAtom();
|
|
|
|
|
|
if (result != E_LoadingResult.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("CheckCriAtom错误");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("app_open_loading_process", new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"process",55 }
|
|
|
|
|
|
});
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.55f;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
result = await LoadLoginUI();
|
|
|
|
|
|
if (result != E_LoadingResult.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("LoadLoginUI错误");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("app_open_loading_process", new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"process",70 }
|
|
|
|
|
|
});
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.7f;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
result = await PreloadOthers();
|
|
|
|
|
|
if (result != E_LoadingResult.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("_PreloadOthers错误");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("app_open_loading_process", new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"process",85 }
|
|
|
|
|
|
});
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.85f;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
result = await LoadPerformance();
|
|
|
|
|
|
if (result != E_LoadingResult.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("_LoadPerformance错误");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("app_open_loading_process", new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"process",90 }
|
|
|
|
|
|
});
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.9f;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
result = InitGameSetting();
|
|
|
|
|
|
if (result != E_LoadingResult.Success)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("InitGameSetting错误");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("app_open_loading_process", new System.Collections.Generic.Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"process",95 }
|
|
|
|
|
|
});
|
2024-08-30 15:58:29 +08:00
|
|
|
|
Progress = 0.95f;
|
2024-08-28 17:03:50 +08:00
|
|
|
|
|
|
|
|
|
|
if (!newMethodLogin)//使用原先登录逻辑
|
|
|
|
|
|
await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_LogIn);
|
|
|
|
|
|
else//新版登陆界面
|
|
|
|
|
|
await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_StartGameInterface);
|
|
|
|
|
|
|
2024-09-04 13:31:54 +08:00
|
|
|
|
DebugUtil.Log("GameStart加载完成");
|
2024-08-28 17:03:50 +08:00
|
|
|
|
|
2024-09-26 19:16:39 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("open_loading_end", null);
|
2024-08-28 17:03:50 +08:00
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async UniTask<E_LoadingResult> PreloadOthers()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 渐变shader需要提前加载
|
|
|
|
|
|
AssetManager.Instance.PostPreload(Constants.SHADER_FADEOUT_PATH);
|
2024-09-18 16:03:02 +08:00
|
|
|
|
AssetManager.Instance.PostPreload(CommonUtils.BLUR_MAT_PATH);
|
2024-08-28 17:03:50 +08:00
|
|
|
|
|
|
|
|
|
|
await AssetManager.Instance.WaitAllPreloads();
|
2024-09-23 15:05:34 +08:00
|
|
|
|
|
|
|
|
|
|
var globalFadeManagerInst = new ColorFadeManagerImpl();
|
|
|
|
|
|
GlobalFadeManager.CreateInstance(globalFadeManagerInst);
|
|
|
|
|
|
await globalFadeManagerInst.Init();
|
2024-08-28 17:03:50 +08:00
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async UniTask<E_LoadingResult> LoadLoginUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!newMethodLogin)
|
|
|
|
|
|
await UIManager.Instance.LoadWindow(UINameConst.UI_LogIn);
|
|
|
|
|
|
else
|
|
|
|
|
|
await UIManager.Instance.LoadWindow(UINameConst.UI_StartGameInterface);
|
|
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否是安装后第一次运行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private async UniTask<E_LoadingResult> FirstRunAppCheck()
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await Net.AppConfig.Instance.UnityRequest();
|
|
|
|
|
|
if (result == Net.ACDownloadStatus.Error)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("网络错误或服务器列表没有添加对应渠道");
|
|
|
|
|
|
return E_LoadingResult.DeviceNetError;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 强更检查
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private async UniTask<E_LoadingResult> AppVersionCheck()
|
|
|
|
|
|
{
|
|
|
|
|
|
var needUpdate = AppConfig.Instance.UpdateInfo.NeedUpdate;
|
|
|
|
|
|
|
|
|
|
|
|
if (needUpdate)
|
|
|
|
|
|
{
|
|
|
|
|
|
string platform = GetPlatform();
|
|
|
|
|
|
if (null != platform && AppConfig.Instance.UpdateInfo.AppUrl.TryGetValue(platform, out string url))
|
|
|
|
|
|
await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_Update, url);
|
|
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.ErrorTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetPlatform()
|
|
|
|
|
|
{
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
return EditorUserBuildSettings.activeBuildTarget switch
|
|
|
|
|
|
{
|
|
|
|
|
|
BuildTarget.Android => "android",
|
|
|
|
|
|
BuildTarget.iOS => "ios",
|
|
|
|
|
|
_ => null,
|
|
|
|
|
|
};
|
|
|
|
|
|
#else
|
|
|
|
|
|
return Application.platform switch
|
|
|
|
|
|
{
|
|
|
|
|
|
RuntimePlatform.Android => "android",
|
|
|
|
|
|
RuntimePlatform.IPhonePlayer => "ios",
|
|
|
|
|
|
_ => null,
|
|
|
|
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async UniTask<E_LoadingResult> LoadPerformance()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (PerformanceManager.instance != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PerformanceManager.CreateInstance();
|
|
|
|
|
|
if (PerformanceManager.instance == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("PerformanceManager 创建失败");
|
|
|
|
|
|
return E_LoadingResult.ErrorTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
await PerformanceManager.instance.LoadRes();
|
|
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private E_LoadingResult InitGameSetting()
|
|
|
|
|
|
{
|
|
|
|
|
|
StorageMgr.Instance.InitServerData();
|
|
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async UniTask<E_LoadingResult> CheckCriAtom()
|
|
|
|
|
|
{
|
|
|
|
|
|
const string AUDIO_PATH = "Assets/AudioCPK/";
|
|
|
|
|
|
|
|
|
|
|
|
RawFileHandle rawFileHandle = AssetManager.Instance.LoadRawFileAsync($"{AUDIO_PATH}{CriAtom.instance.acfFile}");
|
|
|
|
|
|
await rawFileHandle;
|
|
|
|
|
|
string realPath = rawFileHandle.GetRawFilePath();
|
|
|
|
|
|
if (realPath.EndsWith(".acf"))
|
|
|
|
|
|
CriAtom.instance.acfRealPath = realPath;
|
|
|
|
|
|
else
|
|
|
|
|
|
CriAtom.instance.acfRealPath = $"{realPath}.acf";
|
|
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(CriAtom.instance.acfRealPath))
|
|
|
|
|
|
File.Copy(realPath, CriAtom.instance.acfRealPath);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (CriAtomCueSheet sheet in CriAtom.instance.cueSheets)
|
|
|
|
|
|
{
|
|
|
|
|
|
#region acb
|
|
|
|
|
|
rawFileHandle = AssetManager.Instance.LoadRawFileAsync($"{AUDIO_PATH}{sheet.acbFile}");
|
|
|
|
|
|
await rawFileHandle;
|
|
|
|
|
|
realPath = rawFileHandle.GetRawFilePath();
|
|
|
|
|
|
if (realPath.EndsWith(".acb"))
|
|
|
|
|
|
sheet.acbRealPath = realPath;
|
|
|
|
|
|
else
|
|
|
|
|
|
sheet.acbRealPath = $"{realPath}.acb";
|
|
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(sheet.acbRealPath))
|
|
|
|
|
|
File.Copy(realPath, sheet.acbRealPath);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region awb
|
|
|
|
|
|
rawFileHandle = AssetManager.Instance.LoadRawFileAsync($"{AUDIO_PATH}{sheet.awbFile}");
|
|
|
|
|
|
await rawFileHandle;
|
|
|
|
|
|
realPath = rawFileHandle.GetRawFilePath();
|
|
|
|
|
|
if (realPath.EndsWith(".awb"))
|
|
|
|
|
|
sheet.awbRealPath = realPath;
|
|
|
|
|
|
else
|
|
|
|
|
|
sheet.awbRealPath = $"{realPath}.awb";
|
|
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(sheet.awbRealPath))
|
|
|
|
|
|
File.Copy(realPath, sheet.awbRealPath);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CriAtom.instance.Load();
|
|
|
|
|
|
|
|
|
|
|
|
return E_LoadingResult.Success;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|