//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, September 05, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using TableConfig;
|
|
namespace Snxxz.UI
|
{
|
|
public class LaunchWin : Window
|
{
|
[SerializeField] UIAlphaTween m_AlphaTween;
|
[SerializeField] Image m_BackGround;
|
[SerializeField] RectTransform m_AndroidProgressContainer;
|
[SerializeField] SmoothSlider m_ProgressSlider;
|
[SerializeField] Text m_Progress;
|
[SerializeField] RectTransform m_IosProgressContainer;
|
[SerializeField] Text m_IosProgressTip;
|
[SerializeField] Text m_BuildTime;
|
[SerializeField] Text m_Version;
|
[SerializeField] Button m_UserHelp;
|
|
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 = BuiltInLoader.LoadSprite("Launch");
|
m_BackGround.overrideSprite = sprite;
|
}
|
|
protected override void AddListeners()
|
{
|
if (m_UserHelp)
|
{
|
m_UserHelp.SetListener(OpenUserHelp);
|
}
|
}
|
|
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);
|
m_BuildTime.text = VersionConfig.Get().debugVersion ? VersionConfig.Get().buildTime : "";
|
|
if (m_UserHelp)
|
{
|
var appId = VersionConfig.Get().appId;
|
var branch = VersionConfig.Get().branch;
|
m_UserHelp.gameObject.SetActive(ContactConfig.GetConfig(appId, branch) != null);
|
}
|
|
if (Application.platform == RuntimePlatform.IPhonePlayer)
|
{
|
m_AndroidProgressContainer.gameObject.SetActive(false);
|
m_IosProgressContainer.gameObject.SetActive(true);
|
m_IosProgressTip.text = Language.GetFromLocal(30);
|
}
|
else
|
{
|
m_AndroidProgressContainer.gameObject.SetActive(true);
|
m_IosProgressContainer.gameObject.SetActive(false);
|
m_Progress.text = VersionUtility.Instance.IsShangGu() ? "" : 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 (Application.platform == RuntimePlatform.IPhonePlayer)
|
{
|
m_IosProgressContainer.gameObject.SetActive(Launch.currentStage != Launch.LaunchStage.DownLoad);
|
var remainder = ((int)Time.time) % 3;
|
var dot = remainder == 0 ? "." : remainder == 1 ? ".." : "...";
|
m_IosProgressTip.text = StringUtility.Contact(Language.GetFromLocal(30), dot);
|
}
|
else
|
{
|
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 = VersionUtility.Instance.IsShangGu() ? stepDescription :
|
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());
|
}
|
}
|
|
}
|
|
private void OpenUserHelp()
|
{
|
WindowCenter.Instance.OpenFromLocal<UserHelpWin>();
|
}
|
|
}
|
}
|
|
|
|
|
|