using System.Collections; using System.Runtime.CompilerServices; using TMPro; using UnityEngine; using UnityEngine.UI; public class LoadingScreen : MonoBehaviour { [SerializeField] GameObject loadingScreen; [SerializeField] TextMeshProUGUI wiseQuote; private bool bIsUILogicSet = false; [SerializeField] Slider progressBar; [SerializeField] GameObject startPlayingButton; [SerializeField] string[] wiseQuotes; private bool bIsTimerOver = false; private void Awake() { //loadingScreen = GameObject.Find("LoadingScreen"); if (startPlayingButton) { startPlayingButton.SetActive(false); } if (loadingScreen) { loadingScreen.SetActive(true); } StartCoroutine(StartTimer(5f)); wiseQuote.text = wiseQuotes[Random.Range(0, wiseQuotes.Length)]; } IEnumerator StartTimer(float duration) { float timer = 0f; progressBar.maxValue = duration; while(timer < duration) { timer += Time.deltaTime; progressBar.value = timer; yield return null; } progressBar.value = duration; bIsTimerOver = true; } private void Update() { if (GameManager.gameManagerInstance.bHasPlayerLanded && !bIsUILogicSet && bIsTimerOver) { startPlayingButton.SetActive(true); bIsUILogicSet = true; } } public void OnStartButtonClick() { loadingScreen.SetActive(false); GameManager.gameManagerInstance.bIsGameStarted = true; } }