72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
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 FileName { get; set; }
|
|
|
|
private void Start()
|
|
{
|
|
UIManager.AddEvent(btn, EventTriggerType.PointerClick, (e) =>
|
|
{
|
|
modal.SetActive(true);
|
|
transform.parent.parent.parent.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
|
|
public void Init(int roomId,string fileName,GameObject downloadPanel)
|
|
{
|
|
modal = downloadPanel;
|
|
fileNameText = transform.Find("Text").GetComponent<Text>();
|
|
RoomId = roomId;
|
|
fileNameText.text = fileName;
|
|
FileName = fileName;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Loom.DownLoadTaskList.ContainsKey(FileName))
|
|
{
|
|
UpdateProcess(Loom.DownLoadTaskList[FileName]);
|
|
}
|
|
}
|
|
|
|
public void UpdateProcess(float process)
|
|
{
|
|
slider.value = process;
|
|
if (process >= 100)
|
|
{
|
|
done.SetActive(true);
|
|
doneTxt.SetActive(true);
|
|
icon.SetActive(false);
|
|
canvasGroup.DOFade(0, 2).onComplete += () =>
|
|
{
|
|
slider.gameObject.SetActive(false);
|
|
gameObject.Destroy();
|
|
Loom.DownLoadTaskList.Remove(FileName);
|
|
};
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|