diff --git a/namedropper/Assets/GameOverScreen.cs b/namedropper/Assets/GameOverScreen.cs index e6704f5..75e9133 100644 --- a/namedropper/Assets/GameOverScreen.cs +++ b/namedropper/Assets/GameOverScreen.cs @@ -16,11 +16,30 @@ public class GameOverScreen : MonoBehaviour { GameManager.Instance.HighScore = score; } - _gameOverMessage.text = "GAME OVER\n\nYour score: " + score + "\nToday's hi-score: " + GameManager.Instance.HighScore.ToString() + "\n\nPress 'R' to Replay"; + _gameOverMessage.text = "GAME OVER\n\nYour score: " + score + "\nToday's hi-score: " + GameManager.Instance.HighScore.ToString() + "\n\nPress 'R' to replay"; } else { - _gameOverMessage.text = "GAME OVER\n\nScores: " + GameManager.Instance.Score1 + "\n" + GameManager.Instance.Score2 + "\n" + GameManager.Instance.Score3 + "\n" + GameManager.Instance.Score4; + ScoreStack blueScoreStack = GameObject.Find("/ScoreStackBlue").GetComponent(); + ScoreStack redScoreStack = GameObject.Find("/ScoreStackRed").GetComponent(); + + if (blueScoreStack.Score > redScoreStack.Score) + { + _gameOverMessage.color = Color.blue; + _gameOverMessage.text = "BLUE TEAM WINS!\n" + blueScoreStack.Score + " to " + redScoreStack.Score; + } + else if (redScoreStack.Score > blueScoreStack.Score) + { + _gameOverMessage.color = Color.red; + _gameOverMessage.text = "RED TEAM WINS!\n" + redScoreStack.Score + " to " + blueScoreStack.Score; + } + else + { + _gameOverMessage.color = Color.white; + _gameOverMessage.text = "TIE!\n" + redScoreStack.Score + " to " + blueScoreStack.Score; + } + + _gameOverMessage.text += "\n\nPress 'R' to replay"; } } diff --git a/namedropper/Assets/ScoreStack.cs b/namedropper/Assets/ScoreStack.cs index ae4332d..33b9a39 100644 --- a/namedropper/Assets/ScoreStack.cs +++ b/namedropper/Assets/ScoreStack.cs @@ -8,6 +8,11 @@ public class ScoreStack : MonoBehaviour [SerializeField] Sprite _darkSprite; int _numCheckers = 0; // Start is called before the first frame update + + public int Score + { + get { return _numCheckers; } + } void Start() { // diff --git a/namedropper/Assets/Scripts/Category.cs b/namedropper/Assets/Scripts/Category.cs index 42ee520..4486f7f 100644 --- a/namedropper/Assets/Scripts/Category.cs +++ b/namedropper/Assets/Scripts/Category.cs @@ -23,22 +23,40 @@ public class Category : MonoBehaviour HideAllFeedback(); } - public void ShowFeedbackGood(int streak) + public int ShowFeedbackGood(int streak) { - ShowFeedback(_feedbackGood); + int streakPayout = GetStreakPayout(streak); + if (streakPayout > 0) + ShowFeedback(_feedbackGood, duration:2f); + else + ShowFeedback(_feedbackGood); - _streak.SetActive(true); - _streak.GetComponent().text = "10"; - _streak.GetComponent().color = Color.green; - if (streak > 1) + if (streakPayout > 0) { - _streak.GetComponent().text += " x " + streak; + _streak.SetActive(true); + _streak.GetComponent().text = ""; + _streak.GetComponent().color = Color.blue; + _streak.GetComponent().text = streak + " in a row\n+" + streakPayout + " bonus"; } + + return streakPayout; + } + + int GetStreakPayout(int streak) + { + if (streak == 3) + return 1; + else if (streak == 5) + return 1; + else if (streak > 5 && streak % 5 == 0) //every other 5 + return 3; + else + return 0; } public void ShowFeedbackBad(string wrongAnswer) { - ShowFeedback(_feedbackBad); + ShowFeedback(_feedbackBad, duration: 2f); if (SHOW_RIGHT_ANSWERS) { @@ -48,11 +66,11 @@ public class Category : MonoBehaviour } } - void ShowFeedback(SpriteRenderer feedback, bool show = true) + void ShowFeedback(SpriteRenderer feedback, bool show = true, float duration = 1f) { feedback.enabled = show; CancelInvoke(); - Invoke("HideAllFeedback", 1f); + Invoke("HideAllFeedback", duration); } void HideAllFeedback() diff --git a/namedropper/Assets/Scripts/Game.cs b/namedropper/Assets/Scripts/Game.cs index fbc3548..3d99861 100644 --- a/namedropper/Assets/Scripts/Game.cs +++ b/namedropper/Assets/Scripts/Game.cs @@ -6,6 +6,7 @@ using UnityEngine.SceneManagement; public class Game : MonoBehaviour { + const bool HIDE_SCORES = true; int _seconds = 70; [SerializeField] Text Score1; @@ -216,12 +217,23 @@ public class Game : MonoBehaviour public System.Tuple PickRandomWord() { - int index = Random.Range(0, _categories.Length); + int index = Random.Range(0, _categories.Length); return new System.Tuple(_categories[index].Name, _categories[index].PickRandomWord()); } public void UpdateScores() { + if (HIDE_SCORES) + { + Score1.text = ""; + Score2.text = ""; + Score3.text = ""; + Score4.text = ""; + + return; + } + + if (GameManager.Instance.Competitive == false) { int score = GameManager.Instance.Score1 + GameManager.Instance.Score2 + GameManager.Instance.Score3 + GameManager.Instance.Score4; Score1.text = score.ToString(); diff --git a/namedropper/Assets/Scripts/Player.cs b/namedropper/Assets/Scripts/Player.cs index 35b069b..2e07ee3 100644 --- a/namedropper/Assets/Scripts/Player.cs +++ b/namedropper/Assets/Scripts/Player.cs @@ -187,10 +187,10 @@ public class Player : MonoBehaviour if (category.Elements.Contains(_text.text)) { _streak++; - int score = 10 * _streak; + int streakBonus = category.ShowFeedbackGood(_streak); + int score = 10 + 10 * streakBonus; _game.AddScore(score, _playerNumber); - - category.ShowFeedbackGood(_streak); + Respawn(); } else @@ -198,8 +198,8 @@ public class Player : MonoBehaviour _streak = 0; category.ShowFeedbackBad(_categoryName); this.gameObject.SetActive(false); - Respawn(); - //Invoke("Respawn", 2f); + //Respawn(); + Invoke("Respawn", 2f); } }