5 changed files with 1661 additions and 0 deletions
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2 |
||||
guid: bbed3e9599768a545a8ba8621fc57729 |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 4ebf0c4b9197eee41954dcb1ad3f8fdf |
||||
folderAsset: yes |
||||
DefaultImporter: |
||||
externalObjects: {} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,70 @@
|
||||
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"); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue