RoundButtonsScript.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine.UI;
  4. using UnityEngine;
  5. public class RoundButtonsScript : MonoBehaviour
  6. {
  7. public Button newQuestionButton;
  8. public Button nextPlayerButton;
  9. private ScrollViewScript svs;
  10. private TimerScript ts;
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14. newQuestionButton.onClick.AddListener(NewQuestion);
  15. nextPlayerButton.onClick.AddListener(NextPlayer);
  16. svs = GameObject.Find("Scroll View").GetComponent<ScrollViewScript>();
  17. ts = GameObject.Find("TimerCircle").GetComponent<TimerScript>();
  18. }
  19. void NewQuestion() {
  20. if (svs == null) {
  21. svs = GameObject.Find("Scroll View").GetComponent<ScrollViewScript>();
  22. }
  23. Database db = GameObject.Find("GameManager").GetComponent<Database>();
  24. NewQuestion q = db.GetNewQuestion();
  25. q.SetAnswerText("???? - ????");
  26. svs.SetNewQuestion(q);
  27. HidePanel();
  28. ts.StartTimer();
  29. }
  30. void NextPlayer() {
  31. svs.SetAllQuestionsLocked(true);
  32. svs.NextPlayer();
  33. HidePanel();
  34. }
  35. public void HidePanel() {
  36. CanvasGroup cg = this.GetComponent<CanvasGroup>();
  37. cg.alpha = 0F;
  38. cg.blocksRaycasts = false;
  39. }
  40. public void ShowPanel() {
  41. CanvasGroup cg = this.GetComponent<CanvasGroup>();
  42. cg.alpha = 1F;
  43. cg.blocksRaycasts = true;
  44. }
  45. }