using UnityEngine; using UnityEngine.UI; public class ResourceManager : MonoBehaviour { public static ResourceManager Instance { get; private set; } public int playerScore; public int enemyScore; public Text pointsText; public Text enemyPointsText; public TerritoryUI territoryUI; private void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); return; } Instance = this; } private void Start() { UpdateScoreUI(); } public void AddPlayerPoints(int amount) { playerScore += Mathf.Max(0, amount); UpdateScoreUI(); } public void AddEnemyPoints(int amount) { enemyScore += Mathf.Max(0, amount); UpdateScoreUI(); } private void UpdateScoreUI() { if (pointsText != null) { pointsText.text = "Player Points: " + playerScore; } if (enemyPointsText != null) { enemyPointsText.text = "Enemy Points: " + enemyScore; } if (territoryUI != null) { territoryUI.SetScore(playerScore, enemyScore); } } }