using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; using TMPro; public class ResourceRemover : MonoBehaviour { [SerializeField] private int _rock; [SerializeField] private int _wood; [SerializeField] private int _food; [SerializeField] private TextMeshProUGUI _text; private ResourceManager _resourceManager; // Start is called before the first frame update void Start() { _resourceManager = ResourceManager.Instance; } // Update is called once per frame void Update() { ChangeAvailability(); } private void ChangeAvailability() { //checks if player has enough resources then chooses state of button's availability if (_resourceManager.EnoughFor(_rock, _wood, _food)) { if (_text.color == Color.red) { _text.color = Color.green; Debug.Log("Changed to green..."); } } else if (_text.color == Color.green) { _text.color = Color.red; Debug.Log("Changed to red..."); } } public void Remove() { if (_text.color == Color.green) { Debug.Log("Removed items..."); _resourceManager.Remove(_rock, _wood, _food); } } }