先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
107 lines
3.3 KiB
C#
107 lines
3.3 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UniRx;
|
|
using TMPro;
|
|
using System;
|
|
|
|
public class FishingDownLoadPopupPanel : MonoBehaviour
|
|
{
|
|
Button btn_close;
|
|
ILoadResourceService loadResourceService;
|
|
Image bar;
|
|
TMP_Text text_info;
|
|
IDisposable disposable;
|
|
GameObject btn_1;
|
|
GameObject btn_2;
|
|
Button btn_confrim;
|
|
Button btn_back2;
|
|
Button btn_confrim2;
|
|
public Action OnBack;
|
|
public Action OnConfrim;
|
|
|
|
float progress;
|
|
private void Awake()
|
|
{
|
|
loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
|
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
|
bar = transform.Find("root/bg_bar/bar").GetComponent<Image>();
|
|
text_info = transform.Find("root/text_info").GetComponent<TMP_Text>();
|
|
btn_1 = transform.Find("root/btn_1").gameObject;
|
|
btn_2 = transform.Find("root/btn_2").gameObject;
|
|
btn_confrim = transform.Find("root/btn_1/btn_confrim/btn_green").GetComponent<Button>();
|
|
btn_back2 = transform.Find("root/btn_2/btn_back/btn_green").GetComponent<Button>();
|
|
btn_confrim2 = transform.Find("root/btn_2/btn_confrim/btn_green").GetComponent<Button>();
|
|
}
|
|
public void Start()
|
|
{
|
|
btn_close.onClick.AddListener(OnClickClose);
|
|
btn_confrim.onClick.AddListener(OnClickConfrim);
|
|
btn_back2.onClick.AddListener(OnClickBack);
|
|
btn_confrim2.onClick.AddListener(OnClickConfrim);
|
|
Init();
|
|
}
|
|
public void SetBtn(Action OnBack, Action OnConfrim)
|
|
{
|
|
this.OnBack = OnBack;
|
|
this.OnConfrim = OnConfrim;
|
|
btn_1.SetActive(OnBack == null);
|
|
btn_2.SetActive(OnBack != null);
|
|
}
|
|
void OnClickBack()
|
|
{
|
|
OnBack?.Invoke();
|
|
OnClickClose();
|
|
}
|
|
async void Init()
|
|
{
|
|
bool isCanEnter = await loadResourceService.Load(loadResourceService.curName);
|
|
text_info.text = LocalizationMgr.GetFormatTextValue("UI_FishingDownLoadPopupPanel_1", 0);
|
|
if (isCanEnter)
|
|
{
|
|
bar.fillAmount = 1;
|
|
}
|
|
else
|
|
{
|
|
bar.fillAmount = 0;
|
|
disposable = GContext.OnEvent<LoadProgressEvent>().Subscribe(OnLoadProgress);
|
|
}
|
|
}
|
|
void OnClickConfrim()
|
|
{
|
|
if (progress > 1)
|
|
{
|
|
OnConfrim?.Invoke();
|
|
}
|
|
OnClickClose();
|
|
}
|
|
void OnClickClose()
|
|
{
|
|
OnBack = null;
|
|
OnConfrim = null;
|
|
UIManager.Instance.DestroyUI(UITypes.FishingDownLoadPopupPanel);
|
|
}
|
|
private const long byte2mb = 1024 * 1024;
|
|
void OnLoadProgress(LoadProgressEvent e)
|
|
{
|
|
if (e.name == loadResourceService.curName)
|
|
{
|
|
progress = e.progress;
|
|
float curprogress = e.progress;
|
|
if (curprogress > 1)
|
|
{
|
|
curprogress = 1f;
|
|
}
|
|
var progressStr = $"\n{(curprogress * e.totalDownloadSize / byte2mb).ToString("0.0")}MB/{(e.totalDownloadSize / byte2mb).ToString("0.0")}MB ({curprogress.ToPercentageString()})";
|
|
text_info.text = LocalizationMgr.GetFormatTextValue("UI_FishingDownLoadPopupPanel_1", progressStr);
|
|
bar.fillAmount = curprogress;
|
|
}
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
disposable?.Dispose();
|
|
disposable = null;
|
|
}
|
|
}
|