66 lines
2.3 KiB
C#
66 lines
2.3 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UnlockNewMapPopupPanel : MonoBehaviour
|
|
{
|
|
public Button btn_close;
|
|
TMP_Text text_name;
|
|
buff_tips buff_Tips;
|
|
Animation anim;
|
|
private void Awake()
|
|
{
|
|
anim = GetComponent<Animation>();
|
|
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
|
text_name = transform.Find("map_unlock/text_name").GetComponent<TMP_Text>();
|
|
buff_Tips = transform.Find("map_unlock/buff").GetComponent<buff_tips>();
|
|
}
|
|
private void Start()
|
|
{
|
|
btn_close.onClick.AddListener(OnGoto);
|
|
Show();
|
|
}
|
|
public void Show()
|
|
{
|
|
int mapId = GContext.container.Resolve<FishingData>().MapId;
|
|
MapData data = GContext.container.Resolve<Tables>().TbMapData.GetOrDefault(mapId);
|
|
if (data != null)
|
|
{
|
|
text_name.text = LocalizationMgr.GetText(data.Name_l10n_key);
|
|
}
|
|
BuffDataCenter buffDataCenter = GContext.container.Resolve<BuffDataCenter>();
|
|
var buffTimeData = buffDataCenter.GetMapBuffTimeData(mapId);
|
|
var buff = GContext.container.Resolve<Tables>().TbFishBuff.GetOrDefault(buffTimeData.buffID);
|
|
buff_Tips.InitPanel(buff);
|
|
var buffTime = buffTimeData.buffEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
double seconds = buffTime.TotalSeconds;
|
|
Timer map_buff_timer = this.AttachTimer((float)seconds,
|
|
null,
|
|
(elapsed) =>
|
|
{
|
|
TimeSpan now = buffTimeData.buffEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
if (now.TotalSeconds <= 0)
|
|
{
|
|
map_buff_timer = null;
|
|
return;
|
|
}
|
|
buff_Tips.SetBuffTime(ConvertTools.ConvertTime2(now));
|
|
}, useRealTime: true);
|
|
}
|
|
|
|
async void OnGoto()
|
|
{
|
|
btn_close.enabled = false;
|
|
GContext.Publish(new VibrationData(HapticTypes.Success));
|
|
anim.Play("UnlockNewMap_out");
|
|
GContext.Publish(new CameraAnimatorSpeedEvent());
|
|
await Awaiters.Seconds(2f);
|
|
GContext.Publish(new RestartShowHomeUIEvent());
|
|
UIManager.Instance.DestroyUI(UITypes.UnlockNewMapPopupPanel);
|
|
}
|
|
}
|