Commit b1508c50 authored by mohamed20047's avatar mohamed20047

add Popup feedback with points

parent ec27480c
...@@ -1321,20 +1321,27 @@ MonoBehaviour: ...@@ -1321,20 +1321,27 @@ MonoBehaviour:
_loadingUI: {fileID: 4105729685514656015} _loadingUI: {fileID: 4105729685514656015}
_errorUI: {fileID: 8668403456112399721} _errorUI: {fileID: 8668403456112399721}
_resultsUI: {fileID: 8614017441097344094} _resultsUI: {fileID: 8614017441097344094}
_feedbackGroup: {fileID: 5181556637890600282}
_scoreText: {fileID: 5935917613051726348} _scoreText: {fileID: 5935917613051726348}
_streakText: {fileID: 6655817245277015576} _streakText: {fileID: 6655817245277015576}
_scoreLbl: {fileID: 0}
_loadingText: {fileID: 2750036649835959240} _loadingText: {fileID: 2750036649835959240}
_errorText: {fileID: 5202410726077148544} _errorText: {fileID: 5202410726077148544}
_progressLabel: {fileID: 876496144990673683} _progressLabel: {fileID: 876496144990673683}
_resultTitle: {fileID: 7300533697225226430} _resultTitle: {fileID: 7300533697225226430}
_resultScore: {fileID: 5737192048517657640} _resultScore: {fileID: 5737192048517657640}
_resultStats: {fileID: 1630567241621742439} _resultStats: {fileID: 1630567241621742439}
_feedbackText: {fileID: 2735330587039562112}
_feedbackBg: {fileID: 8779464442449399176}
_restartButton: {fileID: 7997833608038347806} _restartButton: {fileID: 7997833608038347806}
_returnToHomeButton: {fileID: 7997833608038347806} _returnToHomeButton: {fileID: 7997833608038347806}
_timerSlider: {fileID: 4514849613205295364} _timerSlider: {fileID: 4514849613205295364}
_timerFill: {fileID: 4203006633935581820} _timerFill: {fileID: 4203006633935581820}
_timerText: {fileID: 1760636326841778451} _timerText: {fileID: 1760636326841778451}
_maxTime: 30 _maxTime: 30
_pointsContainer: {fileID: 0}
_activePointColor: {r: 0, g: 0, b: 0, a: 0}
_inactivePointColor: {r: 0, g: 0, b: 0, a: 0}
onRestartClicked: onRestartClicked:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
......
...@@ -33,10 +33,10 @@ RectTransform: ...@@ -33,10 +33,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5824509147393400757} m_Father: {fileID: 5824509147393400757}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 22.572838, y: -25.96685} m_AnchoredPosition: {x: 22.572838, y: 0}
m_SizeDelta: {x: 0, y: 51.9337} m_SizeDelta: {x: 51.9337, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &9055497536415541340 --- !u!222 &9055497536415541340
CanvasRenderer: CanvasRenderer:
...@@ -868,10 +868,10 @@ RectTransform: ...@@ -868,10 +868,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5824509147393400757} m_Father: {fileID: 5824509147393400757}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 144.8642, y: -25.96685} m_AnchoredPosition: {x: 144.8642, y: 0}
m_SizeDelta: {x: 0, y: 51.9337} m_SizeDelta: {x: 51.9337, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6316850651786239132 --- !u!222 &6316850651786239132
CanvasRenderer: CanvasRenderer:
...@@ -1210,10 +1210,10 @@ RectTransform: ...@@ -1210,10 +1210,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5824509147393400757} m_Father: {fileID: 5824509147393400757}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 83.71851, y: -25.96685} m_AnchoredPosition: {x: 83.71851, y: 0}
m_SizeDelta: {x: 0, y: 51.9337} m_SizeDelta: {x: 51.9337, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6319844450247911941 --- !u!222 &6319844450247911941
CanvasRenderer: CanvasRenderer:
...@@ -2195,10 +2195,10 @@ RectTransform: ...@@ -2195,10 +2195,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5824509147393400757} m_Father: {fileID: 5824509147393400757}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 206.00986, y: -25.96685} m_AnchoredPosition: {x: 206.00986, y: 0}
m_SizeDelta: {x: 0, y: 51.9337} m_SizeDelta: {x: 51.9337, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3778932895135096301 --- !u!222 &3778932895135096301
CanvasRenderer: CanvasRenderer:
...@@ -2380,6 +2380,7 @@ MonoBehaviour: ...@@ -2380,6 +2380,7 @@ MonoBehaviour:
_loadingUI: {fileID: 948396739458356726} _loadingUI: {fileID: 948396739458356726}
_errorUI: {fileID: 4448024252030771562} _errorUI: {fileID: 4448024252030771562}
_resultsUI: {fileID: 1265578760517736726} _resultsUI: {fileID: 1265578760517736726}
_feedbackGroup: {fileID: 4497114863431471683}
_scoreText: {fileID: 7283828466168530179} _scoreText: {fileID: 7283828466168530179}
_streakText: {fileID: 3088443959907424236} _streakText: {fileID: 3088443959907424236}
_scoreLbl: {fileID: 5924483057703210132} _scoreLbl: {fileID: 5924483057703210132}
...@@ -2389,6 +2390,8 @@ MonoBehaviour: ...@@ -2389,6 +2390,8 @@ MonoBehaviour:
_resultTitle: {fileID: 3377821766872872317} _resultTitle: {fileID: 3377821766872872317}
_resultScore: {fileID: 2058651398905202117} _resultScore: {fileID: 2058651398905202117}
_resultStats: {fileID: 2189195751882486028} _resultStats: {fileID: 2189195751882486028}
_feedbackText: {fileID: 2715045871399486055}
_feedbackBg: {fileID: 609508365388699558}
_restartButton: {fileID: 2142933248170327394} _restartButton: {fileID: 2142933248170327394}
_returnToHomeButton: {fileID: 6128910297614538796} _returnToHomeButton: {fileID: 6128910297614538796}
_timerSlider: {fileID: 3613290988306101471} _timerSlider: {fileID: 3613290988306101471}
...@@ -2828,10 +2831,10 @@ RectTransform: ...@@ -2828,10 +2831,10 @@ RectTransform:
m_Children: [] m_Children: []
m_Father: {fileID: 5824509147393400757} m_Father: {fileID: 5824509147393400757}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 267.15555, y: -25.96685} m_AnchoredPosition: {x: 267.15555, y: 0}
m_SizeDelta: {x: 0, y: 51.9337} m_SizeDelta: {x: 51.9337, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1293769170803587111 --- !u!222 &1293769170803587111
CanvasRenderer: CanvasRenderer:
......
...@@ -200,7 +200,10 @@ namespace com.al_arcade.tf ...@@ -200,7 +200,10 @@ namespace com.al_arcade.tf
_correctCount++; _correctCount++;
_streak++; _streak++;
_progress++; _progress++;
_score += CalculateStreakScore(); int points = CalculateStreakScore();
_score += points;
// timer before productionLine to avoid Race Condition // timer before productionLine to avoid Race Condition
UpdateTimerBy(4f); UpdateTimerBy(4f);
...@@ -211,6 +214,8 @@ namespace com.al_arcade.tf ...@@ -211,6 +214,8 @@ namespace com.al_arcade.tf
if (productionLine != null) yield return productionLine.MoveForward(stepDistance); 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($"ممتاز! {points}+", true);
var audio = SSAudioManager.Instance; var audio = SSAudioManager.Instance;
if (audio != null) if (audio != null)
{ if (audio.sfxCorrect != null) audio.PlayCorrect(); else audio.PlayCorrectBeep(); } { if (audio.sfxCorrect != null) audio.PlayCorrect(); else audio.PlayCorrectBeep(); }
...@@ -227,10 +232,17 @@ namespace com.al_arcade.tf ...@@ -227,10 +232,17 @@ namespace com.al_arcade.tf
_streak = 0; _streak = 0;
_progress = Mathf.Max(0, _progress - 1); _progress = Mathf.Max(0, _progress - 1);
// timer before productionLine to avoid Race Condition
UpdateTimerBy(-2f);
uiManager?.UpdateTimer(_timeLeft, false);
if (handController != null) handController.PlayWrongFeedback(playerSaidTrue); if (handController != null) handController.PlayWrongFeedback(playerSaidTrue);
if (productionLine != null) yield return productionLine.MoveBackward(stepDistance); 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);
var audio = SSAudioManager.Instance; var audio = SSAudioManager.Instance;
if (audio != null) if (audio != null)
{ if (audio.sfxWrong != null) audio.PlayWrong(); else audio.PlayWrongBeep(); } { if (audio.sfxWrong != null) audio.PlayWrong(); else audio.PlayWrongBeep(); }
...@@ -242,8 +254,6 @@ namespace com.al_arcade.tf ...@@ -242,8 +254,6 @@ namespace com.al_arcade.tf
.SetEase(Ease.OutQuad).SetId("camShake"); .SetEase(Ease.OutQuad).SetId("camShake");
} }
UpdateTimerBy(-2f);
uiManager?.UpdateTimer(_timeLeft, false);
} }
onAnswerGiven?.Invoke(isCorrect); onAnswerGiven?.Invoke(isCorrect);
......
...@@ -15,11 +15,13 @@ namespace com.al_arcade.tf ...@@ -15,11 +15,13 @@ namespace com.al_arcade.tf
public class TfUIManager : MonoBehaviour public class TfUIManager : MonoBehaviour
{ {
[SerializeField] private Canvas _canvas; [SerializeField] private Canvas _canvas;
[SerializeField] private CanvasGroup _gameUI, _loadingUI, _errorUI, _resultsUI; [SerializeField] private CanvasGroup _gameUI, _loadingUI, _errorUI, _resultsUI , _feedbackGroup;
[SerializeField] private UniText _scoreText, _streakText, _scoreLbl; [SerializeField] private UniText _scoreText, _streakText, _scoreLbl;
[SerializeField] private ArabicTextMeshProUGUI _loadingText, _errorText; [SerializeField] private ArabicTextMeshProUGUI _loadingText, _errorText;
[SerializeField] private UniText _progressLabel; [SerializeField] private UniText _progressLabel;
[SerializeField] private UniText _resultTitle, _resultScore, _resultStats; [SerializeField] private UniText _resultTitle, _resultScore, _resultStats;
[SerializeField] private UniText _feedbackText;
[SerializeField] private Image _feedbackBg;
[SerializeField] private Button _restartButton; [SerializeField] private Button _restartButton;
[SerializeField] protected Button _returnToHomeButton; [SerializeField] protected Button _returnToHomeButton;
...@@ -181,6 +183,27 @@ namespace com.al_arcade.tf ...@@ -181,6 +183,27 @@ namespace com.al_arcade.tf
if (_progressLabel != null) if (_progressLabel != null)
_progressLabel.Text = $"{cur} / {total}"; _progressLabel.Text = $"{cur} / {total}";
} }
public void ShowFeedback(string message, bool isCorrect)
{
if (_feedbackText != null) _feedbackText.Text = message;
if (_feedbackBg != null)
_feedbackBg.color = SSColorPalette.WithAlpha(
isCorrect ? SSColorPalette.Success : SSColorPalette.Danger, 0.92f);
DOTween.Kill(_feedbackGroup, "fbAnim");
_feedbackGroup.alpha = 0;
var bgRect = _feedbackBg?.rectTransform;
if (bgRect != null)
{
bgRect.localScale = new Vector3(0.3f, 0f, 1f);
var seq = DOTween.Sequence().SetId("fbAnim");
seq.Append(_feedbackGroup.DOFade(1f, 0.12f));
seq.Join(bgRect.DOScaleX(1f, 0.25f).SetEase(Ease.OutBack));
seq.Join(bgRect.DOScaleY(1f, 0.2f).SetEase(Ease.OutBack).SetDelay(0.04f));
seq.AppendInterval(1f);
seq.Append(_feedbackGroup.DOFade(0f, 0.3f));
}
}
// ─── Loading / Error ────────────────────────────────────────────────── // ─── Loading / Error ──────────────────────────────────────────────────
......
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