Collectables online, Main hall Join
This commit is contained in:
27
Assets/Game/Scripts/CollectBtn.cs
Normal file
27
Assets/Game/Scripts/CollectBtn.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CollectBtn : MonoBehaviour
|
||||
{
|
||||
public DateTime lastCollected;
|
||||
public float productionRate;
|
||||
public double collectableAmount;
|
||||
public Button btn;
|
||||
public TMP_Text txt;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
collectableAmount=((DateTime.Now - lastCollected).TotalSeconds * productionRate);
|
||||
txt.text = ((int)collectableAmount).ToString();
|
||||
|
||||
btn.interactable = collectableAmount > 1;
|
||||
}
|
||||
|
||||
public void Set(DateTime _lastCollected, float _productionRate){
|
||||
lastCollected = _lastCollected;
|
||||
productionRate=_productionRate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user