Interface d'amélioration s'affiche onClick pour FarmersAssociation Interface n'est présentement pas rétroactive des infos de l'unité
61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class UpgradePlacementButton : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
private Button _button;
|
|
|
|
[SerializeField]
|
|
private Material _outlineMaterial;
|
|
[SerializeField]
|
|
protected UnitCard _unitCardInformation;
|
|
|
|
[SerializeField]
|
|
private TMP_Text _foodLabel;
|
|
[SerializeField]
|
|
private TMP_Text _woodLabel;
|
|
[SerializeField]
|
|
private TMP_Text _rockLabel;
|
|
[SerializeField]
|
|
private GameObject _prefab;
|
|
|
|
|
|
public Button Button => _button;
|
|
public Material OutlineMaterial => _outlineMaterial;
|
|
|
|
void Start()
|
|
{
|
|
_button = GetComponent<Button>();
|
|
_button.enabled = true;
|
|
Debug.Log("Upgrade instantiated...");
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
//_button.interactable = CanUse();
|
|
|
|
//SetTextFor(_foodLabel, _unitCardInformation.Food);
|
|
//SetTextFor(_rockLabel, _unitCardInformation.Rock);
|
|
//SetTextFor(_woodLabel, _unitCardInformation.Wood);
|
|
}
|
|
|
|
private bool CanUse()
|
|
{
|
|
return ResourceManager.Instance.EnoughFor(_unitCardInformation.Rock, _unitCardInformation.Wood, _unitCardInformation.Food);
|
|
}
|
|
|
|
void SetTextFor(TMP_Text label, int value)
|
|
{
|
|
label.transform.parent.gameObject.SetActive(value > 0);
|
|
label.text = "" + value;
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
//Change parent GameObject
|
|
Debug.Log("Upgrade clicked...");
|
|
|
|
}
|
|
} |