using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; public class ResourceRemover : MonoBehaviour { [SerializeField] private int _rock; [SerializeField] private int _wood; [SerializeField] private int _food; [SerializeField] private Button _button; [SerializeField] private TextField _text; private ResourceManager _resourceManager; // Start is called before the first frame update void Start() { _resourceManager = ResourceManager.getInstance(); _button.clicked += () => { //Will remove resources as well as execute placement action defined in the Editors _resourceManager.Remove(_rock, _wood, _food); }; } // 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 StyleColor textColor = _text.style.color; if (_resourceManager.EnoughFor(_rock, _wood, _food) && textColor == Color.red) { textColor = Color.green; } else if (textColor == Color.green) { textColor = Color.red; } } }