Finished converting to new UI.
This commit is contained in:
parent
f70f89324b
commit
105055b307
37 changed files with 24044 additions and 1227 deletions
|
|
@ -15,13 +15,15 @@ public class Die : MonoBehaviour
|
|||
{
|
||||
public DiceColor color;
|
||||
private int _result = 0;
|
||||
[SerializeField] private Button dieButton; // assign in the editor
|
||||
private Color originalColor;
|
||||
private bool _isClickable = false;
|
||||
private bool _selected = false;
|
||||
private bool _blackDieAbilityUsed = false;
|
||||
public event Action<Die> DieSelected;
|
||||
public event Action<Die> DieUnselected;
|
||||
public event Action<int> DieRollResult;
|
||||
public event Action DieReset;
|
||||
public event Action DieSelectedButPairNotCompleteEvent;
|
||||
public event Action DieSelectedAndPairCompleteEvent;
|
||||
|
||||
private void OnEnable() {
|
||||
GameManager.StateChanged += HandleStateChange;
|
||||
|
|
@ -33,14 +35,9 @@ public class Die : MonoBehaviour
|
|||
StartingBlackDieAbility.AbilitySelected -= HandleOnBlackDieAbilitySelected;
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
dieButton.onClick.AddListener(DiePressed);
|
||||
originalColor = gameObject.GetComponent<Image>().color;
|
||||
}
|
||||
|
||||
public void SetResult(int result) {
|
||||
_result = result;
|
||||
gameObject.GetComponentInChildren<TextMeshProUGUI>().text = _result.ToString();
|
||||
DieRollResult?.Invoke(_result);
|
||||
}
|
||||
|
||||
public int GetResult()
|
||||
|
|
@ -51,8 +48,7 @@ public class Die : MonoBehaviour
|
|||
public void ResetDie() {
|
||||
_selected = false;
|
||||
_blackDieAbilityUsed = false;
|
||||
gameObject.GetComponent<Image>().color = originalColor;
|
||||
gameObject.GetComponent<Outline>().enabled = false;
|
||||
DieReset?.Invoke();
|
||||
}
|
||||
|
||||
public void DieBeingUsed(bool isPairComplete)
|
||||
|
|
@ -69,7 +65,7 @@ public class Die : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void DiePressed()
|
||||
public void DiePressed()
|
||||
{
|
||||
if (!_isClickable || (color == DiceColor.Black && !_blackDieAbilityUsed)) return;
|
||||
|
||||
|
|
@ -86,14 +82,12 @@ public class Die : MonoBehaviour
|
|||
private void DieSelectedButPairNotComplete()
|
||||
{
|
||||
_selected = true;
|
||||
gameObject.GetComponent<Outline>().enabled = true;
|
||||
DieSelectedButPairNotCompleteEvent?.Invoke();
|
||||
}
|
||||
|
||||
private void DieSelectedAndPairComplete() {
|
||||
_selected = true;
|
||||
gameObject.GetComponent<Outline>().enabled = false;
|
||||
gameObject.GetComponent<Image>().color =
|
||||
ColorHelper.AddColorTint(gameObject.GetComponent<Image>().color, ColorHelper.OkayGreen, 0.5f);
|
||||
DieSelectedAndPairCompleteEvent?.Invoke();
|
||||
}
|
||||
|
||||
private void HandleStateChange(GameState state) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue