using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; /// /// Gère le retrait de ressources et l'état du bouton /// Si les ressources nécessaires sont atteints, ce script change la disponibilité du bouton /// et vice-versa /// 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 changes the state of button's availability if (_resourceManager.EnoughFor(_rock, _wood, _food)) { if (_text.color != Color.green) { _text.color = Color.green; Debug.Log("Changed to green..."); } } else if (_text.color != Color.red) { _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); } } }