Example #1
0
	public AnswerCell GetRandomAnswer()
	{
		//if(m_AnswerList.Count > 0)
		int randomCell = UnityEngine.Random.Range( 0, m_AnswerList.Count );

		//We need to do a deep copy here to prevent pointer confusion
		AnswerCell newCell = new AnswerCell();
		newCell.m_AnswerText = m_AnswerList[randomCell].m_AnswerText;
		newCell.m_Difficulty = m_AnswerList[randomCell].m_Difficulty;
		newCell.m_IsCorrect = m_AnswerList[randomCell].m_IsCorrect;

		return newCell;
	}
Example #2
0
		public void TrackNewAnswer(AnswerCell answer)
		{
			lol.Add(answer.m_AnswerText);

			if(currentStatList.ContainsKey(answer.m_AnswerText))
			{
				//if the answer is already in the dictionary lets just increment the m_TimesAnswered variable
				currentStatList[answer.m_AnswerText].m_TimesAnswered++;
			}
			else
			{
				//Perform a Deep Copy so we dont lose the reference once it falls out of scope!
				AnswerCell newAnswer = new AnswerCell();
				newAnswer.m_AnswerText = answer.m_AnswerText;
				newAnswer.m_Difficulty = answer.m_Difficulty;
				newAnswer.m_IsCorrect = answer.m_IsCorrect;

				currentStatList.Add(newAnswer.m_AnswerText, newAnswer);
			}

		}
Example #3
0
	/// <summary>
	/// XML LOADER
	/// </summary>
	/// <param name="filename">Filename of the xml file</param>

		public void LoadCategory (string filename)
		{
				TextAsset textAsset = new TextAsset ();
				textAsset = (TextAsset)Resources.Load (filename, typeof(TextAsset));

				if (textAsset != null) {

						XmlDocument xmlDoc = new XmlDocument (); // xmlDoc is the new xml document.
						xmlDoc.LoadXml (GetTextWithoutBOM (textAsset)); // load the file.

						XmlElement root = xmlDoc.DocumentElement;
						XmlNode catName = root.SelectSingleNode ("name");
						XmlNode catParent = root.SelectSingleNode ("parent");

						m_CategoryName = catName.InnerText;
						m_ParentCategory = (MainCategory)Enum.Parse (typeof(MainCategory), catParent.InnerText);

						XmlNodeList correctList = xmlDoc.GetElementsByTagName ("correct");
						XmlNodeList wrongList = xmlDoc.GetElementsByTagName ("wrong");


						m_AnswerList = new List<AnswerCell> ();


						foreach (XmlNode chldNode in correctList) {

								AnswerCell tempcell = new AnswerCell ();

								tempcell.m_AnswerText = chldNode.Attributes ["Text"].Value;
								tempcell.m_Difficulty = Convert.ToInt32(chldNode.Attributes ["Difficulty"].Value);
								tempcell.m_IsCorrect = true;

								m_AnswerList.Add (tempcell);
						}

						foreach (XmlNode chldNode in wrongList) {
				
								AnswerCell tempcell = new AnswerCell ();
				
								tempcell.m_AnswerText = chldNode.Attributes ["Text"].Value;
								tempcell.m_Difficulty = Convert.ToInt32(chldNode.Attributes ["Difficulty"].Value);
								tempcell.m_IsCorrect = false;
				
								m_AnswerList.Add (tempcell);
						}


						
				}
		}