73 lines
2.4 KiB
C#
Raw Normal View History

2025-05-29 20:41:47 +05:00
using UnityEngine;
using UnityEngine.UI;
using TMPro;
2025-06-07 19:06:25 +05:00
using ArabicSupport;
2025-05-29 20:41:47 +05:00
public class MiniQuizManager : MonoBehaviour
{
2025-06-23 14:13:43 +05:00
public Button[] answerButtons;
public TextMeshProUGUI[] answerLabels;
2025-05-29 20:41:47 +05:00
public TextMeshProUGUI feedbackText;
2025-06-23 14:13:43 +05:00
public GameObject restartButton;
2025-07-24 20:42:58 +05:00
public GameObject restartButtonArabic;
2025-05-29 20:41:47 +05:00
private string[] answerTexts = new string[]
{
"Typos in the subject",
"Urgent language",
"Mismatched sender email",
"All of the above"
};
2025-06-07 19:06:25 +05:00
private string[] answerTextsAr = new string[]
{
"أخطاء مطبعية في العنوان",
"لغة مستعجلة",
"عنوان بريد مرسل غير متطابق",
"جميع ما سبق"
};
2025-05-29 20:41:47 +05:00
private int correctIndex = 3;
public void SubmitAnswer(int selectedIndex)
{
2025-06-25 23:14:09 +05:00
NarrationPlayer.Instance.PlayNarration(NarrationID.GameEnd);
2025-07-24 20:42:58 +05:00
2025-06-07 19:06:25 +05:00
bool isArabic = LanguageManager.Instance != null &&
LanguageManager.Instance.currentLanguage == "Arabic";
2025-07-24 20:42:58 +05:00
(isArabic ? restartButtonArabic : restartButton).SetActive(true);
2025-06-07 19:06:25 +05:00
2025-05-29 20:41:47 +05:00
string selectedAnswer = answerTexts[selectedIndex];
2025-06-07 19:06:25 +05:00
string selectedAnswerAr = answerTextsAr[selectedIndex];
UserActionLogger.Instance?.LogQuizAnswer(selectedAnswer, selectedAnswerAr);
2025-05-29 20:41:47 +05:00
if (selectedIndex == correctIndex)
{
2025-06-07 19:06:25 +05:00
feedbackText.text = isArabic
2025-06-23 14:13:43 +05:00
? ArabicFixer.Fix("إجابة صحيحة! جميعها كانت إشارات خطر.")
: "Correct! All of those were red flags.";
2025-05-29 20:41:47 +05:00
}
else
{
2025-06-07 19:06:25 +05:00
string correctAnswer = answerTexts[correctIndex];
string correctAnswerAr = answerTextsAr[correctIndex];
feedbackText.text = isArabic
2025-06-23 14:13:43 +05:00
? ArabicFixer.Fix($"ليست الإجابة الصحيحة. الإجابة الصحيحة هي: {correctAnswerAr}")
: $"Not quite. The correct answer was: {correctAnswer}";
2025-05-29 20:41:47 +05:00
}
foreach (var btn in answerButtons)
btn.interactable = false;
answerLabels[selectedIndex].text = "✅ " + answerLabels[selectedIndex].text;
2025-06-11 21:12:00 +05:00
bool isCorrect = (selectedIndex == correctIndex);
SupabaseEventLogger.Instance?.LogDecisionEvent(isCorrect);
2025-06-23 14:13:43 +05:00
SceneOutcomeManager.Instance.OnEmailDecision(isCorrect, 5);
SupabaseEventLogger.Instance.LogScoreEvent(PlayerPrefs.GetInt("Score"));
2025-05-29 20:41:47 +05:00
}
}