diff options
author | chai <215380520@qq.com> | 2023-11-26 23:52:30 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-11-26 23:52:30 +0800 |
commit | 626381f061cde0c78564f6336e3131835cf20a5b (patch) | |
tree | d9991d6eda6ae5d7649ac91ecaa3b4dc833cd4c3 /Assembly_CSharp/LevelLoader.cs | |
parent | 0e63c4a2c6dec8dfa260501fb7d73750261ea7b7 (diff) |
* move
Diffstat (limited to 'Assembly_CSharp/LevelLoader.cs')
-rw-r--r-- | Assembly_CSharp/LevelLoader.cs | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/Assembly_CSharp/LevelLoader.cs b/Assembly_CSharp/LevelLoader.cs deleted file mode 100644 index 1698c15..0000000 --- a/Assembly_CSharp/LevelLoader.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System.Collections; -using UnityEngine; -using UnityEngine.SceneManagement; -using UnityEngine.UI; - -public class LevelLoader : MonoBehaviour -{ - public static LevelLoader instance; - - [SerializeField] - private Image circle; - - [SerializeField] - private Text loadingText; - - [SerializeField] - private Text tipText; - - [SerializeField] - private string[] tips; - - private void Awake() - { - instance = this; - } - - private void Start() - { - loadingText.text = ""; - tipText.text = ""; - StartCoroutine(CircleExitStart()); - } - - public void LoadLevel(string sceneName) - { - if (MusicManager.instance != null) - { - MusicManager.instance.FadeOut(2.5f); - } - StartCoroutine(LoadAsyncronously(sceneName)); - } - - private IEnumerator LoadAsyncronously(string sceneName) - { - float num = Mathf.Sqrt(Screen.height * Screen.width) * 1.1f; - Vector2 endSize = new Vector2(2f, 1f) * num * 2f; - Vector2 startSize = new Vector2(0f, 1f) * num * 2f; - circle.rectTransform.sizeDelta = startSize; - Vector3 endPosition = new Vector3((float)Screen.height / 2f, (float)Screen.height / 2f, 0f); - Vector3 startPosition = new Vector3((float)Screen.width * 1.1f, (float)Screen.height / 2f, 0f); - circle.transform.position = startPosition; - float t = 0f; - while (t < 1f) - { - circle.rectTransform.sizeDelta = Vector2.Lerp(startSize, endSize, t); - circle.transform.position = Vector3.Lerp(startPosition, endPosition, t); - t += Time.deltaTime / 1.5f; - yield return null; - } - circle.rectTransform.sizeDelta = endSize; - circle.transform.position = endPosition; - tipText.text = GetTipsText(); - AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName); - operation.allowSceneActivation = false; - float waitFill = 0f; - while (!operation.isDone || waitFill < 1f) - { - waitFill = Mathf.Clamp(waitFill + Time.deltaTime / 3f, 0f, 1f); - float num2 = Mathf.Clamp(operation.progress / 0.9f, 0f, 1f); - if (waitFill >= 1f) - { - operation.allowSceneActivation = true; - } - loadingText.text = GetLoadingText((waitFill * num2 + waitFill) / 2f); - yield return null; - } - } - - private string GetLoadingText(float percent) - { - return "Loading...".Substring(0, (int)Mathf.Round(percent * 10f)); - } - - private string GetTipsText() - { - int num = Random.Range(0, tips.Length); - int @int = PlayerPrefs.GetInt("PreviousTip", 0); - if (num == @int) - { - num = (num + 1) % tips.Length; - } - PlayerPrefs.SetInt("PreviousTip", num); - return tips[num]; - } - - private IEnumerator CircleExitStart() - { - float num = Mathf.Sqrt(Screen.height * Screen.width) * 1.1f; - Vector2 startSize = new Vector2(2f, 1f) * num * 2f; - Vector2 endSize = new Vector2(0f, 1f) * num * 2f; - circle.rectTransform.sizeDelta = startSize; - Vector3 startPosition = new Vector3((float)Screen.height / 2f, (float)Screen.height / 2f, 0f); - Vector3 endPosition = new Vector3((float)(-Screen.width) * 0.1f, (float)Screen.height / 2f, 0f); - circle.transform.position = startPosition; - float t = 0f; - while (t < 1f) - { - circle.rectTransform.sizeDelta = Vector2.Lerp(startSize, endSize, t); - circle.transform.position = Vector3.Lerp(startPosition, endPosition, t); - t += Time.deltaTime / 1.5f; - yield return null; - } - circle.rectTransform.sizeDelta = endSize; - circle.transform.position = endPosition; - } -} |