Ajout de ResourceText. Permet de montrer l'inventaire des ressources dynamiquement. Modification de la gestion d'instance dans ResourceManager Changement des boutons pour la version TextMeshPro Debut de la coroutine de ResourceMaker
66 lines
1.4 KiB
C#
66 lines
1.4 KiB
C#
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);
|
|
}
|
|
}
|
|
|
|
|
|
}
|