Commit 3ea8a212 authored by Yousef Sameh's avatar Yousef Sameh

2D

parent fe4b8e7f
...@@ -118,15 +118,15 @@ PrefabInstance: ...@@ -118,15 +118,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3} - target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalScale.x propertyPath: m_LocalScale.x
value: 20 value: 15
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3} - target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalScale.y propertyPath: m_LocalScale.y
value: 20 value: 15
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3} - target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalScale.z propertyPath: m_LocalScale.z
value: 20 value: 15
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3} - target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
......
...@@ -76,10 +76,10 @@ MonoBehaviour: ...@@ -76,10 +76,10 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::ScienceStreet.Shared.FloatingScienceSpawner m_EditorClassIdentifier: Assembly-CSharp::ScienceStreet.Shared.FloatingScienceSpawner
spawnCount: 12 spawnCount: 12
areaSize: {x: 50, y: 18, z: 10} areaSize: {x: 20, y: 10, z: 10}
areaCenterOffset: {x: 0, y: 0, z: 0} areaCenterOffset: {x: 0, y: 0, z: 0}
minScale: 1.2 minScale: 0.4
maxScale: 2 maxScale: 0.7
jitterAmount: 0.8 jitterAmount: 0.8
gizmoColor: {r: 0, g: 1, b: 1, a: 0.3} gizmoColor: {r: 0, g: 1, b: 1, a: 0.3}
showGizmoAlways: 1 showGizmoAlways: 1
......
...@@ -261,6 +261,7 @@ MonoBehaviour: ...@@ -261,6 +261,7 @@ MonoBehaviour:
gradeId: 0 gradeId: 0
questionCount: 8 questionCount: 8
classCode: classCode:
wordSprite: {fileID: 21300000, guid: a54a00aa58b9b455c895e9312d25164d, type: 3}
useOfflineTestData: 0 useOfflineTestData: 0
--- !u!4 &1145369048 --- !u!4 &1145369048
Transform: Transform:
...@@ -356,7 +357,7 @@ Camera: ...@@ -356,7 +357,7 @@ Camera:
near clip plane: 0.3 near clip plane: 0.3
far clip plane: 1000 far clip plane: 1000
field of view: 60 field of view: 60
orthographic: 0 orthographic: 1
orthographic size: 5 orthographic size: 5
m_Depth: -1 m_Depth: -1
m_CullingMask: m_CullingMask:
......
...@@ -13,7 +13,7 @@ namespace com.al_arcade.cs ...@@ -13,7 +13,7 @@ namespace com.al_arcade.cs
[AddComponentMenu("Science Street/CS Prefab Builder")] [AddComponentMenu("Science Street/CS Prefab Builder")]
public class CsPrefabBuilder : MonoBehaviour public class CsPrefabBuilder : MonoBehaviour
{ {
public static CsPrefabBuilder Instance { get; private set; }
[Header("Scene Environment")] [Header("Scene Environment")]
[Tooltip("Your full environment prefab (ground, platform, decorations, etc). Spawned at origin.")] [Tooltip("Your full environment prefab (ground, platform, decorations, etc). Spawned at origin.")]
...@@ -87,6 +87,9 @@ namespace com.al_arcade.cs ...@@ -87,6 +87,9 @@ namespace com.al_arcade.cs
[SerializeField] private int questionCount = 8; [SerializeField] private int questionCount = 8;
[SerializeField] private string classCode = ""; [SerializeField] private string classCode = "";
[Header("Word")]
public Sprite wordSprite;
[Header("Debug")] [Header("Debug")]
[SerializeField] private bool useOfflineTestData = false; [SerializeField] private bool useOfflineTestData = false;
...@@ -98,6 +101,8 @@ namespace com.al_arcade.cs ...@@ -98,6 +101,8 @@ namespace com.al_arcade.cs
private void Start() private void Start()
{ {
Instance = this;
DOTween.Init(); DOTween.Init();
if (arabicFont != null) SSFontManager.Font = arabicFont; if (arabicFont != null) SSFontManager.Font = arabicFont;
StartCoroutine(BuildEverything()); StartCoroutine(BuildEverything());
......
...@@ -15,7 +15,7 @@ namespace com.al_arcade.cs ...@@ -15,7 +15,7 @@ namespace com.al_arcade.cs
public int Index { get; private set; } public int Index { get; private set; }
private GameObject _background; private GameObject _background;
private Material _bgMaterial; // private Material _bgMaterial; // Removed shader material usage
private Canvas _canvas; private Canvas _canvas;
private UniText _uniText; // Assuming the class name is UniText in UniText namespace private UniText _uniText; // Assuming the class name is UniText in UniText namespace
private BoxCollider _collider; private BoxCollider _collider;
...@@ -24,8 +24,7 @@ namespace com.al_arcade.cs ...@@ -24,8 +24,7 @@ namespace com.al_arcade.cs
private Sequence _idleAnim; private Sequence _idleAnim;
private float _cardWidth; private float _cardWidth;
private float _cardHeight = 0.8f; private float _cardHeight = 0.8f;
private Image _backgroundImage;
private Sprite _wordSprite;
public void Setup(string text, bool isWrong, int index, public void Setup(string text, bool isWrong, int index,
...@@ -49,20 +48,14 @@ namespace com.al_arcade.cs ...@@ -49,20 +48,14 @@ namespace com.al_arcade.cs
private void BuildVisuals() private void BuildVisuals()
{ {
var shader = Shader.Find("ScienceStreet/SciFiTextBackground")
?? Shader.Find("Standard") ?? Shader.Find("Unlit/Color");
_background = GameObject.CreatePrimitive(PrimitiveType.Cube); _background = GameObject.CreatePrimitive(PrimitiveType.Cube);
_background.name = "WordBg"; _background.name = "WordBg";
_background.transform.SetParent(transform); _background.transform.SetParent(transform);
_background.transform.localPosition = Vector3.zero; _background.transform.localPosition = Vector3.zero;
_background.transform.localScale = new Vector3(_cardWidth, _cardHeight, 0.08f); _background.transform.localScale = new Vector3(_cardWidth, _cardHeight, 0.08f);
Destroy(_background.GetComponent<Collider>()); Destroy(_background.GetComponent<Collider>());
Destroy(_background.GetComponent<MeshRenderer>());
_bgMaterial = new Material(shader); Destroy(_background.GetComponent<MeshFilter>());
_bgMaterial.SetFloat("_State", 0f);
_background.GetComponent<Renderer>().material = _bgMaterial;
_background.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
var canvasObj = new GameObject("WordCanvas"); var canvasObj = new GameObject("WordCanvas");
canvasObj.transform.SetParent(transform); canvasObj.transform.SetParent(transform);
...@@ -78,6 +71,12 @@ namespace com.al_arcade.cs ...@@ -78,6 +71,12 @@ namespace com.al_arcade.cs
rt.localScale = new Vector3(canvasScale, canvasScale, canvasScale); rt.localScale = new Vector3(canvasScale, canvasScale, canvasScale);
rt.sizeDelta = new Vector2(_cardWidth / canvasScale, _cardHeight / canvasScale); rt.sizeDelta = new Vector2(_cardWidth / canvasScale, _cardHeight / canvasScale);
_backgroundImage = canvasObj.AddComponent<Image>();
_backgroundImage.sprite = CsPrefabBuilder.Instance.wordSprite;
_backgroundImage.type = Image.Type.Sliced;
_backgroundImage.pixelsPerUnitMultiplier = 3f;
_backgroundImage.color = SSColorPalette.NeutralWord;
var textObj = new GameObject("UniText"); var textObj = new GameObject("UniText");
textObj.transform.SetParent(canvasObj.transform); textObj.transform.SetParent(canvasObj.transform);
textObj.transform.localPosition = Vector3.zero; textObj.transform.localPosition = Vector3.zero;
...@@ -137,7 +136,7 @@ namespace com.al_arcade.cs ...@@ -137,7 +136,7 @@ namespace com.al_arcade.cs
_idleAnim?.Kill(); _idleAnim?.Kill();
_idleAnim = null; _idleAnim = null;
DOTween.Kill(transform); DOTween.Kill(transform);
if (_bgMaterial != null) DOTween.Kill(_bgMaterial); if (_backgroundImage != null) DOTween.Kill(_backgroundImage);
} }
...@@ -165,24 +164,20 @@ namespace com.al_arcade.cs ...@@ -165,24 +164,20 @@ namespace com.al_arcade.cs
private void UpdateVisuals() private void UpdateVisuals()
{ {
DOTween.Kill(_bgMaterial, "color"); DOTween.Kill(_backgroundImage, "color");
DOTween.Kill(transform, "scale"); DOTween.Kill(transform, "scale");
if (_isHighlighted) if (_isHighlighted)
{ {
// Pulsing highlight state Color target = SSColorPalette.Primary;
_bgMaterial.SetFloat("_State", 1f); _backgroundImage.DOColor(target, 0.2f).SetId("color");
Color target = SSColorPalette.WithAlpha(SSColorPalette.Primary, 0.4f);
_bgMaterial.DOColor(target, 0.2f).SetId("color");
} }
else else
{ {
// Normal or Hover state
_bgMaterial.SetFloat("_State", _isHovered ? 1f : 0f);
Color target = _isHovered Color target = _isHovered
? SSColorPalette.WithAlpha(SSColorPalette.Primary, 0.4f) ? SSColorPalette.Primary
: SSColorPalette.NeutralWord; : SSColorPalette.NeutralWord;
_bgMaterial.DOColor(target, 0.2f).SetId("color"); _backgroundImage.DOColor(target, 0.2f).SetId("color");
} }
float targetScale = _isHovered ? 1.1f : 1.0f; float targetScale = _isHovered ? 1.1f : 1.0f;
...@@ -217,9 +212,8 @@ namespace com.al_arcade.cs ...@@ -217,9 +212,8 @@ namespace com.al_arcade.cs
transform.DOShakeRotation(0.3f, 5f, 15); transform.DOShakeRotation(0.3f, 5f, 15);
// Flash color to wrong, then return to appropriate state // Flash color to wrong, then return to appropriate state
_bgMaterial.SetFloat("_State", 3f); // Shader Wrong state DOTween.Kill(_backgroundImage, "color");
DOTween.Kill(_bgMaterial, "color"); _backgroundImage.DOColor(SSColorPalette.Danger, 0.15f)
_bgMaterial.DOColor(SSColorPalette.Danger, 0.15f)
.SetId("color") .SetId("color")
.OnComplete(() => .OnComplete(() =>
{ {
...@@ -237,9 +231,8 @@ namespace com.al_arcade.cs ...@@ -237,9 +231,8 @@ namespace com.al_arcade.cs
if (_uniText != null) _uniText.Text = newText; if (_uniText != null) _uniText.Text = newText;
WordText = newText; WordText = newText;
_isHighlighted = false; _isHighlighted = false;
DOTween.Kill(_bgMaterial); DOTween.Kill(_backgroundImage, "color");
_bgMaterial.color = SSColorPalette.CorrectWord; _backgroundImage.color = SSColorPalette.CorrectWord;
_bgMaterial.SetFloat("_State", 2f); // Shader Correct state
}); });
seq.Append(transform.DOScale(Vector3.one * 1.2f, 0.3f).SetEase(Ease.OutBack)); seq.Append(transform.DOScale(Vector3.one * 1.2f, 0.3f).SetEase(Ease.OutBack));
seq.Append(transform.DOScale(Vector3.one, 0.15f)); seq.Append(transform.DOScale(Vector3.one, 0.15f));
......
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3a1740bd1ab0648cd9fa5c2b5d9a5d66 guid: 3a1740bd1ab0648cd9fa5c2b5d9a5d66
\ No newline at end of file MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- _wordSprite: {fileID: 21300000, guid: a54a00aa58b9b455c895e9312d25164d, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -9,36 +9,36 @@ namespace com.al_arcade.shared ...@@ -9,36 +9,36 @@ namespace com.al_arcade.shared
public static class SSColorPalette public static class SSColorPalette
{ {
public static readonly Color Primary = new Color32(48, 48, 208, 255); public static readonly Color Primary = new Color32(48, 48, 208, 255);
public static readonly Color PrimaryDark = new Color32(32, 32, 168, 255); public static readonly Color PrimaryDark = new Color32(32, 32, 168, 255);
public static readonly Color PrimaryLight = new Color32(80, 80, 220, 255); public static readonly Color PrimaryLight = new Color32(80, 80, 220, 255);
public static readonly Color Accent = new Color32(254, 215, 0, 255); public static readonly Color Accent = new Color32(254, 215, 0, 255);
public static readonly Color AccentDark = new Color32(212, 180, 0, 255); public static readonly Color AccentDark = new Color32(212, 180, 0, 255);
public static readonly Color Success = new Color32(16, 185, 129, 255); public static readonly Color Success = new Color32(16, 185, 129, 255);
public static readonly Color SuccessLight = new Color32(209, 250, 229, 255); public static readonly Color SuccessLight = new Color32(209, 250, 229, 255);
public static readonly Color Danger = new Color32(239, 68, 68, 255); public static readonly Color Danger = new Color32(239, 68, 68, 255);
public static readonly Color DangerLight = new Color32(254, 226, 226, 255); public static readonly Color DangerLight = new Color32(254, 226, 226, 255);
public static readonly Color Warning = new Color32(245, 158, 11, 255); public static readonly Color Warning = new Color32(245, 158, 11, 255);
public static readonly Color Info = new Color32(59, 130, 246, 255); public static readonly Color Info = new Color32(59, 130, 246, 255);
public static readonly Color Background = new Color32(238, 240, 248, 255); public static readonly Color Background = new Color32(238, 240, 248, 255);
public static readonly Color Card = Color.white; public static readonly Color Card = Color.white;
public static readonly Color TextDark = new Color32(26, 26, 46, 255); public static readonly Color TextDark = new Color32(26, 26, 46, 255);
public static readonly Color TextMuted = new Color32(107, 114, 128, 255); public static readonly Color TextMuted = new Color32(107, 114, 128, 255);
public static readonly Color Border = new Color32(229, 231, 235, 255); public static readonly Color Border = new Color32(229, 231, 235, 255);
public static readonly Color GateCorrect = new Color32(16, 185, 129, 255); public static readonly Color GateCorrect = new Color32(16, 185, 129, 255);
public static readonly Color GateWrong = new Color32(239, 68, 68, 255); public static readonly Color GateWrong = new Color32(239, 68, 68, 255);
public static readonly Color GateDefault = new Color32(80, 80, 220, 255); public static readonly Color GateDefault = new Color32(80, 80, 220, 255);
public static readonly Color TrueGreen = new Color32(34, 197, 94, 255); public static readonly Color TrueGreen = new Color32(34, 197, 94, 255);
public static readonly Color FalseRed = new Color32(239, 68, 68, 255); public static readonly Color FalseRed = new Color32(239, 68, 68, 255);
public static readonly Color WrongWord = new Color32(239, 68, 68, 255); public static readonly Color WrongWord = new Color32(239, 68, 68, 255);
public static readonly Color CorrectWord = new Color32(179, 255, 128, 255); public static readonly Color CorrectWord = new Color32(179, 255, 128, 255);
public static readonly Color NeutralWord = new Color32(248, 249, 252, 255); public static readonly Color NeutralWord = new Color32(56, 139, 255, 255);
public static Color WithAlpha(Color c, float a) public static Color WithAlpha(Color c, float a)
......
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