QuestionCard.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.Networking;
  6. using UnityEngine.UI;
  7. public class QuestionCard : MonoBehaviour {
  8. public Text questionText;
  9. public Text answerText;
  10. public Text backCategoryText;
  11. public GameObject questionTextPanel;
  12. public string questionString = "";
  13. public string answerString = "";
  14. public string idString = "";
  15. public string categoryString = "";
  16. public Color32 unsafeColor;
  17. public Color32 safeColor;
  18. public void SetQuestionSafe() {
  19. this.GetComponent<Image>().color = safeColor;
  20. }
  21. internal void SetQuestionUnSafe() {
  22. this.GetComponent<Image>().color = unsafeColor;
  23. }
  24. public bool IsQuestionSafe() {
  25. if (this.GetComponent<Image>().color == safeColor) {
  26. return true;
  27. }
  28. return false;
  29. }
  30. public void SetQuestionCategoryColor(Color32 questionCategoryColor) {
  31. if (backCategoryText != null) {
  32. backCategoryText.transform.parent.GetComponent<Image>().color = questionCategoryColor;
  33. }
  34. }
  35. public void SetQuestionText(string text) {
  36. if (questionText == null) {
  37. GameObject test = new GameObject("Text");
  38. questionText = test.AddComponent<Text>();
  39. }
  40. this.questionText.text = text;
  41. }
  42. public void SetAnswerText(string text) {
  43. if (answerText == null) {
  44. GameObject test = new GameObject("Text");
  45. answerText = test.AddComponent<Text>();
  46. }
  47. this.answerText.text = text;
  48. }
  49. public Text GetQuestionText() {
  50. return this.questionText;
  51. }
  52. public Text GetAnswerText() {
  53. return this.answerText;
  54. }
  55. public int GetCategoryId() {
  56. Int32.TryParse(categoryString, out int result);
  57. return result;
  58. }
  59. internal int GetId() {
  60. Int32.TryParse(idString, out int result);
  61. return result;
  62. }
  63. public void SetId(int value) {
  64. idString = value.ToString();
  65. }
  66. public void SetBackCategoryText(string value) {
  67. if (backCategoryText == null) {
  68. GameObject test = new GameObject("Text");
  69. backCategoryText = test.AddComponent<Text>();
  70. }
  71. backCategoryText.text = value;
  72. }
  73. public string GetBackCategoryText() {
  74. if (backCategoryText == null) {
  75. return "Category";
  76. }
  77. return backCategoryText.text;
  78. }
  79. }