using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI; public class QuestionCard : MonoBehaviour { public Text questionText; public Text answerText; public Text backCategoryText; public GameObject questionTextPanel; private Color categoryColor; private int categoryId; private int questionId; private bool questionSafe; private String categoryText; public Color32 unsafeColor; public Color32 safeColor; [SerializeField] CanvasGroup frosting; [SerializeField] GameObject frontCategoryPanel; [SerializeField] Text frontCategoryText; public Color CategoryColor { get => categoryColor; set => categoryColor = value; } public int CategoryId { get => categoryId; set => categoryId = value; } public int QuestionId { get => questionId; set => questionId = value; } public bool QuestionSafe { get => questionSafe; set => questionSafe = value; } public string CategoryText { get => categoryText; set => categoryText = value; } public void SetQuestionSafe(bool safe) { if (safe) { SetQuestionSafe(); } else { SetQuestionUnSafe(); } } public void SetQuestionSafe() { this.GetComponent().color = safeColor; QuestionSafe = true; } internal void SetQuestionUnSafe() { this.GetComponent().color = unsafeColor; QuestionSafe = false; } public bool IsQuestionSafe() { return QuestionSafe; } public void SetQuestionCategoryColor(Color32 questionCategoryColor) { CategoryColor = questionCategoryColor; if (backCategoryText != null) { backCategoryText.transform.parent.GetComponent().color = questionCategoryColor; frontCategoryPanel.GetComponent().color = questionCategoryColor; } } public void SetQuestionText(string text) { if (questionText == null) { GameObject test = new GameObject("Text"); questionText = test.AddComponent(); } this.questionText.text = text; } public void SetAnswerText(string text) { if (answerText == null) { GameObject test = new GameObject("Text"); answerText = test.AddComponent(); } this.answerText.text = text; } public String GetQuestionText() { return this.questionText.text; } public String GetAnswerText() { return this.answerText.text; } public void SetId(int value) { questionId = value; } public void SetBackCategoryText(string value) { if (backCategoryText == null) { GameObject temp = new GameObject("Text"); backCategoryText = temp.AddComponent(); } backCategoryText.text = value; frontCategoryText.text = value; CategoryText = value; } public string GetBackCategoryText() { if (backCategoryText == null) { return "Category"; } return backCategoryText.text; } public void SetFrostingActive(Boolean value) { if (value) { frosting.alpha = 1f; } else { frosting.alpha = 0f; } } }