This commit is contained in:
2023-01-16 08:19:32 +05:30
parent 122f60bdda
commit fe14f582b9
4 changed files with 139 additions and 18 deletions

View File

@@ -7,7 +7,6 @@ public class TimeAliveMoney : MonoBehaviour
public TMP_Text moneyText;
public TMP_Text totalMoneyText;
public Player player;
private bool isAlive = true;
private float timeAlive = 0f;
private float totalMoneyEarned = 0f;
@@ -19,7 +18,7 @@ public class TimeAliveMoney : MonoBehaviour
void Update()
{
if (player.gameStarted && isAlive == true) {
if (player.gameStarted && player.isAlive == true) {
timeAlive += Time.deltaTime;
float earnedMoney = timeAlive * moneyPerSecond;
if (moneyText != null)
@@ -29,7 +28,6 @@ public class TimeAliveMoney : MonoBehaviour
public void OnPlayerDeath()
{
isAlive = false;
totalMoneyEarned += timeAlive * moneyPerSecond;
SaveMoney();
timeAlive = 0f;