From 11e1099e59d95808e61165a96544d2915a15848d Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 28 Feb 2023 10:09:34 -0500 Subject: [PATCH] showing right answers --- namedropper/Assets/Scripts/Category.cs | 11 ++++++++++- namedropper/Assets/Scripts/Game.cs | 4 ++-- namedropper/Assets/Scripts/Player.cs | 7 +++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/namedropper/Assets/Scripts/Category.cs b/namedropper/Assets/Scripts/Category.cs index 74da6d6..42ee520 100644 --- a/namedropper/Assets/Scripts/Category.cs +++ b/namedropper/Assets/Scripts/Category.cs @@ -5,6 +5,7 @@ using UnityEngine.UI; public class Category : MonoBehaviour { + const bool SHOW_RIGHT_ANSWERS = true; public string Name; public List Elements = new List(); List WorkingElements = new List(); @@ -28,15 +29,23 @@ public class Category : MonoBehaviour _streak.SetActive(true); _streak.GetComponent().text = "10"; + _streak.GetComponent().color = Color.green; if (streak > 1) { _streak.GetComponent().text += " x " + streak; } } - public void ShowFeedbackBad() + public void ShowFeedbackBad(string wrongAnswer) { ShowFeedback(_feedbackBad); + + if (SHOW_RIGHT_ANSWERS) + { + _streak.SetActive(true); + _streak.GetComponent().text = wrongAnswer; + _streak.GetComponent().color = Color.red; + } } void ShowFeedback(SpriteRenderer feedback, bool show = true) diff --git a/namedropper/Assets/Scripts/Game.cs b/namedropper/Assets/Scripts/Game.cs index edbcf8a..fbc3548 100644 --- a/namedropper/Assets/Scripts/Game.cs +++ b/namedropper/Assets/Scripts/Game.cs @@ -214,10 +214,10 @@ public class Game : MonoBehaviour UpdateScores(); } - public string PickRandomWord() + public System.Tuple PickRandomWord() { int index = Random.Range(0, _categories.Length); - return _categories[index].PickRandomWord(); + return new System.Tuple(_categories[index].Name, _categories[index].PickRandomWord()); } public void UpdateScores() diff --git a/namedropper/Assets/Scripts/Player.cs b/namedropper/Assets/Scripts/Player.cs index 31988f6..35b069b 100644 --- a/namedropper/Assets/Scripts/Player.cs +++ b/namedropper/Assets/Scripts/Player.cs @@ -28,6 +28,7 @@ public class Player : MonoBehaviour GameObject _spriteChildTop; Vector3 _originalScale; Vector3 _originalTextScale; + string _categoryName; public enum Team { @@ -118,7 +119,9 @@ public class Player : MonoBehaviour { if (_game != null) { - _text.text = _game.PickRandomWord(); + System.Tuple tuple = _game.PickRandomWord(); + _categoryName = tuple.Item1; + _text.text = tuple.Item2; SetRandomTextRotation(); SetFont(); } @@ -193,7 +196,7 @@ public class Player : MonoBehaviour else { _streak = 0; - category.ShowFeedbackBad(); + category.ShowFeedbackBad(_categoryName); this.gameObject.SetActive(false); Respawn(); //Invoke("Respawn", 2f);