using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/*******************************************************************************
*Create By CG
*Function 
*******************************************************************************/
namespace ZXK.ZWQG
{
	public class ThemeCtrl : MonoBehaviour
	{
		[SerializeField]
		private string[] _options;
        [SerializeField]
        private GameObject _optionPrefab;
        [SerializeField]
        private Transform _optionParent;

        private QuestionBtnCtrl _curSelectQuestion;

        private void Awake()
        {
            for (int i = 0; i < _options.Length; i++)
            {
                GameObject optionItemGeo = Instantiate(_optionPrefab, _optionParent);
                optionItemGeo.name = _options[i];
                optionItemGeo.transform.Find("Text (Legacy)").GetComponent<Text>().text = _options[i];
                optionItemGeo.SetActive(false);
                optionItemGeo.GetComponent<OptionItemCtrl>().Init(this);
            }
        }

        public void SelectQuestion(string answerStr, QuestionBtnCtrl selectBtn)
        {
            _curSelectQuestion = selectBtn;
            OptionItemCtrl[] options = _optionParent.GetComponentsInChildren<OptionItemCtrl>(true);
            for (int i = 0; i < options.Length; i++)
            {
                options[i].GetComponent<OptionItemCtrl>()._RightAnswer = answerStr;
                options[i].gameObject.SetActive(true);
            }
        }

        public void SelectRightOption()
        {
            OptionItemCtrl[] options = _optionParent.GetComponentsInChildren<OptionItemCtrl>(true);
            for (int i = 0; i < options.Length; i++)
            {
                options[i].gameObject.SetActive(false);
            }
            _curSelectQuestion.SetRightTxt();
        }
    }
}