You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 lines
1.6 KiB

using System;
using UnityEngine;
using TMPro;
public class Store : MonoBehaviour
{
#region GameManager
Decimal CurrentBalance = 1.00M;
Decimal BaseStorePrice = 1.00M;
[SerializeField]
private TextMeshProUGUI BalanceText;
#endregion
[SerializeField]
private TextMeshProUGUI StoreCountText;
private int StoreCount = 0;
private Decimal StoreProfit = 0.50M;
private float StoreReset = 4.0f;
private float StoreTime = 0.0f;
bool StoreOpen = false;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
StoreCountText.text = StoreCount.ToString();
BalanceText.text = String.Format("$ {0:C2}", CurrentBalance.ToString());
}
// Update is called once per frame
void Update()
{
if(StoreOpen)
{
StoreTime += Time.deltaTime;
if (StoreTime >= StoreReset)
{
StoreTime = 0.0f;
CurrentBalance += StoreProfit * StoreCount;
BalanceText.text = String.Format("$ {0:C2}", CurrentBalance.ToString());
}
}
}
public void Buy()
{
if(BaseStorePrice > CurrentBalance)
{
Debug.Log("Not enough money");
return;
}
CurrentBalance -= BaseStorePrice;
StoreCount++;
StoreCountText.text = StoreCount.ToString();
BalanceText.text = String.Format("$ {0:C2}", CurrentBalance.ToString());
}
public void OpenStore()
{
StoreOpen = true;
Debug.Log("Store Opened");
}
}