using System; using TMPro; using UnityEngine; using UnityEngine.UI; public class Die : MonoBehaviour { private int _result = 0; [SerializeField] private Button dieButton = null; // assign in the editor public event EventHandler DieClicked; private void Start() { dieButton.onClick.AddListener(() => { DiePressed();}); } public void SetResult(int result) { _result = result; gameObject.GetComponentInChildren().text = _result.ToString(); } public int GetResult() { return _result; } public void ClearDie() { gameObject.GetComponent().text = String.Empty; } public void DieBeingUsed(bool isFirstPair, bool isPairComplete) { if (isPairComplete) { // Signify that both dice have been selected DieSelectedAndPairComplete(); } else { // Signify that the die is selected but the pair is not complete DieSelectedButPairNotComplete(); } } private void DiePressed() { DieClicked?.Invoke(this, this); } private void DieSelectedButPairNotComplete() { gameObject.GetComponent().enabled = true; } private void DieSelectedAndPairComplete() { gameObject.GetComponent().color = ColorHelper.AddColorTint(gameObject.GetComponent().color, ColorHelper.OkayGreen, 0.5f); } }