Advertisement
moinularif

Chose Qs

May 14th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.31 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class QuestionHandler : MonoBehaviour {
  6.  
  7.     [System.Serializable]
  8.     public class Question
  9.     {
  10.         public string QuestionString;
  11.         public bool IsItPictorial;
  12.         public bool IsInBengali;
  13.         public Texture2D BengaliQuestion;
  14.         public Texture2D QuestionPictorial;
  15.     }
  16.     public List<Question> Internet_Questions = new List<Question>();
  17.     public List<Question> G_Science_Questions = new List<Question>();
  18.     public List<Question> General_Knowledge_Questions = new List<Question>();
  19.  
  20.     public List<Question> Chosen_Internet_Question = new List<Question>();
  21.     public List<Question> Chosen_G_science_Question = new List<Question>();
  22.     public List<Question> Chosen_General_knowledge_Question = new List<Question>();
  23.  
  24.     public static Question CurrentQuestion = new Question();
  25.     // Use this for initialization
  26.     void Start ()
  27.     {
  28.  
  29.         if (CurrentQuestion.IsItPictorial) { Debug.Log("asdasdasd"); }
  30.  
  31.         // Please Change this values accoridding to requirments;
  32.         int num_of_Internet_Question = 8;
  33.         int num_of_G_science_Question = 8;
  34.         int num_of_General_knowledge_Question = 7;
  35.  
  36.         Chosen_Internet_Question = ChooseQuestion(Internet_Questions, num_of_Internet_Question);
  37.         Chosen_G_science_Question = ChooseQuestion(Internet_Questions, num_of_G_science_Question);
  38.         Chosen_General_knowledge_Question = ChooseQuestion(Internet_Questions, num_of_General_knowledge_Question);
  39.            
  40.     }
  41.    
  42.     // Update is called once per frame
  43.     void Update () {
  44.    
  45.     }
  46.  
  47.     List<Question> ChooseQuestion(List<Question> inputQuestion, int countNumber)
  48.     {
  49.        
  50.        
  51.         List<Question> tempQuestion =  inputQuestion;
  52.         List<Question> chosenQuestion = new List<Question>();
  53.  
  54.         if (tempQuestion.Count == 0)
  55.         {
  56.             Debug.Log("List Empty");
  57.            
  58.  
  59.         }
  60.         else
  61.         {
  62.             for (int i = 0; i < countNumber; i++)
  63.             {
  64.                 int chosenIndex = Random.Range(0, tempQuestion.Count);
  65.                 chosenQuestion.Add(tempQuestion[chosenIndex]);
  66.                 tempQuestion.Remove(tempQuestion[chosenIndex]);
  67.  
  68.             }
  69.         }
  70.  
  71.         return chosenQuestion;
  72.  
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement