Ader Alisma 01 5d9f4d5a96 Ajout de Unity.TestMeshPro au GameAssembly
Permet d'utiliser TextMeshPro dans le code

Déplacé les script liés à la gestion de ressources dans le répertoire Script/Resource
2023-05-27 10:23:59 -04:00

69 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
/// <summary>
/// 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
/// </summary>
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);
}
}
}