//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, September 05, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class LaunchWin : Window
|
{
|
[SerializeField] UIAlphaTween m_AlphaTween;
|
[SerializeField] Image m_BackGround;
|
[SerializeField] SmoothSlider m_ProgressSlider;
|
[SerializeField] Text m_Progress;
|
[SerializeField] Text m_BuildTime;
|
[SerializeField] Text m_Version;
|
|
bool assetBuildTimeShowed = false;
|
|
string stepDescription = string.Empty;
|
|
float refProgress = 0f;
|
float behaviourProgress = 0f;
|
float trueProgress = 0f;
|
|
float timer = 0.1f;
|
float interval = 0.1f;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
var sprite = Resources.Load<Sprite>("UI/Sprites/Launch");
|
m_BackGround.overrideSprite = sprite;
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
refProgress = 0f;
|
behaviourProgress = 0f;
|
trueProgress = 0f;
|
m_ProgressSlider.ResetValue(0f);
|
m_AlphaTween.SetStartState();
|
|
m_Version.text = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex);
|
if (VersionConfig.Get().debugVersion)
|
{
|
m_BuildTime.text = VersionConfig.Get().buildTime;
|
}
|
else
|
{
|
m_BuildTime.text = "";
|
}
|
|
m_Progress.text = StringUtility.Contact(0, "%");
|
|
UpdateLoadingProgress(Launch.currentStage, Launch.progress);
|
|
Launch.progressEvent += UpdateLoadingProgress;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
Launch.progressEvent -= UpdateLoadingProgress;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
public void FadeOut()
|
{
|
m_AlphaTween.Play();
|
}
|
|
void UpdateLoadingProgress(Launch.LaunchStage _stage, float _progress)
|
{
|
trueProgress = Mathf.Max(_progress, behaviourProgress);
|
switch (_stage)
|
{
|
case Launch.LaunchStage.AssetCopy:
|
stepDescription = Language.GetFromLocal(14);
|
break;
|
case Launch.LaunchStage.ClientVersion:
|
stepDescription = Language.GetFromLocal(15);
|
break;
|
case Launch.LaunchStage.DownLoad:
|
stepDescription = Language.GetFromLocal(16);
|
break;
|
case Launch.LaunchStage.ConfigLoad:
|
stepDescription = Language.GetFromLocal(17);
|
break;
|
}
|
|
}
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
if (trueProgress > 0.9599f)
|
{
|
behaviourProgress = Mathf.Clamp01(behaviourProgress + Time.deltaTime * 0.2f);
|
}
|
else
|
{
|
behaviourProgress = Mathf.SmoothDamp(behaviourProgress, trueProgress, ref refProgress, 0.2f);
|
}
|
|
m_ProgressSlider.value = behaviourProgress;
|
m_Progress.text = StringUtility.Contact(stepDescription, Mathf.RoundToInt(behaviourProgress * 100), "%");
|
|
if (!assetBuildTimeShowed && AssetVersionUtility.assetsBuildTime != DateTime.MinValue)
|
{
|
assetBuildTimeShowed = true;
|
var totalMinute = (int)(AssetVersionUtility.assetsBuildTime - new DateTime(2018, 1, 1)).TotalMinutes;
|
m_Version.text = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex, "_", totalMinute.ToString());
|
}
|
}
|
|
|
}
|
}
|
|
|
|
|
|