using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class LoadingWin : UIBase
|
{
|
protected int currentProgress = 0;
|
protected int targetProgress = 0;
|
|
// [SerializeField] UIAlphaTween m_AlphaTween;
|
[SerializeField] Image m_BackGround;
|
[SerializeField] SmoothSlider m_PartProgressSlider;
|
[SerializeField] SmoothSlider m_TotalProgressSlider;
|
[SerializeField] Text m_StageDescription;
|
[SerializeField] Text m_Version;
|
// [SerializeField] Button m_UserHelp;
|
|
protected List<Sprite> backGrounds = new List<Sprite>();
|
|
protected float backGroundTimer = 0f;
|
protected int backGroundIndex = 0;
|
|
protected override void InitComponent()
|
{
|
base.InitComponent();
|
|
if (Application.isEditor)
|
{
|
if (m_BackGround.overrideSprite == null)
|
{
|
var sprite = BuiltInLoader.LoadSprite("Launch_1");
|
m_BackGround.overrideSprite = sprite;
|
}
|
}
|
else
|
{
|
if (backGrounds.Count <= 0)
|
{
|
for (var i = 0; i < 3; i++)
|
{
|
var sprite = BuiltInLoader.LoadSprite(StringUtility.Contact("Launch_", i + 1));
|
if (sprite != null)
|
{
|
backGrounds.Add(sprite);
|
}
|
}
|
|
m_BackGround.overrideSprite = backGrounds[0];
|
}
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
base.OnPreOpen();
|
currentProgress = targetProgress = 0;
|
Refresh();
|
//打包版本 + 功能版本 + 语言ID
|
m_Version.text = LoginManager.Instance.GetVersionStr();
|
}
|
|
protected override void OnPreClose()
|
{
|
base.OnPreClose();
|
}
|
|
public override void Refresh()
|
{
|
base.Refresh();
|
UpdateProgress();
|
}
|
|
public void SetProgress(float value, bool directly = false)
|
{
|
if (directly)
|
{
|
currentProgress = targetProgress = Mathf.Min((int)(value * 100), 100);
|
UpdateProgress();
|
}
|
else
|
{
|
targetProgress = Mathf.Min((int)(value * 100), 100);
|
}
|
}
|
|
protected void UpdateProgress()
|
{
|
// Debug.LogErrorFormat("cur : {0} / target {1}", currentProgress, targetProgress);
|
if (currentProgress < targetProgress)
|
{
|
currentProgress = (int)Mathf.Lerp(currentProgress, targetProgress, 0.1f);
|
m_TotalProgressSlider.value = currentProgress / 100f;
|
m_PartProgressSlider.value = currentProgress / 100f;
|
}
|
else
|
{
|
m_TotalProgressSlider.value = currentProgress / 100f;
|
m_PartProgressSlider.value = currentProgress / 100f;
|
}
|
CopiedLogic_UpdateProgress();
|
}
|
|
private void CopiedLogic_UpdateProgress()
|
{
|
// 暂留接口
|
|
// 好像都不应该在这里写东西了
|
// m_TotalProgressSlider跟m_PartProgressSlider都有自己新的逻辑
|
// m_StageDescription有固定的文字
|
|
// iOS如果不是download那也都是隐藏的 这里肯定不会有download的 所以就不搬了
|
}
|
|
protected void LateUpdate()
|
{
|
UpdateProgress();
|
CopiedLogic_LateUpdate();
|
}
|
|
private void CopiedLogic_LateUpdate()
|
{
|
backGroundTimer += Time.deltaTime;
|
if (backGroundTimer >= 3f)
|
{
|
backGroundTimer -= 3f;
|
if (backGrounds.Count > 1)
|
{
|
m_BackGround.overrideSprite = backGrounds[(++backGroundIndex) % backGrounds.Count];
|
}
|
|
// 考虑在这里做这个描述的切换 或者根据图片来做提示词
|
// m_StageDescription.text = "";
|
}
|
}
|
|
public void SetData(LaunchWinData _launchWinData)
|
{
|
backGroundTimer = _launchWinData.backGroundTimer;
|
backGroundIndex = _launchWinData.backGroundIndex;
|
m_BackGround.overrideSprite = _launchWinData.sprite;
|
backGrounds = _launchWinData.sprites;
|
m_StageDescription.text = Language.GetFromLocal(44);//最后Completed一定是这个 考虑要不要塞入LaunchWinData..
|
}
|
}
|