Compare commits
No commits in common. "fe44ced9f8cc1eadba68ff4da7b36d7b65d9e8ba" and "872f3f263e16c709c672fd64108e9d8ddf809c6e" have entirely different histories.
fe44ced9f8
...
872f3f263e
8 changed files with 102 additions and 88 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Net.Mail;
|
||||
using Firebase.Auth;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.UIElements;
|
||||
|
@ -375,8 +376,6 @@ public class AccountUI : MonoBehaviour
|
|||
_ => "An error occurred updating the username. Please try again."
|
||||
};
|
||||
});
|
||||
|
||||
// TODO: update lpdata
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -409,8 +408,6 @@ public class AccountUI : MonoBehaviour
|
|||
_ => "An error occurred updating the email. Please try again."
|
||||
};
|
||||
});
|
||||
|
||||
// TODO: update lpdata
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -57,12 +57,6 @@ public class Backend
|
|||
Password
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// callback functions to be invoked when the user signs in
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private readonly List<Action<FirebaseConnectionStatus>> _onConnectionStatusChangedCallbacks = new();
|
||||
|
||||
/// <summary>
|
||||
/// callback functions to be invoked when the user signs in
|
||||
/// </summary>
|
||||
|
@ -73,6 +67,12 @@ public class Backend
|
|||
/// </summary>
|
||||
private readonly List<Action> _onSignOutCallbacks = new();
|
||||
|
||||
/// <summary>
|
||||
/// callback functions to be invoked when the user signs in
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private readonly List<Action<FirebaseConnectionStatus>> _onConnectionStatusChangedCallbacks = new ();
|
||||
|
||||
/// <summary>
|
||||
/// the firebase authentication object
|
||||
/// </summary>
|
||||
|
@ -88,16 +88,16 @@ public class Backend
|
|||
/// </summary>
|
||||
private FirebaseUser _user;
|
||||
|
||||
/// <summary>
|
||||
/// the current user's username, if authenticated
|
||||
/// </summary>
|
||||
private string _username;
|
||||
|
||||
/// <summary>
|
||||
/// whether the user is signed in
|
||||
/// </summary>
|
||||
public bool IsSignedIn;
|
||||
|
||||
/// <summary>
|
||||
/// the current user's username, if authenticated
|
||||
/// </summary>
|
||||
private string _username;
|
||||
|
||||
/// <summary>
|
||||
/// whether the backend is connected to the firebase backend
|
||||
/// </summary>
|
||||
|
@ -159,6 +159,7 @@ public class Backend
|
|||
{
|
||||
Debug.Log($"firing OnSignInCallbacks ({_onSignInCallbacks.Count})");
|
||||
foreach (var callback in _onSignInCallbacks)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.Invoke(_user);
|
||||
|
@ -168,6 +169,7 @@ public class Backend
|
|||
Debug.LogError($"error invoking OnSignInCallback: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// function to fire all on sign-out callbacks
|
||||
|
@ -176,6 +178,7 @@ public class Backend
|
|||
{
|
||||
Debug.Log($"firing OnSignOutCallbacks ({_onSignOutCallbacks.Count})");
|
||||
foreach (var callback in _onSignOutCallbacks)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.Invoke();
|
||||
|
@ -185,6 +188,7 @@ public class Backend
|
|||
Debug.LogError($"error invoking OnSignOutCallback: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// async function to retry initialisation after a delay
|
||||
|
@ -230,7 +234,10 @@ public class Backend
|
|||
if (!IsSignedIn) return;
|
||||
|
||||
Debug.Log($"signed in successfully as {_user?.UserId}");
|
||||
RetrieveUsernameWithCallback((_, _) => { FireOnSignInCallbacks(); });
|
||||
RetrieveUsernameWithCallback((_, _) =>
|
||||
{
|
||||
FireOnSignInCallbacks();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -475,12 +482,11 @@ public class Backend
|
|||
/// abstraction function to get the user's recent scores from the database
|
||||
/// </summary>
|
||||
/// <param name="callback">
|
||||
/// callback function that takes in a <c>DatabaseTransactionResult</c> enum and a
|
||||
/// <c>List<LocalPlayerData.Score></c>
|
||||
/// callback function that takes in a <c>DatabaseTransactionResult</c> enum and a <c>List<LocalPlayerData.Score></c>
|
||||
/// </param>
|
||||
public void GetRecentScores(Action<DatabaseTransactionResult, List<LocalPlayerData.Score>> callback)
|
||||
{
|
||||
// TODO: implement this
|
||||
// TODO
|
||||
callback(DatabaseTransactionResult.Error, new List<LocalPlayerData.Score>(0));
|
||||
}
|
||||
|
||||
|
@ -500,10 +506,7 @@ public class Backend
|
|||
/// abstraction function to get and calculate the user's rating from the database
|
||||
/// calculation is done locally, call UpdateUserRating to update the user's rating in the database
|
||||
/// </summary>
|
||||
/// <param name="callback">
|
||||
/// callback function that takes in a <c>DatabaseTransactionResult</c> enum and a user rating
|
||||
/// <c>float</c>
|
||||
/// </param>
|
||||
/// <param name="callback">callback function that takes in a <c>DatabaseTransactionResult</c> enum and a user rating <c>float</c></param>
|
||||
public void CalculateUserRating(
|
||||
Action<DatabaseTransactionResult, float> callback)
|
||||
{
|
||||
|
|
|
@ -18,26 +18,26 @@ public class GameManager : MonoBehaviour
|
|||
/// </summary>
|
||||
public UIManager ui;
|
||||
|
||||
/// <summary>
|
||||
/// list of callbacks to call when the local player data changes
|
||||
/// </summary>
|
||||
private readonly List<Action<LocalPlayerData>> _onLocalPlayerDataChangeCallbacks = new();
|
||||
|
||||
/// <summary>
|
||||
/// the local player data object for storing player data
|
||||
/// </summary>
|
||||
private LocalPlayerData _data;
|
||||
|
||||
/// <summary>
|
||||
/// backend object for handling communication with the firebase backend
|
||||
/// </summary>
|
||||
public Backend Backend;
|
||||
|
||||
/// <summary>
|
||||
/// read-only property for accessing the local player data outside of this class
|
||||
/// </summary>
|
||||
public LocalPlayerData Data => _data;
|
||||
|
||||
/// <summary>
|
||||
/// list of callbacks to call when the local player data changes
|
||||
/// </summary>
|
||||
private readonly List<Action<LocalPlayerData>> _onLocalPlayerDataChangeCallbacks = new List<Action<LocalPlayerData>>();
|
||||
|
||||
/// <summary>
|
||||
/// backend object for handling communication with the firebase backend
|
||||
/// </summary>
|
||||
public Backend Backend;
|
||||
|
||||
/// <summary>
|
||||
/// enforces singleton behaviour; sets doesn't destroy on load and checks for multiple instances
|
||||
/// </summary>
|
||||
|
@ -59,16 +59,7 @@ public class GameManager : MonoBehaviour
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// start modifying state
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log("GameManager starts here");
|
||||
_data.LoadFromTheWorld(FireLocalPlayerDataChangeCallbacks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// initialise variables and ui elements
|
||||
/// called when the game object is enabled, initialises variables
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
|
@ -109,6 +100,15 @@ public class GameManager : MonoBehaviour
|
|||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// load in stuff
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log("GameManager starts here");
|
||||
_data.LoadFromTheWorld(FireLocalPlayerDataChangeCallbacks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called when the application is quitting, saves the local player data
|
||||
/// </summary>
|
||||
|
@ -136,6 +136,7 @@ public class GameManager : MonoBehaviour
|
|||
{
|
||||
Debug.Log($"firing LocalPlayerDataChangeCallbacks ({_onLocalPlayerDataChangeCallbacks.Count})");
|
||||
foreach (var callback in _onLocalPlayerDataChangeCallbacks)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback.Invoke(data);
|
||||
|
@ -146,3 +147,4 @@ public class GameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ public class OklchColourPickerUI : MonoBehaviour
|
|||
private VisualElement _responseColour;
|
||||
|
||||
/// <summary>
|
||||
/// modify state of initialised variables
|
||||
/// function to set the initial values of the sliders
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ public class OklchColourPickerUI : MonoBehaviour
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// initialise the ui elements and register change event callbacks functions
|
||||
/// function to subscribe slider events to their respective functions
|
||||
/// </summary>
|
||||
public void OnEnable()
|
||||
{
|
||||
|
|
18
ColourMeOKGame/Assets/Scripts/Playground.cs
Normal file
18
ColourMeOKGame/Assets/Scripts/Playground.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Playground
|
||||
{
|
||||
private float _score;
|
||||
|
||||
private void SomethingSomethingScore()
|
||||
{
|
||||
var score = 0.0f;
|
||||
|
||||
_score = score;
|
||||
}
|
||||
|
||||
private void ShowTheScore()
|
||||
{
|
||||
Debug.Log(_score);
|
||||
}
|
||||
}
|
3
ColourMeOKGame/Assets/Scripts/Playground.cs.meta
Normal file
3
ColourMeOKGame/Assets/Scripts/Playground.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 662d126b54a54d9ebe6a1dc716d199e3
|
||||
timeCreated: 1731830473
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
|
@ -11,36 +12,21 @@ public class SideViewUI : MonoBehaviour
|
|||
/// </summary>
|
||||
private Button _accountButton;
|
||||
|
||||
/// <summary>
|
||||
/// text label for showing the player's stable-ish chroma accuracy
|
||||
/// </summary>
|
||||
private Label _chromaAccuracyText;
|
||||
|
||||
/// <summary>
|
||||
/// connection status label for showing the connection status
|
||||
/// </summary>
|
||||
private Label _connectionStatusLabel;
|
||||
|
||||
/// <summary>
|
||||
/// text label for showing the player's stable-ish hue accuracy
|
||||
/// </summary>
|
||||
private Label _hueAccuracyText;
|
||||
|
||||
/// <summary>
|
||||
/// leaderboard button for showing the leaderboard
|
||||
/// </summary>
|
||||
private Button _leaderboardButton;
|
||||
|
||||
/// <summary>
|
||||
/// text label for showing the player's stable-ish lightness accuracy
|
||||
/// </summary>
|
||||
private Label _lightnessAccuracyText;
|
||||
|
||||
/// <summary>
|
||||
/// play button for starting the game
|
||||
/// </summary>
|
||||
private Button _playButton;
|
||||
|
||||
/// <summary>
|
||||
/// connection status label for showing the connection status
|
||||
/// </summary>
|
||||
private Label _connectionStatusLabel;
|
||||
|
||||
/// <summary>
|
||||
/// text label for showing the player's known name
|
||||
/// </summary>
|
||||
|
@ -52,7 +38,22 @@ public class SideViewUI : MonoBehaviour
|
|||
private Label _ratingText;
|
||||
|
||||
/// <summary>
|
||||
/// initialise the ui elements and register the button click event functions
|
||||
/// text label for showing the player's stable-ish lightness accuracy
|
||||
/// </summary>
|
||||
private Label _lightnessAccuracyText;
|
||||
|
||||
/// <summary>
|
||||
/// text label for showing the player's stable-ish chroma accuracy
|
||||
/// </summary>
|
||||
private Label _chromaAccuracyText;
|
||||
|
||||
/// <summary>
|
||||
/// text label for showing the player's stable-ish hue accuracy
|
||||
/// </summary>
|
||||
private Label _hueAccuracyText;
|
||||
|
||||
/// <summary>
|
||||
/// function to subscribe button events to their respective functions
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
|
|
|
@ -51,20 +51,10 @@ public class UIManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modify state of initial variables
|
||||
/// </summary>
|
||||
private void Start()
|
||||
{
|
||||
SetDisplayState(DisplayState.Nothing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// initialise variables
|
||||
/// </summary>
|
||||
private void OnEnable()
|
||||
{
|
||||
UI = GetComponent<UIDocument>().rootVisualElement;
|
||||
SetDisplayState(DisplayState.Nothing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Reference in a new issue