added gold mining system in test scene

This commit is contained in:
Lorenzo
2022-04-17 14:16:38 +02:00
parent 62a909795b
commit 7ea15eedf9
10 changed files with 2144 additions and 6541 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class MineScript : MonoBehaviour
{
[HideInInspector] public TMP_Text txt;
[HideInInspector] public TMP_Text gold;
private int goldAmount = 0;
private int totalAmount = 0;
public float refreshTime = 0.2f;
private void Start()
{
StartCoroutine(GetGoldTimer());
}
private IEnumerator GetGoldTimer()
{
while (true) {
yield return new WaitForSeconds(refreshTime);
goldAmount++;
UpdateGold();
}
}
private void UpdateGold()
{
gold.text = goldAmount.ToString();
}
public void CollectGold()
{
totalAmount = goldAmount + totalAmount;
txt.text = totalAmount.ToString();
goldAmount = 0;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5dba27881224bcc41b9ee7727935bdca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -19,4 +19,4 @@ MonoBehaviour:
- name: Production rate
value: 10%
price: 8500
description: This is a mine
description: This is a gold mine