|
@@ -41,6 +41,13 @@ public class ScrollViewScript : MonoBehaviour, IDropHandler {
|
|
|
return unlockedQuestionCount;
|
|
return unlockedQuestionCount;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void SetAllQuestionsLocked() {
|
|
|
|
|
+ for (int i = 0; i < contentPanel.childCount; i++) {
|
|
|
|
|
+ QuestionCard q = contentPanel.GetChild(i).GetComponent<QuestionCard>();
|
|
|
|
|
+ q.SetQuestionSafe();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void OnDrop(PointerEventData eventData) {
|
|
public void OnDrop(PointerEventData eventData) {
|
|
|
Draggable d = eventData.pointerDrag.GetComponent<Draggable>();
|
|
Draggable d = eventData.pointerDrag.GetComponent<Draggable>();
|
|
|
if (d == null || !d.gameObject.name.Contains("NewQuestion")) {
|
|
if (d == null || !d.gameObject.name.Contains("NewQuestion")) {
|
|
@@ -57,42 +64,54 @@ public class ScrollViewScript : MonoBehaviour, IDropHandler {
|
|
|
YesFunction();
|
|
YesFunction();
|
|
|
dialog.Hide();
|
|
dialog.Hide();
|
|
|
|
|
|
|
|
|
|
+
|
|
|
if (answeredCorrectly) {
|
|
if (answeredCorrectly) {
|
|
|
dialog.SetTitle("Korrekt svarat " + nq.answerString + "!");
|
|
dialog.SetTitle("Korrekt svarat " + nq.answerString + "!");
|
|
|
dialog.SetMessage("Helt korrekt, vill du ha en ny fråga, du riskerar då " + GetUnlockedQuestionCount() + " om du svarar fel");
|
|
dialog.SetMessage("Helt korrekt, vill du ha en ny fråga, du riskerar då " + GetUnlockedQuestionCount() + " om du svarar fel");
|
|
|
- dialog.SetOnAccept("Ja", () => { dialog.Hide(); }); // generera ny fråga
|
|
|
|
|
- dialog.SetOnDecline("Nej", () => { dialog.Hide(); }); // lås frågor som ej är låsta.
|
|
|
|
|
|
|
+ dialog.SetOnAccept("Ja", () => {
|
|
|
|
|
+ dialog.Hide();
|
|
|
|
|
+ nq.SetQuestionData();
|
|
|
|
|
+ }); // generera ny fråga
|
|
|
|
|
+ dialog.SetOnDecline("Nej", () => {
|
|
|
|
|
+ dialog.Hide();
|
|
|
|
|
+ SetAllQuestionsLocked();
|
|
|
|
|
+ }); // lås frågor som ej är låsta.
|
|
|
} else {
|
|
} else {
|
|
|
dialog.SetTitle("Tyvärr fel svar, korrekt svar var " + nq.answerString);
|
|
dialog.SetTitle("Tyvärr fel svar, korrekt svar var " + nq.answerString);
|
|
|
dialog.SetMessage("Du förlorade " + GetUnlockedQuestionCount() + ", bättre lycka nästa gång");
|
|
dialog.SetMessage("Du förlorade " + GetUnlockedQuestionCount() + ", bättre lycka nästa gång");
|
|
|
|
|
+ RemoveUnlockedQuestions();
|
|
|
dialog.SetOnAccept("Ok", () => dialog.Hide());
|
|
dialog.SetOnAccept("Ok", () => dialog.Hide());
|
|
|
dialog.SetOnDecline("", () => dialog.Hide());
|
|
dialog.SetOnDecline("", () => dialog.Hide());
|
|
|
|
|
+
|
|
|
|
|
+ nq.SetQuestionData();
|
|
|
}
|
|
}
|
|
|
dialog.Show();
|
|
dialog.Show();
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
dialog.SetOnDecline("Nej", () => dialog.Hide());
|
|
dialog.SetOnDecline("Nej", () => dialog.Hide());
|
|
|
dialog.Show();
|
|
dialog.Show();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- //modalPanel = ModalPanel.Instance();
|
|
|
|
|
- //ModalPanelDetails modalDetails = new ModalPanelDetails { question = "Vill du svara att " + nq.GetQuestionText().text + " hände " + nq.GetAnswerText().text + "?", iconImage = null };
|
|
|
|
|
- //modalDetails.button1Details = new EventButtonDetails { buttonTitle = "Ja", action = YesFunction };
|
|
|
|
|
- //modalDetails.button2Details = new EventButtonDetails { buttonTitle = "Nej", action = NoFunction };
|
|
|
|
|
- //modalPanel.NewChoice(modalDetails);
|
|
|
|
|
|
|
+ private void RemoveUnlockedQuestions() {
|
|
|
|
|
+ for (int i = 0; i < contentPanel.childCount; i++) {
|
|
|
|
|
+ QuestionCard q = contentPanel.GetChild(i).GetComponent<QuestionCard>();
|
|
|
|
|
+ if (!q.IsQuestionSafe()) {
|
|
|
|
|
+ Destroy(q.gameObject);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
// 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() {
|
|
void YesFunction() {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
int correctAnswer = Int32.Parse(nq.answerString);
|
|
int correctAnswer = Int32.Parse(nq.answerString);
|
|
|
Transform questionBefore = null;
|
|
Transform questionBefore = null;
|
|
|
Transform questionAfter = null;
|
|
Transform questionAfter = null;
|
|
|
try {
|
|
try {
|
|
|
- questionBefore = contentPanel.GetChild(newQuestionSiblingIndex -1 );
|
|
|
|
|
|
|
+ questionBefore = contentPanel.GetChild(newQuestionSiblingIndex - 1);
|
|
|
} catch (UnityException e) { }
|
|
} catch (UnityException e) { }
|
|
|
try {
|
|
try {
|
|
|
- questionAfter = contentPanel.GetChild(newQuestionSiblingIndex );
|
|
|
|
|
|
|
+ questionAfter = contentPanel.GetChild(newQuestionSiblingIndex);
|
|
|
} catch (UnityException e) { }
|
|
} catch (UnityException e) { }
|
|
|
|
|
|
|
|
QuestionCard test = contentPanel.GetChild(0).GetComponent<QuestionCard>();
|
|
QuestionCard test = contentPanel.GetChild(0).GetComponent<QuestionCard>();
|