先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
108 lines
3.5 KiB
C#
108 lines
3.5 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class HomeBuffItem : MonoBehaviour
|
|
{
|
|
Button btn_buff;
|
|
TMP_Text buff_time;
|
|
Image buff_icon;
|
|
Timer buff_timer;
|
|
|
|
public FishBuffTimeData buffTimeData;
|
|
cfg.FishBuff buff;
|
|
//buff_tips tips_buff;
|
|
private void Init()
|
|
{
|
|
btn_buff = GetComponent<Button>();
|
|
btn_buff.onClick.AddListener(OnClick);
|
|
}
|
|
public void InitPanel(FishBuffTimeData buffTimeData, string iconName, RectTransform rectTransform)
|
|
{
|
|
this.buffTimeData = buffTimeData;
|
|
buff_time = transform.Find("Ani_Container/text_time").GetComponent<TMP_Text>();
|
|
buff_icon = transform.Find("Ani_Container/icon").GetComponent<Image>();
|
|
if (rectTransform != null)
|
|
{
|
|
RectTransform rect = buff_icon.GetComponent<RectTransform>();
|
|
rect.anchoredPosition = rectTransform.anchoredPosition;
|
|
rect.sizeDelta = rectTransform.sizeDelta;
|
|
}
|
|
InitBuff(iconName);
|
|
}
|
|
async void OnClick()
|
|
{
|
|
GameObject go = await UIManager.Instance.ShowUI(UITypes.FishingBuffInfoPopupPanel);
|
|
FishingBuffInfoPopupPanel fishingBuffInfoPopupPanel = go.GetComponent<FishingBuffInfoPopupPanel>();
|
|
fishingBuffInfoPopupPanel.InitPanel(buffTimeData);
|
|
//item_tips _common_tips = await item_tips.Show();
|
|
//if (_common_tips == null)
|
|
//{
|
|
// return;
|
|
//}
|
|
//tips_buff = _common_tips.ShowBuff(transform.position, buff);
|
|
}
|
|
async void PlayBuff()
|
|
{
|
|
buffTimeData.isEnd = buffTimeData.addDown == 0;
|
|
if (buffTimeData.isEnd)
|
|
{
|
|
btn_buff.gameObject.SetActive(false);
|
|
GContext.Publish(new EventHomeBuffPanelRefresh());
|
|
}
|
|
await Awaiters.Seconds(1f);
|
|
GContext.Publish(new BuffChangeEvent());
|
|
}
|
|
void InitBuff(string iconName)
|
|
{
|
|
if (btn_buff == null)
|
|
{
|
|
Init();
|
|
}
|
|
btn_buff.gameObject.SetActive(buffTimeData != null);
|
|
if (buffTimeData != null)
|
|
{
|
|
buff = GContext.container.Resolve<cfg.Tables>().TbFishBuff.GetOrDefault(buffTimeData.buffID);
|
|
if (string.IsNullOrEmpty(iconName))
|
|
{
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(buff_icon, buff.Icon);
|
|
}
|
|
else
|
|
{
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(buff_icon, iconName);
|
|
}
|
|
var buffTime = buffTimeData.buffEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
buff_timer?.Cancel();
|
|
buffTime.Add(TimeSpan.FromSeconds(-buffTimeData.addDown));
|
|
buff_time.text = ConvertTools.ConvertTime2(buffTime);
|
|
|
|
double seconds = buffTime.TotalSeconds;
|
|
buff_timer = this.AttachTimer((float)seconds,
|
|
() => { PlayBuff(); },
|
|
(elapsed) =>
|
|
{
|
|
if (buffTimeData.isEnd)
|
|
{
|
|
buff_timer?.Cancel();
|
|
PlayBuff();
|
|
return;
|
|
}
|
|
TimeSpan now = buffTimeData.buffEndTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
now.Add(TimeSpan.FromSeconds(-buffTimeData.addDown));
|
|
buff_time.text = ConvertTools.ConvertTime2(now);
|
|
|
|
}, useRealTime: true);
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
buff_timer?.Cancel();
|
|
buff_timer = null;
|
|
}
|
|
}
|
|
|