Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class QustionGenerator : MonoBehaviour
- {
- [SerializeField] Text _text;
- public TextAsset jsonFile;
- private QuestPack questPack;
- public int currentQuest = -1;
- [SerializeField] List<Transform> listOfQuestionToSpawm;
- [SerializeField] GameObject cube;
- void Start()
- {
- questPack = JsonUtility.FromJson<QuestPack>(jsonFile.text);
- StartCoroutine(CahngeQuestion());
- }
- IEnumerator CahngeQuestion()
- {
- while(QustionsAnswers.gameIsOn == true)
- {
- yield return new WaitForSeconds(8);
- currentQuest++;
- VoidGenerateCubes();
- }
- }
- public void VoidGenerateCubes()
- {
- GameObject[] objects = new GameObject[4];
- _text.text = questPack.quests[currentQuest].question;
- for(int i = 0; i<3; i++)
- {
- GameObject newOne = Instantiate(cube, listOfQuestionToSpawm[i].position, Quaternion.identity);
- string text = questPack.quests[currentQuest].wrong_answers[i].ToString();
- objects[i] = newOne;
- newOne.GetComponent<QustController>().SetWrong(text);
- }
- var rObj = Instantiate(cube, listOfQuestionToSpawm[3].position, Quaternion.identity);
- rObj.GetComponent<QustController>().SetRight(questPack.quests[currentQuest].right_answer);
- //_text.text = QustionsAnswers.questions.Split('#')[currentQuest];
- //for(int i =0;i<4;i++)
- //{
- // GameObject newOne = Instantiate(cube, listOfQuestionToSpawm[i].position, Quaternion.identity);
- // string text = QustionsAnswers.answers.Split('#')[currentQuest].Split(',')[i];
- // if (text.Contains("_"))
- // {
- // newOne.GetComponent<QustController>().SetRight(text);
- // }
- // else
- // {
- // newOne.GetComponent<QustController>().SetWrong(text);
- // }
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement