Added roll dice button
This commit is contained in:
parent
d04624edfd
commit
dbef10d80a
10 changed files with 472 additions and 82 deletions
|
|
@ -3,15 +3,25 @@ using TMPro;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public enum DiceColor
|
||||
{
|
||||
Black,
|
||||
White,
|
||||
}
|
||||
|
||||
public class Die : MonoBehaviour
|
||||
{
|
||||
public DiceColor color;
|
||||
private int _result = 0;
|
||||
[SerializeField] private Button dieButton = null; // assign in the editor
|
||||
[SerializeField] private Button dieButton; // assign in the editor
|
||||
private Color originalColor;
|
||||
public event EventHandler<Die> DieClicked;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
dieButton.onClick.AddListener(() => { DiePressed();});
|
||||
|
||||
originalColor = gameObject.GetComponent<Image>().color;
|
||||
}
|
||||
|
||||
public void SetResult(int result) {
|
||||
|
|
@ -24,8 +34,9 @@ public class Die : MonoBehaviour
|
|||
return _result;
|
||||
}
|
||||
|
||||
public void ClearDie() {
|
||||
gameObject.GetComponent<TextMeshProUGUI>().text = String.Empty;
|
||||
public void ResetDie()
|
||||
{
|
||||
gameObject.GetComponent<Image>().color = originalColor;
|
||||
}
|
||||
|
||||
public void DieBeingUsed(bool isFirstPair, bool isPairComplete)
|
||||
|
|
@ -54,6 +65,7 @@ public class Die : MonoBehaviour
|
|||
|
||||
private void DieSelectedAndPairComplete()
|
||||
{
|
||||
gameObject.GetComponent<Outline>().enabled = false;
|
||||
gameObject.GetComponent<Image>().color =
|
||||
ColorHelper.AddColorTint(gameObject.GetComponent<Image>().color, ColorHelper.OkayGreen, 0.5f);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue