73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
using Manager;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
public class UILoad : MonoBehaviour
|
|
{
|
|
public Slider progressBar;
|
|
public Text progressText;
|
|
|
|
private IEnumerator Start()
|
|
{
|
|
Scene scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
|
|
|
|
|
for (float i = 0; i < 100;)
|
|
{
|
|
i += Random.Range(0.1f, 1.5f);
|
|
progressBar.value = i;
|
|
if (i > 100)
|
|
{
|
|
progressText.text = "99%";
|
|
}
|
|
else
|
|
{
|
|
progressText.text = i + "%";
|
|
}
|
|
yield return new WaitForEndOfFrame();
|
|
}
|
|
|
|
|
|
yield return new WaitForSeconds(1f);
|
|
|
|
if (scene.buildIndex == 1)
|
|
{
|
|
if (!PlayerInfo.Instance.info.BagInfo.ContainsKey(1))
|
|
{
|
|
PlayerInfo.Instance.info.BagInfo.Add(1, 4);
|
|
}
|
|
}
|
|
|
|
if(scene.buildIndex==3)
|
|
{
|
|
UIManager.Instance.Show<EndUI>();
|
|
}
|
|
else
|
|
{
|
|
Manager.SenceManager.Instance.LoadScene(scene.buildIndex + 1);
|
|
CheckMusic(scene.buildIndex + 1);
|
|
Destroy(this.gameObject, 2f);
|
|
}
|
|
}
|
|
private void CheckMusic(int idx)
|
|
{
|
|
switch (idx)
|
|
{
|
|
case 1:
|
|
SoundManager.Instance.PlayMusic(SoundDefine.Map_1Music);
|
|
break;
|
|
case 2:
|
|
SoundManager.Instance.PlayMusic(SoundDefine.Map_2Music);
|
|
break;
|
|
case 3:
|
|
SoundManager.Instance.PlayMusic(SoundDefine.Map_3Music);
|
|
break;
|
|
}
|
|
}
|
|
}
|