备份CatanBuilding瘦身独立工程
This commit is contained in:
38
Assets/Scripts/UI/Home/HomeBtnSelectionPack.cs
Normal file
38
Assets/Scripts/UI/Home/HomeBtnSelectionPack.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using System;
|
||||
using GameCore;
|
||||
using asap.core;
|
||||
public class HomeBtnSelectionPack : MonoBehaviour
|
||||
{
|
||||
private TMP_Text _textTime;
|
||||
private SelectionPackData _selectionPackData;
|
||||
private Button _btn;
|
||||
private void Awake()
|
||||
{
|
||||
_textTime = transform.Find("text_time").GetComponent<TMP_Text>();
|
||||
_btn = GetComponent<Button>();
|
||||
_selectionPackData = GContext.container.Resolve<SelectionPackData>();
|
||||
if (!_selectionPackData.IsPackActivated )
|
||||
gameObject.SetActive( false );
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
_btn.onClick.AddListener(async () => { await UIManager.Instance.ShowUI(UITypes.GiftSelectionPanel); });
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_textTime.text = ConvertTools.ConvertTime2(_selectionPackData.RemainingTime);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ => {
|
||||
_textTime.text = ConvertTools.ConvertTime2(_selectionPackData.RemainingTime);
|
||||
if (_selectionPackData.RemainingTime.TotalSeconds <= 0
|
||||
|| _selectionPackData.PurchaseCount >= _selectionPackData.MaxPurchaseCount)
|
||||
gameObject.SetActive(false); })
|
||||
.AddTo(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user