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

2D

parent fe4b8e7f
......@@ -118,15 +118,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalScale.x
value: 20
value: 15
objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalScale.y
value: 20
value: 15
objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalScale.z
value: 20
value: 15
objectReference: {fileID: 0}
- target: {fileID: 4431084402279646, guid: 8e0f285c21cdcf14e8d5c06c57ba936b, type: 3}
propertyPath: m_LocalPosition.x
......
......@@ -76,10 +76,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::ScienceStreet.Shared.FloatingScienceSpawner
spawnCount: 12
areaSize: {x: 50, y: 18, z: 10}
areaSize: {x: 20, y: 10, z: 10}
areaCenterOffset: {x: 0, y: 0, z: 0}
minScale: 1.2
maxScale: 2
minScale: 0.4
maxScale: 0.7
jitterAmount: 0.8
gizmoColor: {r: 0, g: 1, b: 1, a: 0.3}
showGizmoAlways: 1
......
......@@ -261,6 +261,7 @@ MonoBehaviour:
gradeId: 0
questionCount: 8
classCode:
wordSprite: {fileID: 21300000, guid: a54a00aa58b9b455c895e9312d25164d, type: 3}
useOfflineTestData: 0
--- !u!4 &1145369048
Transform:
......@@ -356,7 +357,7 @@ Camera:
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic: 1
orthographic size: 5
m_Depth: -1
m_CullingMask:
......
......@@ -13,7 +13,7 @@ namespace com.al_arcade.cs
[AddComponentMenu("Science Street/CS Prefab Builder")]
public class CsPrefabBuilder : MonoBehaviour
{
public static CsPrefabBuilder Instance { get; private set; }
[Header("Scene Environment")]
[Tooltip("Your full environment prefab (ground, platform, decorations, etc). Spawned at origin.")]
......@@ -87,6 +87,9 @@ namespace com.al_arcade.cs
[SerializeField] private int questionCount = 8;
[SerializeField] private string classCode = "";
[Header("Word")]
public Sprite wordSprite;
[Header("Debug")]
[SerializeField] private bool useOfflineTestData = false;
......@@ -98,6 +101,8 @@ namespace com.al_arcade.cs
private void Start()
{
Instance = this;
DOTween.Init();
if (arabicFont != null) SSFontManager.Font = arabicFont;
StartCoroutine(BuildEverything());
......
......@@ -15,7 +15,7 @@ namespace com.al_arcade.cs
public int Index { get; private set; }
private GameObject _background;
private Material _bgMaterial;
// private Material _bgMaterial; // Removed shader material usage
private Canvas _canvas;
private UniText _uniText; // Assuming the class name is UniText in UniText namespace
private BoxCollider _collider;
......@@ -24,8 +24,7 @@ namespace com.al_arcade.cs
private Sequence _idleAnim;
private float _cardWidth;
private float _cardHeight = 0.8f;
private Sprite _wordSprite;
private Image _backgroundImage;
public void Setup(string text, bool isWrong, int index,
......@@ -49,20 +48,14 @@ namespace com.al_arcade.cs
private void BuildVisuals()
{
var shader = Shader.Find("ScienceStreet/SciFiTextBackground")
?? Shader.Find("Standard") ?? Shader.Find("Unlit/Color");
_background = GameObject.CreatePrimitive(PrimitiveType.Cube);
_background.name = "WordBg";
_background.transform.SetParent(transform);
_background.transform.localPosition = Vector3.zero;
_background.transform.localScale = new Vector3(_cardWidth, _cardHeight, 0.08f);
Destroy(_background.GetComponent<Collider>());
_bgMaterial = new Material(shader);
_bgMaterial.SetFloat("_State", 0f);
_background.GetComponent<Renderer>().material = _bgMaterial;
_background.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
Destroy(_background.GetComponent<MeshRenderer>());
Destroy(_background.GetComponent<MeshFilter>());
var canvasObj = new GameObject("WordCanvas");
canvasObj.transform.SetParent(transform);
......@@ -78,6 +71,12 @@ namespace com.al_arcade.cs
rt.localScale = new Vector3(canvasScale, canvasScale, 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");
textObj.transform.SetParent(canvasObj.transform);
textObj.transform.localPosition = Vector3.zero;
......@@ -137,7 +136,7 @@ namespace com.al_arcade.cs
_idleAnim?.Kill();
_idleAnim = null;
DOTween.Kill(transform);
if (_bgMaterial != null) DOTween.Kill(_bgMaterial);
if (_backgroundImage != null) DOTween.Kill(_backgroundImage);
}
......@@ -165,24 +164,20 @@ namespace com.al_arcade.cs
private void UpdateVisuals()
{
DOTween.Kill(_bgMaterial, "color");
DOTween.Kill(_backgroundImage, "color");
DOTween.Kill(transform, "scale");
if (_isHighlighted)
{
// Pulsing highlight state
_bgMaterial.SetFloat("_State", 1f);
Color target = SSColorPalette.WithAlpha(SSColorPalette.Primary, 0.4f);
_bgMaterial.DOColor(target, 0.2f).SetId("color");
Color target = SSColorPalette.Primary;
_backgroundImage.DOColor(target, 0.2f).SetId("color");
}
else
{
// Normal or Hover state
_bgMaterial.SetFloat("_State", _isHovered ? 1f : 0f);
Color target = _isHovered
? SSColorPalette.WithAlpha(SSColorPalette.Primary, 0.4f)
? SSColorPalette.Primary
: SSColorPalette.NeutralWord;
_bgMaterial.DOColor(target, 0.2f).SetId("color");
_backgroundImage.DOColor(target, 0.2f).SetId("color");
}
float targetScale = _isHovered ? 1.1f : 1.0f;
......@@ -217,9 +212,8 @@ namespace com.al_arcade.cs
transform.DOShakeRotation(0.3f, 5f, 15);
// Flash color to wrong, then return to appropriate state
_bgMaterial.SetFloat("_State", 3f); // Shader Wrong state
DOTween.Kill(_bgMaterial, "color");
_bgMaterial.DOColor(SSColorPalette.Danger, 0.15f)
DOTween.Kill(_backgroundImage, "color");
_backgroundImage.DOColor(SSColorPalette.Danger, 0.15f)
.SetId("color")
.OnComplete(() =>
{
......@@ -237,9 +231,8 @@ namespace com.al_arcade.cs
if (_uniText != null) _uniText.Text = newText;
WordText = newText;
_isHighlighted = false;
DOTween.Kill(_bgMaterial);
_bgMaterial.color = SSColorPalette.CorrectWord;
_bgMaterial.SetFloat("_State", 2f); // Shader Correct state
DOTween.Kill(_backgroundImage, "color");
_backgroundImage.color = SSColorPalette.CorrectWord;
});
seq.Append(transform.DOScale(Vector3.one * 1.2f, 0.3f).SetEase(Ease.OutBack));
seq.Append(transform.DOScale(Vector3.one, 0.15f));
......
fileFormatVersion: 2
guid: 3a1740bd1ab0648cd9fa5c2b5d9a5d66
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- _wordSprite: {fileID: 21300000, guid: a54a00aa58b9b455c895e9312d25164d, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -38,7 +38,7 @@ namespace com.al_arcade.shared
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 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)
......
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