|
|
@@ -3,6 +3,7 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.EventSystems;
|
|
|
+using UnityEngine.UI;
|
|
|
|
|
|
public class ScrollViewScript : MonoBehaviour, IDropHandler {
|
|
|
public GameObject prefab;
|
|
|
@@ -53,7 +54,6 @@ public class ScrollViewScript : MonoBehaviour, IDropHandler {
|
|
|
if (d == null || !d.gameObject.name.Contains("NewQuestion")) {
|
|
|
return;
|
|
|
}
|
|
|
- // Popup modal asking are you sure here or at onDragEnd?
|
|
|
nq = d.GetComponent<NewQuestion>();
|
|
|
newQuestionSiblingIndex = d.placeholder.transform.GetSiblingIndex();
|
|
|
|
|
|
@@ -71,10 +71,13 @@ public class ScrollViewScript : MonoBehaviour, IDropHandler {
|
|
|
dialog.SetOnAccept("Ja", () => {
|
|
|
dialog.Hide();
|
|
|
nq.SetQuestionData();
|
|
|
+ SetQuestionsInAnswerLine();
|
|
|
}); // generera ny fråga
|
|
|
dialog.SetOnDecline("Nej", () => {
|
|
|
dialog.Hide();
|
|
|
SetAllQuestionsLocked();
|
|
|
+ IncreaseRoundValue();
|
|
|
+ SetQuestionsInAnswerLine();
|
|
|
}); // lås frågor som ej är låsta.
|
|
|
} else {
|
|
|
dialog.SetTitle("Tyvärr fel svar, korrekt svar var " + nq.answerString);
|
|
|
@@ -82,6 +85,7 @@ public class ScrollViewScript : MonoBehaviour, IDropHandler {
|
|
|
RemoveUnlockedQuestions();
|
|
|
dialog.SetOnAccept("Ok", () => dialog.Hide());
|
|
|
dialog.SetOnDecline("", () => dialog.Hide());
|
|
|
+ IncreaseRoundValue();
|
|
|
|
|
|
nq.SetQuestionData();
|
|
|
}
|
|
|
@@ -93,26 +97,47 @@ public class ScrollViewScript : MonoBehaviour, IDropHandler {
|
|
|
}
|
|
|
|
|
|
private void RemoveUnlockedQuestions() {
|
|
|
+ int lostQuestions = 0;
|
|
|
for (int i = 0; i < contentPanel.childCount; i++) {
|
|
|
QuestionCard q = contentPanel.GetChild(i).GetComponent<QuestionCard>();
|
|
|
if (!q.IsQuestionSafe()) {
|
|
|
+ lostQuestions++;
|
|
|
Destroy(q.gameObject);
|
|
|
}
|
|
|
}
|
|
|
+ Text lostQuestionsValueText = GameObject.Find("Stats Value Lost").GetComponent<Text>();
|
|
|
+ lostQuestionsValueText.text = (Int16.Parse(lostQuestionsValueText.text) + lostQuestions).ToString();
|
|
|
+
|
|
|
+ SetQuestionsInAnswerLine(contentPanel.childCount - lostQuestions);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void IncreaseRoundValue() {
|
|
|
+ Text roundTextValue = GameObject.Find("Stats Value Round").GetComponent<Text>();
|
|
|
+ roundTextValue.text = (Int16.Parse(roundTextValue.text) + 1).ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetQuestionsInAnswerLine() {
|
|
|
+ Text answerlineTextValue = GameObject.Find("Stats Value Inline").GetComponent<Text>();
|
|
|
+ answerlineTextValue.text = contentPanel.childCount.ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetQuestionsInAnswerLine(int answers) {
|
|
|
+ Text answerlineTextValue = GameObject.Find("Stats Value Inline").GetComponent<Text>();
|
|
|
+ answerlineTextValue.text = answers.ToString();
|
|
|
}
|
|
|
|
|
|
- // kontrollera om man svarat korrekt, om det är korrekt, visa ny modal med vill du ha ny fråga? om fel, meddela det och avsluta omgång.
|
|
|
void YesFunction() {
|
|
|
|
|
|
int correctAnswer = Int32.Parse(nq.answerString);
|
|
|
+ int currentChildCount = contentPanel.childCount;
|
|
|
Transform questionBefore = null;
|
|
|
Transform questionAfter = null;
|
|
|
- try {
|
|
|
+ if (newQuestionSiblingIndex - 1 > 0) {
|
|
|
questionBefore = contentPanel.GetChild(newQuestionSiblingIndex - 1);
|
|
|
- } catch (UnityException e) { }
|
|
|
- try {
|
|
|
+ }
|
|
|
+ if (newQuestionSiblingIndex < currentChildCount) {
|
|
|
questionAfter = contentPanel.GetChild(newQuestionSiblingIndex);
|
|
|
- } catch (UnityException e) { }
|
|
|
+ }
|
|
|
|
|
|
QuestionCard test = contentPanel.GetChild(0).GetComponent<QuestionCard>();
|
|
|
int answerBefore = -1;
|