备份CatanBuilding瘦身独立工程
This commit is contained in:
68
Assets/Scripts/UI/Home/HomeBtnOneOnePack.cs
Normal file
68
Assets/Scripts/UI/Home/HomeBtnOneOnePack.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HomeBtnOneOnePack : MonoBehaviour, IUIRedPoint
|
||||
{
|
||||
public const string redKey = "Home.OneOne";
|
||||
Image redpoint;
|
||||
Button btn_enter;
|
||||
TMP_Text text_time;
|
||||
FishingEventData fishingEventData;
|
||||
private void Awake()
|
||||
{
|
||||
fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
btn_enter = GetComponent<Button>();
|
||||
redpoint = transform.Find("redpoint").GetComponent<Image>();
|
||||
text_time = transform.Find("text_time").GetComponent<TMP_Text>();
|
||||
if (fishingEventData.Pack1A1Data == null || fishingEventData.Pack1A1Data.index >= 2)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
SetEndTime();
|
||||
RedPointManager.Instance.AddRedPoint(redKey, this);
|
||||
redpoint.enabled = RedPointManager.Instance.GetRedPointState(redKey);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_enter.onClick.AddListener(async () => await UIManager.Instance.GetUIAsync(UITypes.GiftPopupPanel_10));
|
||||
}
|
||||
public void SetRedPointState(bool state)
|
||||
{
|
||||
redpoint.enabled = state;
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
RedPointManager.Instance.RemoveRedPoint(redKey);
|
||||
}
|
||||
|
||||
void SetEndTime()
|
||||
{
|
||||
DateTime endTime = fishingEventData.GetEvent1A1EndTime();
|
||||
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
double seconds = now.TotalSeconds;
|
||||
if (seconds < 1)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AttachTimer((float)seconds,
|
||||
() => { gameObject.SetActive(false); },
|
||||
(elapsed) =>
|
||||
{
|
||||
now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}, useRealTime: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user