AnswerLineInfoScript.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class AnswerLineInfoScript : MonoBehaviour
  7. {
  8. [SerializeField] Button nextPlayerButton;
  9. [SerializeField] Button prevPlayerButton;
  10. [SerializeField] Text lockedQuestionsText;
  11. [SerializeField] Text unlockedQuestionsText;
  12. [SerializeField] GameObject scrollView;
  13. [SerializeField] GameObject gameManager;
  14. private void Start() {
  15. nextPlayerButton.onClick.AddListener(ShowPrevPlayerAnswerLine);
  16. prevPlayerButton.onClick.AddListener(ShoeNextPlayerAnswerLine);
  17. }
  18. private void Update() {
  19. UpdateLockedQuestionsText();
  20. UpdateUnlockedQuestionsText();
  21. }
  22. public void UpdateButtonsText() {
  23. List<KeyValuePair<string, int>> players = gameManager.GetComponent<GameManagerScript>().GetPlayers();
  24. if (players.Count <= 1) {
  25. nextPlayerButton.gameObject.SetActive(false);
  26. prevPlayerButton.gameObject.SetActive(false);
  27. } else {
  28. nextPlayerButton.gameObject.SetActive(true);
  29. prevPlayerButton.gameObject.SetActive(true);
  30. }
  31. }
  32. private void UpdateUnlockedQuestionsText() {
  33. int unlockedQuestionCount = scrollView.GetComponent<ScrollViewScript>().GetUnlockedQuestionCount();
  34. if (unlockedQuestionCount <= 0) {
  35. unlockedQuestionsText.gameObject.SetActive(false);
  36. } else {
  37. unlockedQuestionsText.gameObject.SetActive(true);
  38. unlockedQuestionsText.text = String.Format(
  39. LocalizationManager.Instance.GetText(
  40. unlockedQuestionsText.GetComponent<TextLocalization>().key),
  41. unlockedQuestionCount);
  42. }
  43. }
  44. private void UpdateLockedQuestionsText() {
  45. ScrollViewScript scrollViewScript = scrollView.GetComponent<ScrollViewScript>();
  46. int lockedQuestionsCount = scrollViewScript.GetQuestionIdsInAnswerLine().Count - scrollViewScript.GetUnlockedQuestionCount();
  47. lockedQuestionsText.text = String.Format(
  48. LocalizationManager.Instance.GetText(
  49. lockedQuestionsText.GetComponent<TextLocalization>().key),
  50. lockedQuestionsCount);
  51. }
  52. private void ShoeNextPlayerAnswerLine()
  53. {
  54. throw new NotImplementedException();
  55. }
  56. private void ShowPrevPlayerAnswerLine()
  57. {
  58. throw new NotImplementedException();
  59. }
  60. }