| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- 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;
- public string questionString = "";
- public string answerString = "";
- public string idString = "";
- public string categoryString = "";
- public Color32 unsafeColor;
- public Color32 safeColor;
- [SerializeField] CanvasGroup frosting;
- [SerializeField] GameObject frontCategoryPanel;
- [SerializeField] Text frontCategoryText;
- public void SetQuestionSafe() {
- this.GetComponent<Image>().color = safeColor;
- }
- internal void SetQuestionUnSafe() {
- this.GetComponent<Image>().color = unsafeColor;
- }
- public bool IsQuestionSafe() {
- if (this.GetComponent<Image>().color == safeColor) {
- return true;
- }
- return false;
- }
- public void SetQuestionCategoryColor(Color32 questionCategoryColor) {
- if (backCategoryText != null) {
- backCategoryText.transform.parent.GetComponent<Image>().color = questionCategoryColor;
- frontCategoryPanel.GetComponent<Image>().color = questionCategoryColor;
- }
- }
- public void SetQuestionText(string text) {
- if (questionText == null) {
- GameObject test = new GameObject("Text");
- questionText = test.AddComponent<Text>();
- }
- this.questionText.text = text;
- }
- public void SetAnswerText(string text) {
- if (answerText == null) {
- GameObject test = new GameObject("Text");
- answerText = test.AddComponent<Text>();
- }
- this.answerText.text = text;
- }
- public Text GetQuestionText() {
- return this.questionText;
- }
- public Text GetAnswerText() {
- return this.answerText;
- }
- public int GetCategoryId() {
- Int32.TryParse(categoryString, out int result);
- return result;
- }
- internal int GetId() {
- Int32.TryParse(idString, out int result);
- return result;
- }
- public void SetId(int value) {
- idString = value.ToString();
- }
- public void SetBackCategoryText(string value) {
- if (backCategoryText == null) {
- GameObject test = new GameObject("Text"); // TODO test??
- backCategoryText = test.AddComponent<Text>();
- }
- backCategoryText.text = value;
- frontCategoryText.text = 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;
- }
- }
- }
|