added gold mining system in test scene
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
42
Assets/Game/Scenes/TestScene/TestSceneScripts/MineScript.cs
Normal file
42
Assets/Game/Scenes/TestScene/TestSceneScripts/MineScript.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dba27881224bcc41b9ee7727935bdca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -19,4 +19,4 @@ MonoBehaviour:
|
||||
- name: Production rate
|
||||
value: 10%
|
||||
price: 8500
|
||||
description: This is a mine
|
||||
description: This is a gold mine
|
||||
|
||||
Reference in New Issue
Block a user