using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class EconomyManager : Singleton { private TMP_Text goldText; private int currentGold = 0; const string COIN_AMOUNT_TEXT = "Gold Amount Text"; // Change this to the name of your gold count Text component public GameObject victoryPanel; public TMP_Text victoryGoldCountText; private const int requiredGoldCount = 100; private void Start() { if (goldText == null) { goldText = GameObject.Find(COIN_AMOUNT_TEXT).GetComponent(); } UpdateGoldText(); victoryPanel.SetActive(false); // Ensure the victory panel is hidden at start } public void UpdateCurrentGold() { currentGold += 1; UpdateGoldText(); if (currentGold >= requiredGoldCount) { ShowVictoryPanel(); } } public void ResetGold() { currentGold = 0; UpdateGoldText(); victoryPanel.SetActive(false); // Hide the victory panel on reset } private void UpdateGoldText() { if (goldText != null) { goldText.text = currentGold.ToString("D3"); } } private void ShowVictoryPanel() { if (victoryGoldCountText != null) { victoryGoldCountText.text = currentGold.ToString("D3"); } victoryPanel.SetActive(true); } }