From f47ea60f59e0b2b8601583351e269151237c6708 Mon Sep 17 00:00:00 2001
From: client_Zxw <826696702@qq.com>
Date: 星期一, 28 一月 2019 11:20:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into SpringFestival
---
Core/GameEngine/Login/Launch.cs | 116 +++++++++++++++++++++-------------------------------------
1 files changed, 42 insertions(+), 74 deletions(-)
diff --git a/Core/GameEngine/Login/Launch.cs b/Core/GameEngine/Login/Launch.cs
index 5d443ff..f3f7430 100644
--- a/Core/GameEngine/Login/Launch.cs
+++ b/Core/GameEngine/Login/Launch.cs
@@ -11,6 +11,7 @@
{
static LaunchStage m_CurrentStage = LaunchStage.None;
+ static int step = 0;
public static ProgressInfo progressInfo { get; private set; }
private void Awake()
@@ -123,21 +124,18 @@
}
float timer = 0f;
- float progressRateOfIncrease = 1f;
- float originalExpectTotalTime = -1f;
- float expectTotalTime = 0f;
- public float totalTime {
- get {
- return Mathf.Lerp(originalExpectTotalTime, expectTotalTime, Mathf.Clamp01(timer / expectTotalTime));
- }
- }
Queue<LaunchTask> tasks = new Queue<LaunchTask>();
LaunchTask currentTask = null;
bool launchComplete = false;
+ float surplusProgress = 0f;
+ float surplusTime = 0f;
void Start()
{
+ WindowCenter.Instance.DestoryWinsByStage(WindowCenter.WindowStage.Launch);
+ AssetBundleUtility.Instance.UnloadAssetBundle("builtin/prefabs", true, false);
+
Application.backgroundLoadingPriority = ThreadPriority.High;
SoundPlayer.Instance.PlayLoginMusic();
Config.Instance.PreLoadConfigs();
@@ -145,7 +143,6 @@
Config.Instance.RegisterGlobalEvent();
PackageRegedit.Init();
DebugUtility.Instance.CreateDebugRoot();
-
WindowCenter.Instance.OpenFromLocal<LaunchWin>();
var sdkInitedTask = new SDKInitedTask();
@@ -182,7 +179,6 @@
tasks.Enqueue(launchFadeOutTask);
CalculateExpectTotalTime();
- originalExpectTotalTime = expectTotalTime;
}
void Update()
@@ -216,12 +212,13 @@
if (m_CurrentStage == LaunchStage.DownLoad)
{
- progressInfo = new ProgressInfo(m_CurrentStage, progressInfo.totalProgress, 0f);
+ progressInfo = new ProgressInfo(m_CurrentStage, 1, progressInfo.totalProgress, 0f);
}
else
{
timer += Time.deltaTime;
- var progress = progressInfo.totalProgress + progressRateOfIncrease * Time.deltaTime / totalTime;
+ var progress = progressInfo.totalProgress + surplusProgress * (Time.deltaTime / surplusTime);
+ progress = Mathf.Clamp(progress, 0, 0.98f);
var partProgress = 0f;
if (currentTask == null)
@@ -230,18 +227,19 @@
}
else
{
- var temp = currentTask.timer / Mathf.Min(1f, currentTask.duration);
+ var temp = currentTask.timer / Mathf.Min(2f, currentTask.duration);
+ step = (int)temp + 1;
partProgress = temp - (int)temp;
}
- progressInfo = new ProgressInfo(m_CurrentStage, Mathf.Clamp01(progress), partProgress);
+ progressInfo = new ProgressInfo(m_CurrentStage, step, Mathf.Clamp01(progress), partProgress);
}
}
if (launchComplete)
{
Debug.LogFormat("鍚姩鑰楁椂锛歿0}", timer);
- progressInfo = new ProgressInfo(m_CurrentStage, 1f, 1f);
+ progressInfo = new ProgressInfo(m_CurrentStage, 1, 1f, 1f);
this.enabled = false;
StageManager.Instance.LoadLoginStage();
}
@@ -249,19 +247,13 @@
void CalculateExpectTotalTime()
{
- var time = timer;
- foreach (var item in tasks)
- {
- time += item.expectTime;
+ surplusTime = 0f;
+ foreach (var item in tasks)
+ {
+ surplusTime += item.expectTime;
}
- expectTotalTime = time;
- if (originalExpectTotalTime <= 0f)
- {
- originalExpectTotalTime = expectTotalTime;
- }
-
- progressRateOfIncrease = (expectTotalTime - timer) / (originalExpectTotalTime - timer);
+ surplusProgress = 1 - progressInfo.totalProgress;
}
public enum LaunchStage
@@ -269,12 +261,13 @@
None = 0,
SDKInit = 1,
AssetCopy = 2,
- ClientVersion = 3,
- CheckAsset = 4,
- DownLoad = 5,
- AssetBundleInit = 6,
- ConfigInit = 7,
- Complete = 8,
+ AssetDecompress=3,
+ ClientVersion = 4,
+ CheckAsset = 5,
+ DownLoad = 6,
+ AssetBundleInit = 7,
+ ConfigInit = 8,
+ Complete = 9,
}
public abstract class LaunchTask
@@ -330,7 +323,6 @@
var memory = 2048;
DeviceUtility.GetCpuAndMemory(out cpu, out memory);
DebugEx.LogFormat("鑾峰緱鏈哄櫒淇℃伅锛歝pu {0}----鍐呭瓨 {1}", cpu, memory);
- GameNotice.OpenGameNotice();
}
public override void Update()
@@ -362,14 +354,14 @@
List<FileInfo> copyTasks = new List<FileInfo>();
public override float expectTime {
- get { return LocalSave.GetFloat("AssetCopyTask_ExpectTime", 30f); }
+ get { return LocalSave.GetFloat("AssetCopyTask_ExpectTime", 70f); }
protected set { LocalSave.SetFloat("AssetCopyTask_ExpectTime", value); }
}
public override void Begin()
{
m_CurrentStage = LaunchStage.AssetCopy;
- duration = Mathf.Max(0.1f, expectTime);
+ duration = Mathf.Max(0.5f, expectTime);
outTime = 50f;
#if UNITY_ANDROID
switch (VersionConfig.Get().assetAccess)
@@ -522,8 +514,8 @@
public override void Begin()
{
- m_CurrentStage = LaunchStage.AssetCopy;
- duration = Mathf.Max(0.1f, expectTime);
+ m_CurrentStage = LaunchStage.AssetDecompress;
+ duration = Mathf.Max(0.5f, expectTime);
if (!AssetDeCompressTask.assetDeCompressCompleted)
{
@@ -573,7 +565,7 @@
public override void Begin()
{
m_CurrentStage = LaunchStage.ClientVersion;
- duration = expectTime;
+ duration = Mathf.Max(0.5f, expectTime);
#if UNITY_ANDROID
if (InGameDownTestUtility.enable || !Application.isEditor)
@@ -640,7 +632,7 @@
public override void Begin()
{
m_CurrentStage = LaunchStage.CheckAsset;
- duration = Mathf.Max(0.1f, expectTime);
+ duration = Mathf.Max(0.5f, expectTime);
ServerListCenter.Instance.RequestJumpUrl();
OperationLogCollect.Instance.RecordLauchEvent(2);
@@ -662,6 +654,7 @@
{
expectTime = timer;
DebugEx.LogFormat("{0}鎵ц鏃堕暱锛歿1}锛�", this.GetType().Name, timer);
+ GameNotice.OpenGameNotice();
}
public override void Update()
@@ -697,7 +690,7 @@
{
m_CurrentStage = LaunchStage.DownLoad;
- duration = Mathf.Max(0.1f, expectTime);
+ duration = Mathf.Max(0.5f, expectTime);
if (VersionUtility.Instance.NeedDownAsset())
{
if (!AssetVersionUtility.priorAssetDownLoadDone)
@@ -762,7 +755,7 @@
{
m_CurrentStage = LaunchStage.AssetBundleInit;
- duration = Mathf.Max(0.1f, expectTime);
+ duration = Mathf.Max(0.5f, expectTime);
if (!AssetSource.allFromEditor)
{
AssetBundleUtility.Instance.Sync_LoadAll("ui/prioritywindow");
@@ -780,6 +773,7 @@
public override void End()
{
expectTime = timer;
+ UILoader.LoadWindowAsync("LaunchBackGroundWin", null);
DebugEx.LogFormat("{0}鎵ц鏃堕暱锛歿1}锛�", this.GetType().Name, timer);
}
@@ -807,19 +801,16 @@
public class ConfigInitTask : LaunchTask
{
public override float expectTime {
- get { return LocalSave.GetFloat("ConfigInitTask_ExpectTime", inferredTime); }
+ get { return LocalSave.GetFloat("ConfigInitTask_ExpectTime", 10f); }
protected set { LocalSave.SetFloat("ConfigInitTask_ExpectTime", value); }
}
float threshold = 1f;
- float inferredTime = 3f;
public override void Begin()
{
- inferredTime = LocalSave.GetFloat("AssetCopyTask_ExpectTime", 30f) / 30f * 10f;
-
m_CurrentStage = LaunchStage.ConfigInit;
- duration = Mathf.Max(0.1f, expectTime);
+ duration = Mathf.Max(0.5f, expectTime);
threshold = Application.platform == RuntimePlatform.WindowsEditor ? 1f : 0.9f;
LaunchPostProcess.Instance.Begin();
@@ -863,44 +854,28 @@
protected set { LocalSave.SetFloat("LaunchFadeOutTask_ExpectTime", value); }
}
- bool launchBackGroundLoadedOk = false;
- bool openBackGround = false;
-
public override void Begin()
{
m_CurrentStage = LaunchStage.Complete;
- duration = Mathf.Max(0.1f, expectTime);
+ duration = Mathf.Max(0.5f, expectTime);
LuaUtility.Instance.Init();
CSharpCallLua.Init();
ShaderUtility.WarmUpAll();
SpeechTranslate.Instance.RequestGetToken();
UI3DModelExhibition.CreateStage();
-
+ WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
var launchWin = WindowCenter.Instance.Get<LaunchWin>();
if (launchWin != null)
{
launchWin.FadeOut();
}
-
- UILoader.LoadWindowAsync("LaunchBackGroundWin",
- (bool ok, UnityEngine.Object @object) =>
- {
- if (ok)
- {
- launchBackGroundLoadedOk = true;
- }
- });
}
public override void End()
{
expectTime = timer;
DebugEx.LogFormat("{0}鎵ц鏃堕暱锛歿1}锛�", this.GetType().Name, timer);
- if (!openBackGround)
- {
- WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
- }
var launchBackGroundWin = WindowCenter.Instance.Get<LaunchBackGroundWin>();
launchBackGroundWin.transform.SetAsFirstSibling();
@@ -913,15 +888,6 @@
return;
}
timer += Time.deltaTime;
-
- if (!openBackGround)
- {
- if (launchBackGroundLoadedOk)
- {
- WindowCenter.Instance.Open<LaunchBackGroundWin>();
- openBackGround = true;
- }
- }
if (timer >= expectTime)
{
@@ -973,12 +939,14 @@
public struct ProgressInfo
{
public LaunchStage stage;
+ public int step;
public float totalProgress;
public float partProgress;
- public ProgressInfo(LaunchStage stage, float totalProgress, float partProgress)
+ public ProgressInfo(LaunchStage stage, int step, float totalProgress, float partProgress)
{
this.stage = stage;
+ this.step = step;
this.totalProgress = totalProgress;
this.partProgress = partProgress;
}
--
Gitblit v1.8.0