RoundButtonsScript.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine.UI;
  4. using UnityEngine;
  5. using System;
  6. public class RoundButtonsScript : MonoBehaviour
  7. {
  8. public Button newQuestionButton;
  9. public Button nextPlayerButton;
  10. public GameObject QuestionAnswerLine;
  11. public GameObject nextCategoryText;
  12. public GameObject QuestionCardPrefab;
  13. public GameObject NewQuestionCardPanel;
  14. private ScrollViewScript svs;
  15. private TimerScript ts;
  16. // Start is called before the first frame update
  17. void Start()
  18. {
  19. newQuestionButton.onClick.AddListener(NewQuestion);
  20. nextPlayerButton.onClick.AddListener(NextPlayer);
  21. svs = GameObject.Find("Scroll View").GetComponent<ScrollViewScript>();
  22. ts = GameObject.Find("TimerCircle").GetComponent<TimerScript>();
  23. }
  24. void NewQuestion() {
  25. HidePanel();
  26. ts.ResetTimer();
  27. ts.StartTimer();
  28. }
  29. void NextPlayer() {
  30. svs.SetAllQuestionsLocked(true);
  31. svs.NextPlayer();
  32. HidePanel();
  33. }
  34. public void HidePanel() {
  35. gameObject.SetActive(false);
  36. }
  37. public void ShowPanel() {
  38. if (svs == null) {
  39. svs = GameObject.Find("Scroll View").GetComponent<ScrollViewScript>();
  40. }
  41. NewQuestionData q = Database.Instance.GetNewQuestion(svs.GetQuestionIdsInAnswerLine(), svs.currentPlayer, svs.GetGameMode());
  42. //q.SetAnswerText("???? - ????");
  43. //svs.SetNewQuestion(q);
  44. Text nqct = nextCategoryText.GetComponent<Text>();
  45. CategoryPanel cp = GameObject.Find("Categories").GetComponent<CategoryPanel>();
  46. CategoryPanel.Category cat = cp.GetCategoryById(q.CategoryId);
  47. nqct.text = cat.name;
  48. gameObject.SetActive(true);
  49. }
  50. internal void DeactivateNextPlayer() {
  51. nextPlayerButton.interactable = false;
  52. newQuestionButton.GetComponentInChildren<Text>().text = LocalizationManager.Instance.GetText("START_ROUND_TEXT");
  53. }
  54. internal void ActivateNextPlayer() {
  55. nextPlayerButton.interactable = true;
  56. newQuestionButton.GetComponentInChildren<Text>().text = LocalizationManager.Instance.GetText("NEW_QUESTION");
  57. }
  58. public void SetGameOver() {
  59. nextPlayerButton.interactable = false;
  60. newQuestionButton.interactable = false;
  61. }
  62. }