Commit 9807f3e4 authored by Yousef Sameh's avatar Yousef Sameh

UI

parent c1d2bd70
......@@ -35,16 +35,18 @@ public class SupabaseAuthentication
}
catch
{
Debug.LogError("[Auth] Session refresh failed, falling back to anonymous");
Debug.LogError("[Auth] Session refresh failed, signing out");
// Refresh failed — fall through to anonymous
}
}
var session = await client.Auth.SignInAnonymously();
Debug.Log("[Auth] Signed in anonymously" + $" (user ID: {session?.User.Id})");
return session?.User != null
? new Success()
: "Anonymous sign in failed";
return "No valid session";
// var session = await client.Auth.SignInAnonymously();
// Debug.Log("[Auth] Signed in anonymously" + $" (user ID: {session?.User.Id})");
// return session?.User != null
// ? new Success()
// : "Anonymous sign in failed";
}
catch (GotrueException ex)
{
......@@ -89,6 +91,36 @@ public class SupabaseAuthentication
}
}
public async UniTask<OneOf<Success, string>> LoginAnon()
{
try
{
IsLoading = true;
var client = SupabaseManager.Instance.Supabase();
if (client == null)
return "Supabase not initialized";
var session = await client.Auth.SignInAnonymously();
Debug.Log("[Auth] Signed in anonymously" + $" (user ID: {session?.User.Id})");
return session?.User != null
? new Success()
: "Anonymous sign in failed";
}
catch (GotrueException ex)
{
return ex.Message;
}
catch (Exception ex)
{
return ex.Message;
}
finally
{
IsLoading = false;
}
}
public async UniTask<OneOf<Success, string>> LogOut()
{
try
......
......@@ -50,29 +50,30 @@ public class SupabaseManager
client.Auth.SetPersistence(new UnitySession());
client.Auth.Options.AllowUnconfirmedUserSessions = true;
string url = $"{SupabaseSettings.SupabaseURL}/auth/v1/settings?apikey={SupabaseSettings.SupabaseAnonKey}";
try
{
client.Auth.Online = await _networkStatus.StartAsync(url);
}
catch (NotSupportedException)
{
client.Auth.Online = true;
}
catch (Exception e)
{
Debug.LogWarning($"Network check failed: {e.Message}");
client.Auth.Online = false;
}
if (client.Auth.Online)
{
await client.InitializeAsync();
var config = await client.Auth.Settings();
Debug.Log($"[Supabase] Auto-confirm: {config?.MailerAutoConfirm}");
}
// string url = $"{SupabaseSettings.SupabaseURL}/auth/v1/settings?apikey={SupabaseSettings.SupabaseAnonKey}";
// await client.InitializeAsync();
// try
// {
// client.Auth.Online = await _networkStatus.StartAsync(url);
// }
// catch (NotSupportedException)
// {
// client.Auth.Online = true;
// }
// catch (Exception e)
// {
// Debug.LogWarning($"Network check failed: {e.Message}");
// client.Auth.Online = false;
// }
// if (client.Auth.Online)
// {
// var config = await client.Auth.Settings();
// Debug.Log($"[Supabase] Auto-confirm: {config?.MailerAutoConfirm}");
// }
_client = client;
_initialized = true;
......
......@@ -91,7 +91,7 @@ public static class EducationManager
// 2. Term Mapping
private static readonly Dictionary<int, string> TermMap = new Dictionary<int, string>
{
{ 1, "الفصل الدراسي الأول" },
{ 1, "الفصل الدراسي الاول" },
{ 2, "الفصل الدراسي الثاني" }
};
......
......@@ -27,7 +27,7 @@ public class HomeController : MonoBehaviour
private VisualElement menuPanel;
void Awake()
void Start()
{
var root = mainMenuDocument.rootVisualElement.Q("Home");
menuPanel = mainMenuDocument.rootVisualElement.Q("MenuPanel");
......
......@@ -15,7 +15,7 @@ public class LeaderboardController : MonoBehaviour, IDisposable
// Stores the active cancellation token
private CancellationTokenSource _loadCts;
void Awake()
void Start()
{
root = leaderboardDocument.rootVisualElement;
leaderboardScrollView = root.Q<ScrollView>("Leaderboard");
......
......@@ -35,7 +35,10 @@ public class LoginController : MonoBehaviour
public async void RegisterAnon()
{
var auth = await SupabaseAuthentication.Instance.EnsureSession();
register.text = "جاري التسجيل...";
register.SetEnabled(false);
var auth = await SupabaseAuthentication.Instance.LoginAnon();
if (auth.IsT1)
{
Debug.LogError($"Authentication failed");
......@@ -46,6 +49,8 @@ public class LoginController : MonoBehaviour
if (string.IsNullOrEmpty(username.text) || grade.value == null || sex.value == null || term.value == null || curriculum.value == null)
{
Debug.LogError("Please fill in all fields");
register.text = "تسجيل";
register.SetEnabled(true);
return;
}
......@@ -63,7 +68,11 @@ public class LoginController : MonoBehaviour
}, error =>
{
Debug.LogError($"Failed to create user: {error.Message}");
register.text = "تسجيل";
register.SetEnabled(true);
});
}
......
......@@ -13,8 +13,10 @@ public class ProfileController : MonoBehaviour
private DropdownField Grade;
private DropdownField Term;
private CustomSwitch musicSwitch;
private CustomSwitch sfxSwitch;
void Awake()
void Start()
{
var root = profileDocument.rootVisualElement.Q("Settings");
name = root.Q<Label>("Username");
......@@ -28,6 +30,15 @@ public class ProfileController : MonoBehaviour
Grade = root.Q<DropdownField>("Grade");
Term = root.Q<DropdownField>("Term");
musicSwitch = root.Q<CustomSwitch>("MusicSwitch");
sfxSwitch = root.Q<CustomSwitch>("SFXSwitch");
musicSwitch.IsOn = SettingsCache.MusicEnabled;
sfxSwitch.IsOn = SettingsCache.SfxEnabled;
musicSwitch.onValueChanged += (value) => SettingsCache.MusicEnabled = value;
sfxSwitch.onValueChanged += (value) => SettingsCache.SfxEnabled = value;
UserService.Instance.OnUserChanged += OnUserChange;
OnUserChange(UserService.Instance.CurrentUser);
}
......
using UnityEngine;
using System;
public static class SettingsCache
{
// Keys for PlayerPrefs
private const string MusicKey = "Settings_MusicEnabled";
private const string SfxKey = "Settings_SfxEnabled";
// Events to notify the Audio Manager immediately
public static event Action<bool> OnMusicChanged;
public static event Action<bool> OnSfxChanged;
// Properties with automatic saving
public static bool MusicEnabled
{
get => PlayerPrefs.GetInt(MusicKey, 1) == 1; // Default to true (1)
set
{
PlayerPrefs.SetInt(MusicKey, value ? 1 : 0);
PlayerPrefs.Save();
OnMusicChanged?.Invoke(value);
}
}
public static bool SfxEnabled
{
get => PlayerPrefs.GetInt(SfxKey, 1) == 1;
set
{
PlayerPrefs.SetInt(SfxKey, value ? 1 : 0);
PlayerPrefs.Save();
OnSfxChanged?.Invoke(value);
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 275b09c0cab1fe9468d3006fe44f0cd9
\ No newline at end of file
guid: da1b43652273b3a4e99e97d9ddcf80a8
\ No newline at end of file
......@@ -65,7 +65,6 @@
</ui:VisualElement>
<ui:Button text="" name="Register" class="action-btn">
<ui:Label text="تسجيل " language-direction="RTL" class="text-bold-black" style="color: rgb(255, 255, 255); font-size: 55px;"/>
<ui:Label text="✨" name="TextFieldLabel" language-direction="RTL" class="emoji" style="color: rgb(117, 117, 117); margin-bottom: 0; font-size: 50px; -unity-text-align: middle-right; margin-left: 0;"/>
</ui:Button>
</ui:VisualElement>
</ui:VisualElement>
......
......@@ -53,7 +53,7 @@
<ui:Label text="🔊" name="icon" class="emoji" style="padding-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; font-size: 50px;"/>
</ui:VisualElement>
<ui:Label text="المؤثرات الصوتية" class="text-bold-black" style="color: rgb(66, 66, 66);"/>
<CustomSwitch is-on="true" style="position: absolute; right: auto; left: 0;"/>
<CustomSwitch is-on="true" name="SFXSwitch" style="position: absolute; right: auto; left: 0;"/>
</ui:VisualElement>
<ui:VisualElement name="Line" style="flex-grow: 0; width: 100%; background-color: rgba(0, 0, 0, 0.1); height: 2px; margin-top: 25px; margin-bottom: 25px;"/>
<ui:VisualElement name="row" style="flex-grow: 1; flex-direction: row-reverse; align-items: center;">
......@@ -61,7 +61,7 @@
<ui:Label text="🎵" name="icon" class="emoji" style="padding-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; font-size: 50px;"/>
</ui:VisualElement>
<ui:Label text="الموسيقي" class="text-bold-black" style="color: rgb(66, 66, 66);"/>
<CustomSwitch is-on="true" style="position: absolute; right: auto; left: 0;"/>
<CustomSwitch is-on="true" name="MusicSwitch" style="position: absolute; right: auto; left: 0;"/>
</ui:VisualElement>
</ui:VisualElement>
<ui:Label text="حول" name="Label" class="text-bold" style="color: rgb(178, 178, 178); -unity-text-align: middle-right; margin-top: 25px; margin-bottom: 25px;"/>
......
......@@ -340,7 +340,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 877571984}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 540, y: 1199.9999, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
......
......@@ -196,6 +196,51 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::LoginPageAnimation
loginPage: {fileID: 1971829438}
--- !u!1 &668896140
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 668896142}
- component: {fileID: 668896141}
m_Layer: 0
m_Name: TransitionManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &668896141
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 668896140}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61430b0086307cc4da3ccc8d39ae88da, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::EasyTransition.TransitionManager
transitionTemplate: {fileID: 5276914992623515724, guid: 616d511151a6c554caddf1c754e4f91d, type: 3}
--- !u!4 &668896142
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 668896140}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 62.77843, y: 74.36234, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &951503749
GameObject:
m_ObjectHideFlags: 0
......@@ -645,3 +690,4 @@ SceneRoots:
- {fileID: 1628372281}
- {fileID: 1093642342}
- {fileID: 2142479138}
- {fileID: 668896142}
......@@ -401,6 +401,51 @@ MonoBehaviour:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!1 &1450206973
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1450206974}
- component: {fileID: 1450206975}
m_Layer: 0
m_Name: TransitionManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1450206974
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450206973}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 62.77843, y: 74.36234, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1450206975
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1450206973}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61430b0086307cc4da3ccc8d39ae88da, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::EasyTransition.TransitionManager
transitionTemplate: {fileID: 5276914992623515724, guid: 616d511151a6c554caddf1c754e4f91d, type: 3}
--- !u!1 &1455761154
GameObject:
m_ObjectHideFlags: 0
......@@ -593,51 +638,6 @@ Camera:
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!1 &1709733323
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1709733325}
- component: {fileID: 1709733324}
m_Layer: 0
m_Name: TransitionManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1709733324
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1709733323}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61430b0086307cc4da3ccc8d39ae88da, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::EasyTransition.TransitionManager
transitionTemplate: {fileID: 5276914992623515724, guid: 616d511151a6c554caddf1c754e4f91d, type: 3}
--- !u!4 &1709733325
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1709733323}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1841206265
GameObject:
m_ObjectHideFlags: 0
......@@ -723,4 +723,4 @@ SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 2035341440}
- {fileID: 1709733325}
- {fileID: 1450206974}
......@@ -212,6 +212,51 @@ Transform:
- {fileID: 2025346609}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &590366223
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 590366225}
- component: {fileID: 590366224}
m_Layer: 0
m_Name: TransitionManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &590366224
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 590366223}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61430b0086307cc4da3ccc8d39ae88da, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::EasyTransition.TransitionManager
transitionTemplate: {fileID: 5276914992623515724, guid: 616d511151a6c554caddf1c754e4f91d, type: 3}
--- !u!4 &590366225
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 590366223}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 540, y: 1199.9999, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &689087716
GameObject:
m_ObjectHideFlags: 0
......@@ -736,3 +781,4 @@ SceneRoots:
- {fileID: 1486533217}
- {fileID: 689087717}
- {fileID: 414692744}
- {fileID: 590366225}
using System;
using UnityEngine;
using UnityEngine.UIElements;
......@@ -8,6 +9,8 @@ public partial class CustomSwitch : VisualElement
VisualElement _switchBackground;
VisualElement _switchPoint;
public Action<bool> onValueChanged;
[UxmlAttribute]
public bool IsOn
{
......@@ -26,6 +29,7 @@ public partial class CustomSwitch : VisualElement
_switchBackground.RegisterCallback<ClickEvent>((v) =>
{
IsOn = !IsOn;
onValueChanged?.Invoke(IsOn);
});
}
......
......@@ -287,7 +287,7 @@ ParticleSystem:
startSize:
serializedVersion: 2
minMaxState: 0
scalar: 0.5
scalar: 2.5
minScalar: 1
maxCurve:
serializedVersion: 2
......@@ -1300,7 +1300,7 @@ ParticleSystem:
m_RotationOrder: 4
separateAxes: 0
ColorModule:
enabled: 0
enabled: 1
gradient:
serializedVersion: 2
minMaxState: 1
......@@ -1368,14 +1368,14 @@ ParticleSystem:
m_NumAlphaKeys: 2
UVModule:
serializedVersion: 2
enabled: 0
enabled: 1
mode: 0
timeMode: 0
fps: 30
frameOverTime:
serializedVersion: 2
minMaxState: 1
scalar: 0.9999
minMaxState: 0
scalar: 0
minScalar: 0.9999
maxCurve:
serializedVersion: 2
......@@ -1427,8 +1427,8 @@ ParticleSystem:
m_RotationOrder: 4
startFrame:
serializedVersion: 2
minMaxState: 0
scalar: 0
minMaxState: 3
scalar: 0.875
minScalar: 0
maxCurve:
serializedVersion: 2
......@@ -1479,8 +1479,8 @@ ParticleSystem:
m_PostInfinity: 2
m_RotationOrder: 4
speedRange: {x: 0, y: 1}
tilesX: 1
tilesY: 1
tilesX: 4
tilesY: 4
animationType: 0
rowIndex: 0
cycles: 1
......@@ -4758,7 +4758,7 @@ ParticleSystem:
vectorLabel1_3: W
--- !u!199 &3062164300472580502
ParticleSystemRenderer:
serializedVersion: 6
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
......@@ -4774,6 +4774,11 @@ ParticleSystemRenderer:
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
......@@ -4795,9 +4800,11 @@ ParticleSystemRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_RenderMode: 0
m_MeshDistribution: 0
m_SortMode: 0
......@@ -4829,4 +4836,3 @@ ParticleSystemRenderer:
m_MeshWeighting1: 1
m_MeshWeighting2: 1
m_MeshWeighting3: 1
m_MaskInteraction: 0
......@@ -17,7 +17,7 @@ namespace EasyTransition
public UnityAction onTransitionCutPointReached;
public UnityAction onTransitionEnd;
private static TransitionManager instance;
public static TransitionManager instance { get; private set; }
private void Awake()
{
......
......@@ -297,6 +297,10 @@ PrefabInstance:
propertyPath: UVModule.tilesY
value: 4
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.type
value: 4
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.enabled
value: 1
......@@ -313,14 +317,42 @@ PrefabInstance:
propertyPath: ColorModule.enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.m_Scale.x
value: 20
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.m_Scale.y
value: 20
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.m_Scale.z
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.animationType
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.donutRadius
value: 1.16
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.radius.value
value: 0.3
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.startFrame.scalar
value: 0.9375
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: NoiseModule.strength.scalar
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.radiusThickness
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.frameOverTime.scalar
value: 0
......@@ -329,21 +361,85 @@ PrefabInstance:
propertyPath: InitialModule.startSize.scalar
value: 1.5
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: VelocityModule.orbitalX.scalar
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: VelocityModule.orbitalY.scalar
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: InitialModule.startSpeed.scalar
value: 2
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.startFrame.minMaxState
value: 3
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: EmissionModule.rateOverTime.scalar
value: 3
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.frameOverTime.minMaxState
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: VelocityModule.orbitalOffsetZ.scalar
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.ctime0
value: 12567
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.ctime1
value: 51117
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.ctime2
value: 65458
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key0.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key0.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key0.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key2.b
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key2.g
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key2.r
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.m_ColorSpace
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.m_NumColorKeys
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalPosition.x
value: -0.37
value: -0.52
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalPosition.y
value: 1.15
value: -10.18
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalPosition.z
......
......@@ -615,7 +615,6 @@ GameObject:
- component: {fileID: 833009907982420317}
- component: {fileID: 9000497820563231295}
- component: {fileID: 3798486219360939645}
- component: {fileID: 6945769294166899398}
m_Layer: 0
m_Name: ProductionLine
m_TagString: Untagged
......@@ -666,7 +665,7 @@ MonoBehaviour:
moveSound: {fileID: 8300000, guid: 1a929b70e26095f489dc29121aa6052a, type: 3}
backgroundMusic: {fileID: 8300000, guid: 35e247fe8003f9730a5afdc547918e69, type: 3}
moveAudioSource: {fileID: 3798486219360939645}
musicAudioSource: {fileID: 6945769294166899398}
musicAudioSource: {fileID: 0}
machineVFXController: {fileID: 0}
--- !u!82 &3798486219360939645
AudioSource:
......@@ -765,103 +764,6 @@ AudioSource:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!82 &6945769294166899398
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8133776314024328659}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_Resource: {fileID: 8300000, guid: 35e247fe8003f9730a5afdc547918e69, type: 3}
m_PlayOnAwake: 1
m_Volume: 0.5
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &8848232476125441368
GameObject:
m_ObjectHideFlags: 0
......
fileFormatVersion: 2
guid: 5fbe46aa3e590164480422e3c655116b
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
......@@ -119,7 +119,7 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &62724368
--- !u!1 &17204979
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -127,48 +127,44 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 62724370}
- component: {fileID: 62724369}
- component: {fileID: 17204980}
- component: {fileID: 17204981}
m_Layer: 0
m_Name: Global Volume
m_Name: TransitionManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &62724369
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 62724368}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.Volume
m_IsGlobal: 1
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 38487a2abc17859078d5e237685101f0, type: 2}
--- !u!4 &62724370
--- !u!4 &17204980
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 62724368}
m_GameObject: {fileID: 17204979}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.8141794, y: 5.1738243, z: 0}
m_LocalPosition: {x: 62.77843, y: 74.36234, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &601229405
--- !u!114 &17204981
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 17204979}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61430b0086307cc4da3ccc8d39ae88da, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::EasyTransition.TransitionManager
transitionTemplate: {fileID: 5276914992623515724, guid: 616d511151a6c554caddf1c754e4f91d, type: 3}
--- !u!1 &62724368
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -176,38 +172,42 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 601229407}
- component: {fileID: 601229406}
- component: {fileID: 62724370}
- component: {fileID: 62724369}
m_Layer: 0
m_Name: TransitionManager
m_Name: Global Volume
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &601229406
--- !u!114 &62724369
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 601229405}
m_GameObject: {fileID: 62724368}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 61430b0086307cc4da3ccc8d39ae88da, type: 3}
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::EasyTransition.TransitionManager
transitionTemplate: {fileID: 5276914992623515724, guid: 616d511151a6c554caddf1c754e4f91d, type: 3}
--- !u!4 &601229407
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.Volume
m_IsGlobal: 1
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 38487a2abc17859078d5e237685101f0, type: 2}
--- !u!4 &62724370
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 601229405}
m_GameObject: {fileID: 62724368}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 562.3606, y: 1200, z: 0}
m_LocalPosition: {x: 2.8141794, y: 5.1738243, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
......@@ -732,4 +732,4 @@ SceneRoots:
- {fileID: 1049087476}
- {fileID: 1559015525}
- {fileID: 62724370}
- {fileID: 601229407}
- {fileID: 17204980}
......@@ -311,7 +311,7 @@ AudioSource:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 603037695}
m_Enabled: 1
m_Enabled: 0
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
......@@ -692,6 +692,7 @@ MonoBehaviour:
sfxPop: {fileID: 0}
sfxCheer: {fileID: 0}
sfxCountdown: {fileID: 0}
music: {fileID: 8300000, guid: 35e247fe8003f9730a5afdc547918e69, type: 3}
correctBurstParticle: {fileID: 0}
wrongBurstParticle: {fileID: 0}
confettiParticle: {fileID: 8193503977349690185, guid: fae695be220a38541b692ad19239ef9f, type: 3}
......@@ -714,44 +715,96 @@ PrefabInstance:
m_TransformParent: {fileID: 603037698}
m_Modifications:
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.mode
propertyPath: ShapeModule.type
value: 5
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.m_Scale.x
value: 30
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.m_Scale.y
value: 20
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.m_Scale.z
value: 20
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ShapeModule.radiusThickness
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: VelocityModule.orbitalX.scalar
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: VelocityModule.orbitalY.scalar
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.tilesX
value: 4
propertyPath: ColorModule.gradient.maxGradient.ctime0
value: 12567
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.ctime1
value: 51117
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.tilesY
value: 4
propertyPath: ColorModule.gradient.maxGradient.ctime2
value: 65458
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.enabled
propertyPath: ColorModule.gradient.maxGradient.key0.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: UVModule.animationType
propertyPath: ColorModule.gradient.maxGradient.key0.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key0.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key2.b
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key2.g
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.key2.r
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.m_ColorSpace
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5575199186091687107, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: ColorModule.gradient.maxGradient.m_NumColorKeys
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalPosition.x
value: -0.08737
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalPosition.y
value: 10.40678
value: 10.4
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalPosition.z
value: 10
value: 41.1
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
value: 0.64278764
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
value: -0.7660445
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalRotation.y
......@@ -763,7 +816,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -90
value: -100
objectReference: {fileID: 0}
- target: {fileID: 6955428004947038011, guid: 34182cd83d7c1f44ebd466464e1a4db5, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
......
......@@ -18,6 +18,7 @@ public class ChallengeManager : MonoBehaviour
[SerializeField] private int timeSavedBonusMultiplier = 2;
[SerializeField] private List<int> penaltiesPerGame = new() { 200, 150, 100 };
[SerializeField] private AudioClip transitionSFX;
// Time saved for bonus if won the challenge
private int timeSaved = 0;
......@@ -28,6 +29,8 @@ public class ChallengeManager : MonoBehaviour
IChallengeGame currentGame = null;
BaseGameManager baseGameManager = null;
private UniTaskCompletionSource transitionEndCompletionSource = null;
[SerializeField] private ChallengeCanvas challengeCanvas;
......@@ -94,11 +97,16 @@ public class ChallengeManager : MonoBehaviour
private async UniTask LoadNextGameAndListen()
{
if (transitionSFX != null)
{
SSAudioManager.EnsureInstance();
SSAudioManager.Instance.Play(transitionSFX);
}
TransitionManager.Instance().Transition(gameSceneNames[currentGameIndex], transitionSettings, 0);
// Wait until the old game is destroyed and the new game is loaded and ready
await UniTask.WaitUntil(() => baseGameManager == null || baseGameManager.IsDestroyed());
await UniTask.WaitUntil(() =>
{
currentGame = FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None)
......@@ -108,8 +116,8 @@ public class ChallengeManager : MonoBehaviour
return currentGame != null;
});
baseGameManager = currentGame as BaseGameManager;
print("Current game: " + baseGameManager.name);
await UniTask.WaitForSeconds(0.5f);
baseGameManager.StartGame();
......@@ -136,7 +144,7 @@ public class ChallengeManager : MonoBehaviour
public void EndChallenge()
{
Destroy(gameObject, 5);
Destroy(gameObject, 2);
}
}
\ No newline at end of file
......@@ -608,6 +608,7 @@ MonoBehaviour:
winningPoints: 500
timeSavedBonusMultiplier: 2
penaltiesPerGame: c80000009600000064000000
transitionSFX: {fileID: 8300000, guid: 5fbe46aa3e590164480422e3c655116b, type: 3}
challengeCanvas: {fileID: 3214242843135042761}
--- !u!1 &6825994381865325274
GameObject:
......
......@@ -63,6 +63,7 @@ namespace com.al_arcade.mcq
_mainCamera = Camera.main;
onAnswerGiven?.AddListener(CameraFeedback);
}
// ─── BaseGameManager implementation ──────────────────────────────────
......@@ -70,6 +71,13 @@ namespace com.al_arcade.mcq
protected override IEnumerator FetchQuestions(Action<string> onError)
{
if (prefabBuilder != null && prefabBuilder.music != null)
{
SSAudioManager.Instance.music = prefabBuilder.music;
SSAudioManager.Instance.PlayMusic();
}
var session = SSGameSession.EnsureInstance();
var api = SSApiManager.EnsureInstance();
......
......@@ -69,6 +69,8 @@ namespace com.al_arcade.mcq
[SerializeField] private AudioClip sfxCheer;
[SerializeField] private AudioClip sfxCountdown;
[Header("Music")]
[SerializeField] public AudioClip music;
[Header("Particles")]
[SerializeField] private ParticleSystem correctBurstParticle;
......
......@@ -73,8 +73,6 @@ namespace com.al_arcade.shared
// ─────────────────────────────────────────────────────────────────────
protected virtual void Awake()
{
onAnswerGiven.AddListener(HapticFeedback);
// Subclasses that need extra Awake logic should call base.Awake()
// THEN do their own work.
}
......@@ -285,28 +283,12 @@ namespace com.al_arcade.shared
}
protected void HapticFeedback(bool correct)
{
#if UNITY_ANDROID || UNITY_IOS
if (correct)
HapticManager.LightTap();
else
HapticManager.HeavyError();
#endif
}
protected virtual IEnumerator SharedVictorySequence() { yield break; }
protected virtual IEnumerator SharedLoseSequence() { yield break; }
protected virtual IEnumerator NoChallengeVictorySequence() { yield break; }
protected virtual IEnumerator NoChallengeLoseSequence() { yield break; }
protected void Oestroy()
{
onAnswerGiven.RemoveListener(HapticFeedback);
}
}
}
using UnityEngine;
public static class HapticManager
{
public static void LightTap()
{
// Only execute on actual mobile hardware
if (Application.isEditor) return;
#if UNITY_ANDROID
VibrateAndroid(50);
#elif UNITY_IOS
// Handheld.Vibrate is the only built-in option without a native plugin
Handheld.Vibrate();
#endif
}
public static void HeavyError()
{
if (Application.isEditor) return;
#if UNITY_ANDROID
VibrateAndroid(500);
#elif UNITY_IOS
Handheld.Vibrate();
#endif
}
private static void VibrateAndroid(long milliseconds)
{
// CRITICAL: This preprocessor ensures the Editor never touches this block
#if UNITY_ANDROID && !UNITY_EDITOR
try
{
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
using (AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
using (AndroidJavaObject vibrator = currentActivity.Call<AndroidJavaObject>("getSystemService", "vibrator"))
{
if (vibrator != null)
{
vibrator.Call("vibrate", milliseconds);
}
}
}
catch (System.Exception ex)
{
Debug.LogWarning($"Android Haptic Failed: {ex.Message}");
}
#endif
}
}
\ No newline at end of file
......@@ -71,6 +71,8 @@ namespace com.al_arcade.shared
public void PlayMusic()
{
if (!SettingsCache.MusicEnabled) return;
if (_isMusicPlaying) return;
_isMusicPlaying = true;
if (music == null) return;
......@@ -130,6 +132,7 @@ namespace com.al_arcade.shared
public void Play(AudioClip clip, float volumeScale = 1f, float pitch = 1f)
{
if (!SettingsCache.SfxEnabled) return;
if (clip == null) return;
var src = GetSource();
src.pitch = pitch;
......
......@@ -52,18 +52,8 @@ namespace com.al_arcade.tf
moveAudioSource.playOnAwake = false;
moveAudioSource.loop = false;
// Music Audio Source
if (musicAudioSource == null)
musicAudioSource = gameObject.AddComponent<AudioSource>();
if (backgroundMusic != null)
{
musicAudioSource.clip = backgroundMusic;
musicAudioSource.loop = true;
musicAudioSource.volume = 0.5f;
musicAudioSource.playOnAwake = true;
musicAudioSource.Play();
}
SSAudioManager.Instance.music = backgroundMusic;
SSAudioManager.Instance.PlayMusic();
}
private void PlayMoveSound()
......
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