- Home /
This question was
closed Jul 15, 2017 at 09:56 AM by
tanoshimi for the following reason:
Question is off-topic or not relevant or non-existent
Question by
GilbertFerrer · Jul 15, 2017 at 09:49 AM ·
gamequizwithpictures
i wanted to build a quiz game that has a 30 questions including 30 pictures as well. like 1 question is equal to 1 picture. so that the question is based on the picture display
using UnityEngine.UI; using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour {
//public Sprite[] pics;
//private Image imagePic;
//private List<Sprite> images;
//private Image factImage;
//private Question pictures;
//private static List<Question> unpictures;
//private Question currentpicture;
//[SerializeField]
//private Image factimage;
public Question[] questions;
private static List<Question> unansweredQuestions;
private Question currentQuestion;
[SerializeField]
private Text factText;
[SerializeField]
private float TimeBetweenQuestions = 1f;
void Start()
{
if (unansweredQuestions == null || unansweredQuestions.Count == 0)
{
unansweredQuestions = questions.ToList<Question> ();
}
SetRandomQuestion ();
}
//void SetPicture()
//{
// int count = unansweredpictures.Count;
// int index = Random.Range (0, count);
// Debug.Log ("picture1");
//unansweredpictures.sprite = unansweredpictures [index];
//image1.sprite = pics [index];
//}
void SetRandomQuestion ()
{
int randomQuestionIndex = Random.Range (0, unansweredQuestions.Count);
currentQuestion = unansweredQuestions [randomQuestionIndex];
factText.text = currentQuestion.fact;
// int randomindex = Random.Range (0, unpictures.Count);
// currentpicture = unpictures [randomindex];
//factimage.canvasRenderer<Sprite> = currentpicture.fact;
}
IEnumerator TransitionToNextQuestion ()
{
unansweredQuestions.Remove (currentQuestion);
//unpictures.Remove (currentpicture);
yield return new WaitForSeconds (TimeBetweenQuestions);
SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
}
public void UserSelectTrue()
{
if (currentQuestion.isTrue) {
Debug.Log ("Correct");
} else
{
Debug.Log ("Wrong");
}
StartCoroutine (TransitionToNextQuestion ());
}
public void UserSelectFalse()
{
if (!currentQuestion.isTrue) {
Debug.Log ("Correct");
} else
{
Debug.Log ("Wrong");
}
StartCoroutine (TransitionToNextQuestion ());
}
}
Comment
Follow this Question
Related Questions
Creating a Multiple Choice Game 2 Answers
Make quiz game Confused About PlayerPrefs and database 1 Answer
how to randomize questions but still show all the questions? 1 Answer
Code to integrate Json database? 2 Answers
Trouble with exporting game! 0 Answers