先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
90 lines
3.0 KiB
C#
90 lines
3.0 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using System;
|
|
using TMPro;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class HomeBtnEventPack : MonoBehaviour
|
|
{
|
|
private EventPackData _epd;
|
|
private FishingEvent _currentEvent;
|
|
private Tables _tables;
|
|
private TMP_Text _timeText;
|
|
private Button _btn;
|
|
private EventPackManager _epm;
|
|
private IDisposable _timer;
|
|
private TimeSpan RemainingTime
|
|
{
|
|
get
|
|
{
|
|
return DateTime.Parse((_currentEvent.TimeDefinition as LimitedTime).EndTime)
|
|
- ZZTimeHelper.UtcNow();
|
|
}
|
|
}
|
|
private void Awake()
|
|
{
|
|
_btn = GetComponent<Button>();
|
|
_timeText = transform.Find("text_time").GetComponent<TMP_Text>();
|
|
_tables = GContext.container.Resolve<Tables>();
|
|
_epd = GContext.container.Resolve<EventPackData>();
|
|
//Debug.Log($"button: {_epd.CurrentEventID}");
|
|
|
|
if (_epd.CurrentEventID == 0)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
_currentEvent = _tables.TbFishingEvent.DataMap[_epd.CurrentEventID];
|
|
var et = DateTime.Parse((_currentEvent.TimeDefinition as LimitedTime).EndTime);
|
|
var st = DateTime.Parse((_currentEvent.TimeDefinition as LimitedTime).StartTime);
|
|
if (ZZTimeHelper.UtcNow() < st || ZZTimeHelper.UtcNow() >= et)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
}
|
|
private void Start()
|
|
{
|
|
//Debug.Log("<color=red>get epd</color>");
|
|
//_epd.UpdateData();
|
|
if (_epd == null || _epd.CurrentEventID == 0)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
if (GContext.container.Resolve<IUserService>().CreateTotalSeconds()
|
|
< int.Parse(_currentEvent.ConditionList[0].Param[0]) * 3600
|
|
|| GContext.container.Resolve<PlayerData>().lv
|
|
< int.Parse(_currentEvent.ConditionList[1].Param[0]))
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
_epm = _tables.TbEventPackManager.DataMap[_currentEvent.RedirectID];
|
|
gameObject.SetActive(RemainingTime.TotalSeconds > 0);
|
|
//Debug.Log(_epd.PurchaseCount);
|
|
if (RemainingTime.TotalSeconds <= 0 || _epd.PurchaseCount >= _epm.MaxCount)
|
|
gameObject.SetActive(false);
|
|
_btn.onClick.AddListener(() => _ = UIManager.Instance.ShowUI(UITypes.GiftPopupPanel_9));
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
_timeText.text = ConvertTools.ConvertTime2(TimeSpan.FromSeconds(RemainingTime.TotalSeconds));
|
|
_timer = Observable.Interval(TimeSpan.FromSeconds(1.0))
|
|
.Subscribe(_ =>
|
|
{
|
|
_timeText.text = ConvertTools.ConvertTime2(RemainingTime);
|
|
if (RemainingTime.TotalSeconds <= 0 || _epd.PurchaseCount >= _epm.MaxCount)
|
|
gameObject.SetActive(false);
|
|
});
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
_timer?.Dispose();
|
|
}
|
|
}
|