Commit 48c75590 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fixed A TON OF 5ara in the mcq

parent 860e02c1
......@@ -11,6 +11,7 @@ public class McqCompetitor : MonoBehaviour
private float[] _lanes = new float[4] { -5.8f, -1.8f, 2.2f, 6.2f };
private List<Transform> _runners = new();
private List<Animator> _runnerAnimators = new();
private float _initialSpeed;
private float _currentSpeed;
private bool _isRunning;
......@@ -25,11 +26,12 @@ public class McqCompetitor : MonoBehaviour
var index = i;
_runners.Add(transform.GetChild(i));
_runnerAnimators.Add(_runners[i].GetComponentInChildren<Animator>());
_runners[i].localPosition =
new Vector3(_runners[i].localPosition.x, 0, Random.Range(-3f, 4f));
var delay = Random.Range(0f, 1f);
StartCoroutine(DelayedAction(delay, () => EnableAnimators(_runners[index].gameObject.GetComponent<Animator>())));
StartCoroutine(DelayedAction(delay, () => EnableAnimators(_runnerAnimators[index])));
}
Invoke(nameof(SwitchLane), 4);
......@@ -48,7 +50,6 @@ public class McqCompetitor : MonoBehaviour
public void SetupManager(McqGameManager manager)
{
if (manager == null) print("Null manager");
_manager = manager;
manager.onAnswerGiven?.AddListener(ChangeZLevel);
manager.onGameOver.AddListener(Stop);
......@@ -95,26 +96,25 @@ public class McqCompetitor : MonoBehaviour
}
public void Stop()
{
foreach (Transform runner in _runners)
{
runner.GetComponentInChildren<Animator>().Play("closing");
}
CancelInvoke(nameof(SwitchLane));
for (int i = 0; i < _runners.Count; i++)
_runnerAnimators[i].Play("closing");
_currentSpeed = 0;
_isRunning = false;
}
public void ResetToStart()
{
//Stop();
CancelInvoke(nameof(SwitchLane));
DOTween.Kill(transform);
transform.position = _startPosition;
transform.rotation = Quaternion.identity;
transform.localScale = Vector3.one;
foreach (Transform runner in _runners)
for (int i = 0; i < _runners.Count; i++)
{
runner.DOKill();
runner.transform.localPosition = new Vector3(runner.localPosition.x, 0, Random.Range(2f, 4f));
runner.GetComponentInChildren<Animator>().Play("opening");
_runners[i].DOKill();
_runners[i].localPosition = new Vector3(_runners[i].localPosition.x, 0, Random.Range(2f, 4f));
_runnerAnimators[i].Play("opening");
}
Invoke(nameof(SwitchLane), 4);
}
......
......@@ -21,6 +21,7 @@ namespace com.al_arcade.mcq
private ArabicTextMeshPro _label;
private BoxCollider _collider;
private Material _panelMaterial;
private MaterialPropertyBlock _mpb;
private Sequence _idleAnim;
private Sequence _glowAnim;
......@@ -38,7 +39,7 @@ namespace com.al_arcade.mcq
private const string colorGraph = "_Texture_Tint_Color";
private static Material _sharedGateMaterial;
public void Setup(int index, string text, bool correct)
{
......@@ -53,11 +54,23 @@ namespace com.al_arcade.mcq
public void Start()
{
_panelRenderer.material = new Material(_panelRenderer.material.shader);
_panelMaterial = _panelRenderer.material;
if (_sharedGateMaterial == null)
{
_sharedGateMaterial = new Material(_panelRenderer.material.shader);
_sharedGateMaterial.SetColor("_Hologram_Color", Color.white);
}
_panelRenderer.sharedMaterial = _sharedGateMaterial;
_panelMaterial = _sharedGateMaterial;
_panelMaterial.SetColor(colorGraph, SSColorPalette.GateDefault);
_panelMaterial.SetColor("_Hologram_Color", Color.white);
_mpb = new MaterialPropertyBlock();
SetPanelColor(SSColorPalette.GateDefault);
}
private void SetPanelColor(Color color)
{
if (_panelRenderer == null) return;
_mpb.SetColor(colorGraph, color);
_panelRenderer.SetPropertyBlock(_mpb);
}
private void BuildVisuals()
......@@ -197,8 +210,7 @@ namespace com.al_arcade.mcq
public void PlayCorrectAnimation()
{
KillAllTweens();
if (_panelMaterial != null) _panelMaterial.SetColor(colorGraph, SSColorPalette.GateCorrect);
// if (_panelRenderer != null) _panelRenderer.material.DOColor(SSColorPalette.GateCorrect, 0.3f);
SetPanelColor(SSColorPalette.GateCorrect);
if (CorrectParticle != null) CorrectParticle.Play();
transform.DOPunchScale(Vector3.one * 0.2f, 0.5f, 8, 0.5f);
if (_label != null) _label.transform.DOPunchScale(Vector3.one * 0.3f, 0.4f, 6, 0.3f);
......@@ -207,8 +219,7 @@ namespace com.al_arcade.mcq
public void PlayWrongAnimation()
{
KillAllTweens();
if (_panelMaterial != null) _panelMaterial.SetColor(colorGraph, SSColorPalette.GateWrong);
// if (_panelRenderer != null) _panelRenderer.material.DOColor(SSColorPalette.GateWrong, 0.3f);
SetPanelColor(SSColorPalette.GateWrong);
if (WrongParticle != null) WrongParticle.Play();
transform.DOShakePosition(0.5f, 0.4f, 20, 90f, false, true);
transform.DOShakeRotation(0.5f, 10f, 20, 90f, true);
......
......@@ -56,13 +56,20 @@ namespace com.al_arcade.mcq
public void SetupManager(McqGameManager manager)
{
if (manager == null) print("Null manager");
_manager = manager;
manager.onAnswerGiven?.AddListener(PlayAnimation);
manager.onGameOver?.AddListener(Stop);
manager.onWin?.AddListener(Stop);
}
private void OnDestroy()
{
if (_manager == null) return;
_manager.onAnswerGiven?.RemoveListener(PlayAnimation);
_manager.onGameOver?.RemoveListener(Stop);
_manager.onWin?.RemoveListener(Stop);
}
private void PlayAnimation(bool correct)
{
_animator.ResetTrigger(correct ? "Wrong" : "Correct");
......@@ -162,11 +169,8 @@ namespace com.al_arcade.mcq
Quaternion.identity, Time.deltaTime * 8f);
}
// touch movement
if (Input.touchCount > 0)
{
print("touch detected");
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved)
{
......
......@@ -112,7 +112,6 @@ namespace com.al_arcade.mcq
private void Start()
{
Instance = this;
DOTween.Init();
if (arabicFont != null) SSFontManager.Font = arabicFont;
StartCoroutine(BuildEverything());
}
......@@ -122,7 +121,7 @@ namespace com.al_arcade.mcq
Debug.Log("═══ MCQ Prefab Builder — Starting ═══");
if (FindObjectOfType<EventSystem>() == null)
if (!FindAnyObjectByType<EventSystem>())
{
var es = new GameObject("EventSystem");
es.AddComponent<EventSystem>();
......
......@@ -27,6 +27,7 @@ namespace com.al_arcade.mcq
private Transform _playerTransform;
private bool _visible;
private Camera _mainCamera;
private Coroutine[] _returnCoroutines = new Coroutine[4];
private void Start()
......@@ -127,16 +128,22 @@ namespace com.al_arcade.mcq
private IEnumerator ReturnToBaseColor(int index)
{
yield return new WaitForSeconds(2.8f);
print("Return for " + index);
PanelRenderers[index].DOColor(_baseColor, 0.3f);
}
private void ScheduleReturnToBase(int index)
{
if (_returnCoroutines[index] != null)
StopCoroutine(_returnCoroutines[index]);
_returnCoroutines[index] = StartCoroutine(ReturnToBaseColor(index));
}
public void PlayCorrectAnimation(int index)
{
if (PanelRenderers != null) PanelRenderers[index].DOColor(SSColorPalette.GateCorrect, 0.3f);
transform.DOPunchScale(Vector3.one * 0.2f, 0.5f, 8, 0.5f);
if (AnswerTexts != null) AnswerTexts[index].transform.DOPunchScale(Vector3.one * 0.3f, 0.4f, 6, 0.3f);
StartCoroutine(ReturnToBaseColor(index));
print("Correct for " + index);
ScheduleReturnToBase(index);
}
public void PlayWrongAnimation(int index)
......@@ -144,8 +151,7 @@ namespace com.al_arcade.mcq
if (PanelRenderers != null) PanelRenderers[index].DOColor(SSColorPalette.GateWrong, 0.3f);
transform.DOShakePosition(0.5f, 0.4f, 20, 90f, false, true);
transform.DOShakeRotation(0.5f, 10f, 20, 90f, true);
StartCoroutine(ReturnToBaseColor(index));
print("Wrong for " + index);
ScheduleReturnToBase(index);
}
public void PlayRevealCorrect(int index)
......@@ -160,19 +166,14 @@ namespace com.al_arcade.mcq
}
transform.DOPunchScale(Vector3.one * 0.15f, 0.8f, 4, 0.2f);
StartCoroutine(ReturnToBaseColor(index));
print("Reveal for " + index);
ScheduleReturnToBase(index);
}
public void PlayFadeOut(int index)
{
/*
if (_panelMaterial != null) _panelMaterial.DOFade(0.3f, 0.5f);
*/
if (PanelRenderers != null) PanelRenderers[index].DOFade(0.3f, 0.5f);
transform.DOScale(Vector3.one * 0.8f, 0.5f).SetEase(Ease.InBack);
StartCoroutine(ReturnToBaseColor(index));
print("Fade for " + index);
ScheduleReturnToBase(index);
}
public void Show(McqQuestion question)
......@@ -203,8 +204,7 @@ namespace com.al_arcade.mcq
private void LateUpdate()
{
if (_playerTransform == null) return;
if (!_visible || _playerTransform == null) return;
Vector3 targetPos = _playerTransform.position
+ Vector3.up * floatHeight
......
......@@ -67,6 +67,7 @@ namespace com.al_arcade.mcq
// ✅ NEW: points images list — built from _pointsContainer children
private List<Image> _pointImages = new();
private int _lastPointCount = -1;
private void Awake()
{
......@@ -244,21 +245,27 @@ namespace com.al_arcade.mcq
// count = current _deltaChangeInSize value from game manager
public void TickPoints(int count)
{
bool changed = count != _lastPointCount;
_lastPointCount = count;
for (int i = 0; i < _pointImages.Count; i++)
{
var img = _pointImages[i];
if (i < count)
{
// dot is active — color it and punch scale it
img.color = _activePointColor;
img.transform.DOPunchScale(
Vector3.one * 0.4f, 0.4f)
.SetEase(Ease.OutElastic)
.SetDelay(0.1f * i);
if (changed)
{
DOTween.Kill(img.transform, "dotPunch");
img.transform.DOPunchScale(
Vector3.one * 0.4f, 0.4f)
.SetEase(Ease.OutElastic)
.SetDelay(0.1f * i)
.SetId("dotPunch");
}
}
else
{
// dot is inactive — dim it and reset scale
img.color = SSColorPalette.WithAlpha(_inactivePointColor, 0.3f);
img.transform.localScale = Vector3.one;
}
......@@ -357,7 +364,7 @@ namespace com.al_arcade.mcq
if (_timerFill != null) _timerFill.color = _timerDefaultColor;
if (_timerText != null) _timerText.Text = "";
// ✅ NEW: reset points dots to all inactive
_lastPointCount = -1;
TickPoints(0);
_isTweening = false;
......
......@@ -76,7 +76,6 @@ MonoBehaviour:
- rid: 1321912066682388556
- rid: 1321912066682388558
- rid: 1321912066682388559
- rid: 1321912066682388560
- rid: 1321912066682388561
- rid: 1321912066682388562
- rid: 1321912066682388568
......
......@@ -17,7 +17,7 @@ PlayerSettings:
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
m_ShowUnitySplashScreen: 1
m_ShowUnitySplashScreen: 0
m_ShowUnitySplashLogo: 0
m_SplashScreenOverlayOpacity: 1
m_SplashScreenAnimation: 1
......@@ -116,7 +116,6 @@ PlayerSettings:
xboxEnableGuest: 0
xboxEnablePIXSampling: 0
metalFramebufferOnly: 0
metalUseMetalDisplayLink: 0
xboxOneResolution: 0
xboxOneSResolution: 0
xboxOneXResolution: 3
......@@ -271,13 +270,13 @@ PlayerSettings:
useCustomGradlePropertiesTemplate: 0
useCustomGradleSettingsTemplate: 0
useCustomProguardFile: 0
AndroidTargetArchitectures: 2
AndroidTargetArchitectures: 3
AndroidAllowedArchitectures: -13
AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0}
AndroidKeystoreName:
AndroidKeyaliasName:
AndroidEnableArmv9SecurityFeatures: 0
AndroidKeystoreName: '{dedicated}: Desktop/SSbook.keystore'
AndroidKeyaliasName: ssbook
AndroidEnableArmv9SecurityFeatures: 1
AndroidEnableArm64MTE: 0
AndroidBuildApkPerCpuArchitecture: 0
AndroidTVCompatibility: 0
......@@ -288,7 +287,7 @@ PlayerSettings:
AndroidEnableTango: 0
androidEnableBanner: 1
androidUseLowAccuracyLocation: 0
androidUseCustomKeystore: 0
androidUseCustomKeystore: 1
m_AndroidBanners:
- width: 320
height: 180
......@@ -409,6 +408,38 @@ PlayerSettings:
- m_BuildTarget: Android
m_Icons:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 0
m_SubKind:
- m_Textures:
- {fileID: 2800000, guid: 38e324f2965ad4660b4aefaba2575df8, type: 3}
- {fileID: 2800000, guid: 980570066fb5dd74abc396427104080f, type: 3}
m_Width: 432
m_Height: 432
m_Kind: 2
......@@ -438,66 +469,42 @@ PlayerSettings:
m_Height: 81
m_Kind: 2
m_SubKind:
- m_Textures: []
- m_Textures:
- {fileID: 0}
m_Width: 192
m_Height: 192
m_Kind: 1
m_SubKind:
- m_Textures: []
- m_Textures:
- {fileID: 0}
m_Width: 144
m_Height: 144
m_Kind: 1
m_SubKind:
- m_Textures: []
- m_Textures:
- {fileID: 0}
m_Width: 96
m_Height: 96
m_Kind: 1
m_SubKind:
- m_Textures: []
- m_Textures:
- {fileID: 0}
m_Width: 72
m_Height: 72
m_Kind: 1
m_SubKind:
- m_Textures: []
- m_Textures:
- {fileID: 0}
m_Width: 48
m_Height: 48
m_Kind: 1
m_SubKind:
- m_Textures: []
- m_Textures:
- {fileID: 0}
m_Width: 36
m_Height: 36
m_Kind: 1
m_SubKind:
- m_Textures: []
m_Width: 192
m_Height: 192
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 144
m_Height: 144
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 96
m_Height: 96
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 72
m_Height: 72
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 48
m_Height: 48
m_Kind: 0
m_SubKind:
- m_Textures: []
m_Width: 36
m_Height: 36
m_Kind: 0
m_SubKind:
- m_BuildTarget: tvOS
m_Icons:
- m_Textures: []
......
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