using Assets.Scripts; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using DG.Tweening; class GameRoomDownloadTask : MonoBehaviour { public GameObject btn; public Slider slider; public GameObject icon; public GameObject done; public GameObject doneTxt; public CanvasGroup canvasGroup; private GameObject modal; private Text fileNameText; public int RoomId { get; set; } public string RouteName { get; set; } public string FileName { get; set; } private void Start() { UIManager.AddEvent(btn, EventTriggerType.PointerClick, (e) => { if (!modal.transform.parent.Find("MapList").gameObject.activeSelf) { modal.SetActive(true); modal.GetComponent().ComeIntoStep2(FileName, RouteName); } else { modal.SetActive(false); } //transform.parent.parent.parent.gameObject.SetActive(false); }); } public void Init(int roomId,string fileName,string routeName,GameObject downloadPanel) { modal = downloadPanel; fileNameText = transform.Find("Text").GetComponent(); RoomId = roomId; RouteName = routeName; fileNameText.text = routeName; FileName = fileName; } private void Update() { if (Loom.DownloadStack.ContainsKey(FileName)) { UpdateProcess(Loom.DownloadStack[FileName].Process); } } public void UpdateProcess(float process) { slider.value = process; if (process >= 1) { done.SetActive(true); doneTxt.SetActive(true); icon.SetActive(false); Loom.DownloadStack.Remove(FileName); canvasGroup.DOFade(0, 2).onComplete += () => { slider.gameObject.SetActive(false); gameObject.Destroy(); Loom.DownloadStack.Remove(FileName); }; } } public void Dispose() { gameObject.SetActive(false); } }