using UnityEngine;
using System.Collections;
public class Loading : MonoBehaviour
{
public bool m_IsReset;
public GameObject[] m_CurBgs;
private UI_ViewDur m_Progress;
void Start()
{
if (m_IsReset)
{
PlayerPrefs.SetInt("CurLoadingBg", 0);
}
m_Progress = GetComponent<UI_ViewDur>();
int curBgIndex = PlayerPrefs.GetInt("CurLoadingBg");
int index1 = curBgIndex, index2 = curBgIndex, index3 = curBgIndex;
bool b1 = false, b2 = false, b3 = false;
Debug.Log("当前Idengx" + curBgIndex);
if (curBgIndex != 0)
{
switch (curBgIndex)
{
case 1:
b1 = false;
b2 = true;
b3 = false;
index1 -= 1;
index2 += 0;
index3 += 1;
PlayerPrefs.SetInt("CurLoadingBg", index2+1);//2
break;
case 2:
b1 = false;
b2 = false;
b3 = true;
index1 -= 2;
index2 += -1;
index3 += 0;
PlayerPrefs.SetInt("CurLoadingBg", index3+1);//3
break;
case 3:
b1 = true;
b2 = false;
b3 = false;
index1 -= 3;
index2 += -2;
index3 += -1;
PlayerPrefs.SetInt("CurLoadingBg", index1+1);//1
break;
}
m_CurBgs[index1].SetActive(b1);
m_CurBgs[index2].SetActive(b2);
m_CurBgs[index3].SetActive(b3);
}
else
{
for (int i = 1; i < m_CurBgs.Length + 1; i++)
{
if (m_CurBgs[i - 1].activeSelf)
{
Debug.Log("当前CurLoadingBg=" + i);
PlayerPrefs.SetInt("CurLoadingBg", i);
}
}
}
//StartCoroutine(LoadLevel());
}
public AsyncOperation async;
IEnumerator LoadLevel()
{
//async = Application.LoadLevelAsync(Global.s_Instance.CurLoadSceneName);
async = Application.LoadLevelAsync("moou");
yield return async;
}
public int progress = 0;
public float m_Var = 0;
void Update()
{
if (Random.RandomRange(0, 10) == 1)
{
m_Var += Random.RandomRange(0f, 0.06f);
}
m_Progress.ViewBlood(m_Var);
//m_Progress.ViewBlood(async.progress + 0.1f);
if (m_Var >= 1f)
{
Debug.Log("GIC: " + Global.s_Instance.CurLoadSceneName);
Application.LoadLevel(Global.s_Instance.CurLoadSceneName);
}
//m_Progress.value = async.progress + 0.1f;
// progress = (int)(async.progress * 100);
//Debug.Log(progress);
//Debug.Log(async.progress);
}
}