Commit c7279f62 authored by mohamed20047's avatar mohamed20047

add best streak. and handle its UI in result menu

parent 173a851c
......@@ -154,7 +154,7 @@ namespace com.al_arcade.cs
protected override void BeginGameplay()
{
_currentIndex = _score = _streak = _correctCount = _wrongCount = 0;
_currentIndex = _score = _streak = _correctCount = _wrongCount = _bestStreak = 0;
_deltaChangeInSize = 0;
_timeLeft = CsPrefabBuilder.Instance.startTime; // CS uses its own start time
_timerRunning = true;
......@@ -225,6 +225,7 @@ namespace com.al_arcade.cs
AdjustTimer(-CsPrefabBuilder.Instance.wrongAnswerPenaltyTime);
_wrongClicks++;
_wordClickLocked = true;
_streak = 0; // reset streak when click on worng word
wordButton.ShakeWrong();
SSAudioManager.Instance?.PlayWrongBeep();
StartCoroutine(UnlockAfterCooldown());
......@@ -323,6 +324,7 @@ namespace com.al_arcade.cs
_state = CsGameState.Feedback;
_correctCount++;
_streak++;
if (_streak > _bestStreak) _bestStreak = _streak;
_deltaChangeInSize++;
AdjustTimer(CsPrefabBuilder.Instance.correctAnswerBonusTime);
......@@ -415,7 +417,7 @@ namespace com.al_arcade.cs
StartCoroutine(DelayedAction(0.7f, () => SSAudioManager.Instance.PlayCheer())); // shared helper
yield return new WaitForSeconds(1f);
uiManager?.ShowResults(_score, _correctCount, _wrongClicks, _questions.Length, _streak);
uiManager?.ShowResults(_score, _correctCount, _wrongClicks, _questions.Length, _bestStreak);
onGameComplete?.Invoke(_score);
ClearWordButtons();
......@@ -423,7 +425,7 @@ namespace com.al_arcade.cs
protected override IEnumerator NoChallengeLoseSequence()
{
uiManager?.ShowResults(_score, _correctCount, _wrongClicks, _questions.Length, _streak, false);
uiManager?.ShowResults(_score, _correctCount, _wrongClicks, _questions.Length, _bestStreak, false);
yield return null;
}
......
......@@ -476,12 +476,13 @@ namespace com.al_arcade.cs
_resultsUI.alpha = 0;
float pct = total > 0 ? (float)correct / total * 100f : 0;
if (_resultTitle != null)
_resultTitle.Text = win ? pct >= 70 ? "أحسنت!" : "عمل جيد!" : "حظ اوفر";
if (_resultScore != null) _resultScore.Text = score.ToString("N0");
//if (_resultTitle != null)
// _resultTitle.Text = win ? pct >= 70 ? "أحسنت!" : "عمل جيد!" : "حظ اوفر";
//if (_resultScore != null) _resultScore.Text = score.ToString("N0");
if (_resultStats != null)
_resultStats.Text = $"صحيح: {correct} | " +
$"المحاولات الخاطئة: {wrong} ";
$"المحاولات الخاطئة: {wrong} | " +
$"أعلى سلسلة: {bestStreak}";
var seq = DOTween.Sequence();
seq.Append(_resultsUI.DOFade(1f, 0.5f));
......
......@@ -43,7 +43,7 @@ namespace com.al_arcade.mcq
public McqGameState State => _state;
private McqQuestion[] _questions;
private int _bestStreak;
private List<McqGateController> _activeGates = new();
private int _correctGateIndex = -1;
private int _selectedGateIndex = -1;
......@@ -224,7 +224,6 @@ namespace com.al_arcade.mcq
{
ResetBaseState();
_state = McqGameState.Idle;
_bestStreak = 0;
_isTicking = false;
// ✅ NEW: reset delta on full reset
_deltaChangeInSize = 0;
......@@ -651,7 +650,7 @@ namespace com.al_arcade.mcq
yield return new WaitForSeconds(0.5f);
if (uiManager != null)
uiManager.ShowResults(_score, _correctCount, _wrongCount,
_bestStreak, _questions.Length, true);
_questions.Length, _bestStreak, true);
onGameComplete?.Invoke(_score);
}
......@@ -676,11 +675,9 @@ namespace com.al_arcade.mcq
yield return new WaitForSeconds(0.5f);
if (uiManager != null)
uiManager.ShowResults(_score, _correctCount, _wrongCount,
_bestStreak, _questions.Length, false);
_questions.Length, _bestStreak, false);
onGameOver?.Invoke();
}
public int BestStreak => _bestStreak;
public int TotalQuestions => _questions?.Length ?? 0;
}
}
\ No newline at end of file
......@@ -294,11 +294,12 @@ namespace com.al_arcade.mcq
_resultsUI.gameObject.SetActive(true);
_resultsUI.alpha = 0;
if (_resultTitle != null) _resultTitle.Text = win ? "أحسنت!" : "حظ أوفر!";
if (_resultScore != null) _resultScore.Text = score.ToString("N0");
//if (_resultTitle != null) _resultTitle.Text = win ? "أحسنت!" : "حظ أوفر!";
//if (_resultScore != null) _resultScore.Text = score.ToString("N0");
if (_resultStats != null)
_resultStats.Text = $"صحيح: {correct} | " +
$"المحاولات الخاطئة: {wrong} " ;
$"المحاولات الخاطئة: {wrong} | " +
$"أعلى سلسلة: {bestStreak}"; ;
if (_winIcon != null) _winIcon.SetActive(win);
if (_loseIcon != null) _loseIcon.SetActive(!win);
......
......@@ -30,6 +30,7 @@ namespace com.al_arcade.shared
// ─── Shared runtime state ────────────────────────────────────────────
protected int _score;
protected int _streak;
protected int _bestStreak;
protected int _correctCount;
protected int _wrongCount;
protected int _currentIndex;
......@@ -219,7 +220,7 @@ namespace com.al_arcade.shared
protected void ResetBaseState()
{
StopAllCoroutines();
_score = _streak = _correctCount = _wrongCount = _currentIndex = _totalAsked = 0;
_score = _streak = _correctCount = _wrongCount = _currentIndex = _totalAsked =_bestStreak= 0;
_timeLeft = 0f;
_timerRunning = false;
}
......
......@@ -99,7 +99,7 @@ namespace com.al_arcade.tf
protected override void BeginGameplay()
{
_progress = 0;
_currentIndex = _score = _streak = _correctCount = _wrongCount = _totalAsked = 0;
_currentIndex = _score = _streak = _correctCount = _wrongCount = _totalAsked = _bestStreak = 0;
_state = TfGameState.Playing;
if (uiManager != null)
......@@ -199,6 +199,7 @@ namespace com.al_arcade.tf
{
_correctCount++;
_streak++;
if (_streak > _bestStreak) _bestStreak = _streak;
_progress++;
int points = CalculateStreakScore();
_score += points;
......@@ -212,7 +213,7 @@ namespace com.al_arcade.tf
if (handController != null) handController.PlayCorrectFeedback(playerSaidTrue);
if (productionLine != null) yield return productionLine.MoveForward(stepDistance);
if (questionScreen != null) questionScreen.ShowFeedback(true, _streak);
//if (questionScreen != null) questionScreen.ShowFeedback(true, _streak);
if (uiManager != null) uiManager.ShowFeedback($"ممتاز!", true);
......@@ -239,7 +240,7 @@ namespace com.al_arcade.tf
if (handController != null) handController.PlayWrongFeedback(playerSaidTrue);
if (productionLine != null) yield return productionLine.MoveBackward(stepDistance);
if (questionScreen != null) questionScreen.ShowFeedback(false, 0);
//if (questionScreen != null) questionScreen.ShowFeedback(false, 0);
if (uiManager != null) uiManager.ShowFeedback("حاول مرة أخرى", false);
......@@ -305,7 +306,7 @@ namespace com.al_arcade.tf
protected override IEnumerator NoChallengeLoseSequence()
{
yield return new WaitForSeconds(1f);
uiManager?.ShowResults(_score, _correctCount, _wrongCount,_questions.Length, _streak, false);
uiManager?.ShowResults(_score, _correctCount, _wrongCount,_questions.Length, _bestStreak, false);
onGameOver?.Invoke();
}
......@@ -327,7 +328,7 @@ namespace com.al_arcade.tf
protected override IEnumerator NoChallengeVictorySequence()
{
yield return new WaitForSeconds(1.5f);
uiManager?.ShowResults(_score, _correctCount, _wrongCount,_questions.Length ,_streak);
uiManager?.ShowResults(_score, _correctCount, _wrongCount,_questions.Length ,_bestStreak);
onGameComplete?.Invoke();
}
......
......@@ -234,11 +234,12 @@ namespace com.al_arcade.tf
_resultsUI.gameObject.SetActive(true);
_resultsUI.alpha = 0;
if (_resultTitle != null) _resultTitle.Text = win ? "نجحت المهمة" : "حاول مجدداً";
if (_resultScore != null) _resultScore.Text = score.ToString("N0");
//if (_resultTitle != null) _resultTitle.Text = win ? "نجحت المهمة" : "حاول مجدداً";
//if (_resultScore != null) _resultScore.Text = score.ToString("N0");
if (_resultStats != null)
_resultStats.Text = $"صحيح: {correct} | " +
$"المحاولات الخاطئة: {wrong} " ;
$"المحاولات الخاطئة: {wrong} | " +
$"أعلى سلسلة: {bestStreak}"; ;
var seq = DOTween.Sequence();
seq.Append(_resultsUI.DOFade(1, 0.4f));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment