Compare commits

..

2 commits

10 changed files with 319 additions and 384 deletions

View file

@ -378,13 +378,13 @@ private void OnUsernameUpdateButtonClick()
GameManager.Instance.Backend.UpdateUserAccountDetail(Backend.UserAccountDetailTargetEnum.Username, GameManager.Instance.Backend.UpdateUserAccountDetail(Backend.UserAccountDetailTargetEnum.Username,
_usernameField.value, _usernameField.value,
dtr => res =>
{ {
_accompanyingText.style.display = DisplayStyle.Flex; _accompanyingText.style.display = DisplayStyle.Flex;
_accompanyingText.text = dtr switch _accompanyingText.text = res switch
{ {
Backend.DatabaseTransactionResult.Ok => "Username updated!", Backend.TransactionResult.Ok => "Username updated!",
Backend.DatabaseTransactionResult.Unauthenticated => Backend.TransactionResult.Unauthenticated =>
"You are not signed in. Please sign in to update your username.", "You are not signed in. Please sign in to update your username.",
_ => "An error occurred updating the username. Please try again." _ => "An error occurred updating the username. Please try again."
}; };
@ -414,9 +414,9 @@ private void OnEmailUpdateButtonClick()
_accompanyingText.style.display = DisplayStyle.Flex; _accompanyingText.style.display = DisplayStyle.Flex;
_accompanyingText.text = callback switch _accompanyingText.text = callback switch
{ {
Backend.DatabaseTransactionResult.Ok => Backend.TransactionResult.Ok =>
$"Verification email sent to {_emailField.value}! You may want to sign in again to see the changes.", $"Verification email sent to {_emailField.value}! You may want to sign in again to see the changes.",
Backend.DatabaseTransactionResult.Unauthenticated => Backend.TransactionResult.Unauthenticated =>
"You are not signed in. Please sign in to update your email.", "You are not signed in. Please sign in to update your email.",
_ => "An error occurred updating the email. Please try again." _ => "An error occurred updating the email. Please try again."
}; };
@ -446,8 +446,8 @@ private void OnPasswordUpdateButtonClick()
_accompanyingText.style.display = DisplayStyle.Flex; _accompanyingText.style.display = DisplayStyle.Flex;
_accompanyingText.text = callback switch _accompanyingText.text = callback switch
{ {
Backend.DatabaseTransactionResult.Ok => "Password updated!", Backend.TransactionResult.Ok => "Password updated!",
Backend.DatabaseTransactionResult.Unauthenticated => Backend.TransactionResult.Unauthenticated =>
"You are not signed in. Please sign in to update your password.", "You are not signed in. Please sign in to update your password.",
_ => "An error occurred updating the password. Please try again." _ => "An error occurred updating the password. Please try again."
}; };
@ -635,12 +635,23 @@ private void OnTertiaryActionButtonClick()
// delete local data // delete local data
case State.NotSignedIn: case State.NotSignedIn:
PlayerPrefs.DeleteAll(); PlayerPrefs.DeleteAll();
_accompanyingText.style.display = DisplayStyle.Flex;
_accompanyingText.text = "Local data deleted.";
GameManager.Instance.Data.LoadFromTheWorld(GameManager.Instance.FireLocalPlayerDataChangeCallbacks); GameManager.Instance.Data.LoadFromTheWorld(GameManager.Instance.FireLocalPlayerDataChangeCallbacks);
break; break;
// delete user account // delete user account
case State.SignedIn: case State.SignedIn:
GameManager.Instance.Backend.DeleteUser(); GameManager.Instance.Backend.DeleteUser(result =>
{
_accompanyingText.style.display = DisplayStyle.Flex;
_accompanyingText.text = result switch
{
Backend.TransactionResult.Ok => "Account deleted.",
Backend.TransactionResult.Unauthenticated => "You are not signed in.",
_ => "An error occurred deleting the account. Please try again."
};
});
break; break;
case State.AfterContinue: case State.AfterContinue:
@ -661,7 +672,7 @@ private void OnLocalPlayerDataChangeCallback(LocalPlayerData data)
$"updating AccountView ui with lkUsername={data.LastKnownUsername} and lkEmail={data.LastKnownEmail}"); $"updating AccountView ui with lkUsername={data.LastKnownUsername} and lkEmail={data.LastKnownEmail}");
_usernameField.value = data.LastKnownUsername; _usernameField.value = data.LastKnownUsername;
_emailField.value = data.LastKnownEmail; _emailField.value = data.LastKnownEmail;
_header.text = $"Signed in as {data.LastKnownUsername}"; if (state == State.SignedIn) _header.text = $"Signed in as {data.LastKnownUsername}";
} }
/// <summary> /// <summary>

View file

@ -28,16 +28,6 @@ public enum AuthenticationResult
GenericError GenericError
} }
/// <summary>
/// generic enum for the result of a database transaction
/// </summary>
public enum DatabaseTransactionResult
{
Ok,
Unauthenticated,
Error
}
/// <summary> /// <summary>
/// enum for the connection status of the firebase backend /// enum for the connection status of the firebase backend
/// </summary> /// </summary>
@ -51,6 +41,16 @@ public enum FirebaseConnectionStatus
InternalError // "an unknown error occurred" InternalError // "an unknown error occurred"
} }
/// <summary>
/// generic enum for the result of a database transaction
/// </summary>
public enum TransactionResult
{
Ok,
Unauthenticated,
Error
}
public enum UserAccountDetailTargetEnum public enum UserAccountDetailTargetEnum
{ {
Username, Username,
@ -454,14 +454,14 @@ private void RetrieveUsername()
/// <summary> /// <summary>
/// function to retrieve the user's username from the database /// function to retrieve the user's username from the database
/// </summary> /// </summary>
private void RetrieveUsernameWithCallback(Action<DatabaseTransactionResult, string> callback) private void RetrieveUsernameWithCallback(Action<TransactionResult, string> callback)
{ {
if (!Status.Equals(FirebaseConnectionStatus.Connected)) return; if (!Status.Equals(FirebaseConnectionStatus.Connected)) return;
if (_user == null) if (_user == null)
{ {
Debug.LogError("receiving username post-authentication but user is null (should be unreachable)"); Debug.LogError("receiving username post-authentication but user is null (should be unreachable)");
callback(DatabaseTransactionResult.Unauthenticated, "Unknown"); callback(TransactionResult.Unauthenticated, "Unknown");
return; return;
} }
@ -471,16 +471,16 @@ private void RetrieveUsernameWithCallback(Action<DatabaseTransactionResult, stri
.GetValueAsync() .GetValueAsync()
.ContinueWithOnMainThread(task => .ContinueWithOnMainThread(task =>
{ {
DatabaseTransactionResult result; TransactionResult result;
if (task.IsCompletedSuccessfully) if (task.IsCompletedSuccessfully)
{ {
result = DatabaseTransactionResult.Ok; result = TransactionResult.Ok;
_username = task.Result.Value.ToString(); _username = task.Result.Value.ToString();
Debug.Log($"our username is {_username}"); Debug.Log($"our username is {_username}");
} }
else else
{ {
result = DatabaseTransactionResult.Error; result = TransactionResult.Error;
_username = "Unknown"; _username = "Unknown";
Debug.LogError("failed to get username"); Debug.LogError("failed to get username");
} }
@ -514,18 +514,33 @@ public void SignOutUser()
/// <summary> /// <summary>
/// abstraction function to delete the user /// abstraction function to delete the user
/// </summary> /// </summary>
public void DeleteUser() public void DeleteUser(Action<TransactionResult> callback)
{ {
if (!Status.Equals(FirebaseConnectionStatus.Connected))
{
callback(TransactionResult.Error);
return;
}
if (_user == null)
{
callback(TransactionResult.Unauthenticated);
return;
}
_user.DeleteAsync().ContinueWithOnMainThread(task => _user.DeleteAsync().ContinueWithOnMainThread(task =>
{ {
if (task.IsCompletedSuccessfully) if (task.IsCompletedSuccessfully)
{ {
Debug.Log("user deleted"); Debug.Log("user deleted");
SignOutUser(); _user = null;
FireOnSignOutCallbacks();
callback(TransactionResult.Ok);
} }
else else
{ {
Debug.LogError(task.Exception); Debug.LogError($"error deleting user: {task.Exception}");
callback(TransactionResult.Error);
} }
}); });
} }
@ -556,29 +571,29 @@ public void ResetUserPassword(string email, Action<bool> callback)
/// abstraction function to get the user's recent scores from the database /// abstraction function to get the user's recent scores from the database
/// </summary> /// </summary>
/// <param name="callback"> /// <param name="callback">
/// callback function that takes in a <c>DatabaseTransactionResult</c> enum and a /// callback function that takes in a <c>TransactionResult</c> enum and a
/// <c>List&lt;LocalPlayerData.Score&gt;</c> /// <c>List&lt;LocalPlayerData.Score&gt;</c>
/// </param> /// </param>
public void GetRecentScores(Action<DatabaseTransactionResult, List<LocalPlayerData.Score>> callback) public void GetRecentScores(Action<TransactionResult, List<LocalPlayerData.Score>> callback)
{ {
if (!Status.Equals(FirebaseConnectionStatus.Connected)) return; if (!Status.Equals(FirebaseConnectionStatus.Connected)) return;
if (_user == null) if (_user == null)
{ {
callback(DatabaseTransactionResult.Unauthenticated, new List<LocalPlayerData.Score>(0)); callback(TransactionResult.Unauthenticated, new List<LocalPlayerData.Score>(0));
return; return;
} }
_db.Child("scores") _db.Child("scores")
.OrderByChild("timestamp") .OrderByChild("timestamp")
.LimitToLast(LocalPlayerData.MaxBestOnlineScores) .LimitToLast(LocalPlayerData.MaxBestScores)
.GetValueAsync() .GetValueAsync()
.ContinueWithOnMainThread(task => .ContinueWithOnMainThread(task =>
{ {
if (!task.IsCompletedSuccessfully) if (!task.IsCompletedSuccessfully)
{ {
Debug.LogError(task.Exception); Debug.LogError(task.Exception);
callback(DatabaseTransactionResult.Error, new List<LocalPlayerData.Score>(0)); callback(TransactionResult.Error, new List<LocalPlayerData.Score>(0));
return; return;
} }
@ -594,7 +609,7 @@ public void GetRecentScores(Action<DatabaseTransactionResult, List<LocalPlayerDa
Debug.LogError($"{e}\n{child.GetRawJsonValue()}"); Debug.LogError($"{e}\n{child.GetRawJsonValue()}");
} }
callback(DatabaseTransactionResult.Ok, scores); callback(TransactionResult.Ok, scores);
GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data); GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data);
}); });
} }
@ -603,29 +618,29 @@ public void GetRecentScores(Action<DatabaseTransactionResult, List<LocalPlayerDa
/// abstraction function to get the user's best scores from the database /// abstraction function to get the user's best scores from the database
/// </summary> /// </summary>
/// <param name="callback"> /// <param name="callback">
/// callback function that takes in a <c>DatabaseTransactionResult</c> enum and a /// callback function that takes in a <c>TransactionResult</c> enum and a
/// <c>List&lt;LocalPlayerData.Score&gt;</c> /// <c>List&lt;LocalPlayerData.Score&gt;</c>
/// </param> /// </param>
private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerData.Score>> callback) private void GetBestScores(Action<TransactionResult, List<LocalPlayerData.Score>> callback)
{ {
if (!Status.Equals(FirebaseConnectionStatus.Connected)) return; if (!Status.Equals(FirebaseConnectionStatus.Connected)) return;
if (_user == null) if (_user == null)
{ {
callback(DatabaseTransactionResult.Unauthenticated, new List<LocalPlayerData.Score>(0)); callback(TransactionResult.Unauthenticated, new List<LocalPlayerData.Score>(0));
return; return;
} }
_db.Child("scores") _db.Child("scores")
.OrderByChild("avgPerceivedAccuracy") .OrderByChild("avgPerceivedAccuracy")
.LimitToLast(LocalPlayerData.MaxBestOnlineScores) .LimitToLast(LocalPlayerData.MaxBestScores)
.GetValueAsync() .GetValueAsync()
.ContinueWithOnMainThread(task => .ContinueWithOnMainThread(task =>
{ {
if (!task.IsCompletedSuccessfully) if (!task.IsCompletedSuccessfully)
{ {
Debug.LogError(task.Exception); Debug.LogError(task.Exception);
callback(DatabaseTransactionResult.Error, new List<LocalPlayerData.Score>(0)); callback(TransactionResult.Error, new List<LocalPlayerData.Score>(0));
return; return;
} }
@ -641,7 +656,7 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
Debug.LogError(e); Debug.LogError(e);
} }
callback(DatabaseTransactionResult.Ok, scores); callback(TransactionResult.Ok, scores);
GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data); GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data);
}); });
} }
@ -650,16 +665,16 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
/// abstraction function to submit a score to the database /// abstraction function to submit a score to the database
/// </summary> /// </summary>
/// <param name="score">score</param> /// <param name="score">score</param>
/// <param name="callback">callback function that takes in a <c>DatabaseTransactionResult</c> enum </param> /// <param name="callback">callback function that takes in a <c>TransactionResult</c> enum </param>
public void SubmitScore( public void SubmitScore(
LocalPlayerData.Score score, LocalPlayerData.Score score,
Action<DatabaseTransactionResult> callback) Action<TransactionResult> callback)
{ {
if (!Status.Equals(FirebaseConnectionStatus.Connected)) return; if (!Status.Equals(FirebaseConnectionStatus.Connected)) return;
if (_user == null) if (_user == null)
{ {
callback(DatabaseTransactionResult.Unauthenticated); callback(TransactionResult.Unauthenticated);
return; return;
} }
@ -670,12 +685,12 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
{ {
if (task.IsCompletedSuccessfully) if (task.IsCompletedSuccessfully)
{ {
callback(DatabaseTransactionResult.Ok); callback(TransactionResult.Ok);
} }
else else
{ {
Debug.LogError(task.Exception); Debug.LogError(task.Exception);
callback(DatabaseTransactionResult.Error); callback(TransactionResult.Error);
} }
}); });
} }
@ -685,15 +700,15 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
/// calculation is done locally, call UpdateUserRating to update the user's rating in the database /// calculation is done locally, call UpdateUserRating to update the user's rating in the database
/// </summary> /// </summary>
/// <param name="callback"> /// <param name="callback">
/// callback function that takes in a <c>DatabaseTransactionResult</c> enum and a user rating /// callback function that takes in a <c>TransactionResult</c> enum and a user rating
/// <c>float</c> /// <c>float</c>
/// </param> /// </param>
public void CalculateUserRating( public void CalculateUserRating(
Action<DatabaseTransactionResult, float> callback) Action<TransactionResult, float> callback)
{ {
GetRecentScores((recentRes, recentScores) => GetRecentScores((recentRes, recentScores) =>
{ {
if (recentRes != DatabaseTransactionResult.Ok) if (recentRes != TransactionResult.Ok)
{ {
Debug.Log("failed to get recent scores"); Debug.Log("failed to get recent scores");
callback(recentRes, 0f); callback(recentRes, 0f);
@ -702,22 +717,24 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
var recentScoreQueue = GameManager.Instance.Data.RecentOnlineScores; var recentScoreQueue = GameManager.Instance.Data.RecentOnlineScores;
foreach (var score in recentScores) recentScoreQueue.Enqueue(score); foreach (var score in recentScores) recentScoreQueue.Enqueue(score);
while (recentScoreQueue.Count > LocalPlayerData.MaxRecentLocalScores) recentScoreQueue.Dequeue(); while (recentScoreQueue.Count > LocalPlayerData.MaxRecentScores) recentScoreQueue.Dequeue();
GetBestScores((bestRes, bestScores) => GetBestScores((bestRes, bestScores) =>
{ {
if (bestRes != DatabaseTransactionResult.Ok) if (bestRes != TransactionResult.Ok)
{ {
Debug.Log("failed to get recent scores"); Debug.Log("failed to get recent scores");
GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data);
callback(recentRes, 0f); callback(recentRes, 0f);
return; return;
} }
var bestScoreQueue = GameManager.Instance.Data.BestOnlineScores; var bestScoreQueue = GameManager.Instance.Data.BestOnlineScores;
foreach (var score in bestScores) bestScoreQueue.Enqueue(score); foreach (var score in bestScores) bestScoreQueue.Enqueue(score);
while (bestScoreQueue.Count > LocalPlayerData.MaxBestOnlineScores) bestScoreQueue.Dequeue(); while (bestScoreQueue.Count > LocalPlayerData.MaxBestScores) bestScoreQueue.Dequeue();
callback(DatabaseTransactionResult.Ok, GameManager.Instance.Data.CalculateUserRating()); GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data);
callback(TransactionResult.Ok, GameManager.Instance.Data.CalculateUserRating());
}); });
}); });
} }
@ -725,32 +742,35 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
/// <summary> /// <summary>
/// abstraction function to update the user's rating in the database /// abstraction function to update the user's rating in the database
/// </summary> /// </summary>
/// <param name="callback">callback function that takes in a <c>DatabaseTransactionResult</c> enum </param> /// <param name="callback">callback function that takes in a <c>TransactionResult</c> enum </param>
public void UpdateUserRating( public void UpdateUserRating(
Action<DatabaseTransactionResult> callback) Action<TransactionResult> callback)
{ {
if (!Status.Equals(FirebaseConnectionStatus.Connected)) return; if (!Status.Equals(FirebaseConnectionStatus.Connected)) return;
if (_user == null) if (_user == null)
{ {
callback(DatabaseTransactionResult.Unauthenticated); callback(TransactionResult.Unauthenticated);
return; return;
} }
var userRating = GameManager.Instance.Data.CalculateUserRating();
_db.Child("users") _db.Child("users")
.Child(_user.UserId) .Child(_user.UserId)
.Child("rating") .Child("rating")
.SetValueAsync(GameManager.Instance.Data.CalculateUserRating()) .SetValueAsync(userRating)
.ContinueWithOnMainThread(task => .ContinueWithOnMainThread(task =>
{ {
if (task.IsCompletedSuccessfully) if (task.IsCompletedSuccessfully)
{ {
callback(DatabaseTransactionResult.Ok); Debug.Log($"updated online user rating to {userRating}");
callback(TransactionResult.Ok);
} }
else else
{ {
Debug.LogError(task.Exception); Debug.LogError(task.Exception);
callback(DatabaseTransactionResult.Error); callback(TransactionResult.Error);
} }
}); });
} }
@ -759,10 +779,10 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
/// abstraction function to get the leaderboard from the database /// abstraction function to get the leaderboard from the database
/// </summary> /// </summary>
/// <param name="callback"> /// <param name="callback">
/// callback function that takes in a <c>DatabaseTransactionResult</c> enum and a <c>List&lt;LeaderboardEntry&gt;</c> /// callback function that takes in a <c>TransactionResult</c> enum and a <c>List&lt;LeaderboardEntry&gt;</c>
/// </param> /// </param>
public void GetLeaderboard( public void GetLeaderboard(
Action<DatabaseTransactionResult, LeaderboardEntry[]> callback) Action<TransactionResult, LeaderboardEntry[]> callback)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -772,18 +792,18 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
/// </summary> /// </summary>
/// <param name="target">the target account detail to update</param> /// <param name="target">the target account detail to update</param>
/// <param name="newValue">the new value for the target account detail</param> /// <param name="newValue">the new value for the target account detail</param>
/// <param name="callback">callback function that takes in a <c>DatabaseTransactionResult</c> enum</param> /// <param name="callback">callback function that takes in a <c>TransactionResult</c> enum</param>
/// <exception cref="ArgumentOutOfRangeException">thrown when the target is not a valid UserAccountDetailTargetEnum</exception> /// <exception cref="ArgumentOutOfRangeException">thrown when the target is not a valid UserAccountDetailTargetEnum</exception>
public void UpdateUserAccountDetail( public void UpdateUserAccountDetail(
UserAccountDetailTargetEnum target, UserAccountDetailTargetEnum target,
string newValue, string newValue,
Action<DatabaseTransactionResult> callback) Action<TransactionResult> callback)
{ {
if (!Status.Equals(FirebaseConnectionStatus.Connected)) callback(DatabaseTransactionResult.Unauthenticated); if (!Status.Equals(FirebaseConnectionStatus.Connected)) callback(TransactionResult.Unauthenticated);
if (_user == null) if (_user == null)
{ {
callback(DatabaseTransactionResult.Unauthenticated); callback(TransactionResult.Unauthenticated);
return; return;
} }
@ -796,12 +816,12 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
{ {
GameManager.Instance.Data.LastKnownEmail = newValue; GameManager.Instance.Data.LastKnownEmail = newValue;
GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data); GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data);
callback(DatabaseTransactionResult.Ok); callback(TransactionResult.Ok);
} }
else else
{ {
Debug.LogError(task.Exception); Debug.LogError(task.Exception);
callback(DatabaseTransactionResult.Error); callback(TransactionResult.Error);
} }
}); });
break; break;
@ -818,12 +838,12 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
_username = newValue; _username = newValue;
GameManager.Instance.Data.LastKnownUsername = newValue; GameManager.Instance.Data.LastKnownUsername = newValue;
GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data); GameManager.Instance.FireLocalPlayerDataChangeCallbacks(GameManager.Instance.Data);
callback(DatabaseTransactionResult.Ok); callback(TransactionResult.Ok);
} }
else else
{ {
Debug.LogError(task.Exception); Debug.LogError(task.Exception);
callback(DatabaseTransactionResult.Error); callback(TransactionResult.Error);
} }
}); });
break; break;
@ -833,12 +853,12 @@ private void GetBestScores(Action<DatabaseTransactionResult, List<LocalPlayerDat
{ {
if (task.IsCompletedSuccessfully) if (task.IsCompletedSuccessfully)
{ {
callback(DatabaseTransactionResult.Ok); callback(TransactionResult.Ok);
} }
else else
{ {
Debug.LogError(task.Exception); Debug.LogError(task.Exception);
callback(DatabaseTransactionResult.Error); callback(TransactionResult.Error);
} }
}); });
break; break;

View file

@ -175,42 +175,47 @@ public void SignalGameEnd(List<Gameplay.RoundInfo> playedRounds)
var historicalLightnessAcc = 0f; var historicalLightnessAcc = 0f;
var historicalChromaAcc = 0f; var historicalChromaAcc = 0f;
var historicalHueAcc = 0f; var historicalHueAcc = 0f;
var historicalRounds = 0; var historicalPerceivedAcc = 0f;
var historicalGames = 0;
foreach (var localScore in _data.RecentLocalScores) foreach (var localScore in _data.RecentLocalScores.Take(LocalPlayerData.MaxRecentScores))
{ {
historicalLightnessAcc += localScore.AvgLightnessAccuracy; historicalLightnessAcc += localScore.AvgLightnessAccuracy;
historicalChromaAcc += localScore.AvgChromaAccuracy; historicalChromaAcc += localScore.AvgChromaAccuracy;
historicalHueAcc += localScore.AvgHueAccuracy; historicalHueAcc += localScore.AvgHueAccuracy;
historicalRounds += localScore.NoOfRounds; historicalPerceivedAcc += localScore.AvgPerceivedAccuracy;
historicalGames++;
} }
foreach (var onlineScore in _data.RecentOnlineScores) foreach (var onlineScore in _data.RecentOnlineScores.Take(LocalPlayerData.MaxRecentScores))
{ {
historicalLightnessAcc += onlineScore.AvgLightnessAccuracy; historicalLightnessAcc += onlineScore.AvgLightnessAccuracy;
historicalChromaAcc += onlineScore.AvgChromaAccuracy; historicalChromaAcc += onlineScore.AvgChromaAccuracy;
historicalHueAcc += onlineScore.AvgHueAccuracy; historicalHueAcc += onlineScore.AvgHueAccuracy;
historicalRounds += onlineScore.NoOfRounds; historicalPerceivedAcc += onlineScore.AvgPerceivedAccuracy;
historicalGames++;
} }
foreach (var onlineScore in _data.BestOnlineScores) foreach (var onlineScore in _data.BestOnlineScores.Take(LocalPlayerData.MaxBestScores))
{ {
historicalLightnessAcc += onlineScore.AvgLightnessAccuracy; historicalLightnessAcc += onlineScore.AvgLightnessAccuracy;
historicalChromaAcc += onlineScore.AvgChromaAccuracy; historicalChromaAcc += onlineScore.AvgChromaAccuracy;
historicalHueAcc += onlineScore.AvgHueAccuracy; historicalHueAcc += onlineScore.AvgHueAccuracy;
historicalRounds += onlineScore.NoOfRounds; historicalPerceivedAcc += onlineScore.AvgPerceivedAccuracy;
historicalGames++;
} }
historicalLightnessAcc /= historicalRounds; historicalGames = Math.Max(1, historicalGames);
historicalChromaAcc /= historicalRounds; historicalLightnessAcc /= historicalGames;
historicalHueAcc /= historicalRounds; historicalChromaAcc /= historicalGames;
historicalHueAcc /= historicalGames;
historicalPerceivedAcc /= historicalGames;
// calculate round averages // calculate round averages
var gameLightnessAcc = 0d; var gameLightnessAcc = 0d;
var gameChromaAcc = 0d; var gameChromaAcc = 0d;
var gameHueAcc = 0d; var gameHueAcc = 0d;
var gamePerceivedAcc = 0d; var gamePerceivedAcc = 0d;
var templateColour = Color.clear; var templateColour = Color.clear;
var responseColour = Color.clear; var responseColour = Color.clear;
var roundNumber = 1; var roundNumber = 1;
@ -226,7 +231,7 @@ public void SignalGameEnd(List<Gameplay.RoundInfo> playedRounds)
var roundLightnessAcc = Math.Clamp(dLCh.L * 100d, 0d, 100d); var roundLightnessAcc = Math.Clamp(dLCh.L * 100d, 0d, 100d);
var roundChromaAcc = Math.Clamp(dLCh.C * 100d, 0d, 100d); var roundChromaAcc = Math.Clamp(dLCh.C * 100d, 0d, 100d);
var roundHueAcc = Math.Clamp(dLCh.h * 100d, 0d, 100d); var roundHueAcc = Math.Clamp(dLCh.h * 100d, 0d, 100d);
var roundPerceivedAcc = Math.Clamp((100d - distance.dE) * 100d, 0d, 100d); var roundPerceivedAcc = Math.Clamp((1d - distance.dE) * 100d, 0d, 100d);
gameLightnessAcc += roundLightnessAcc; gameLightnessAcc += roundLightnessAcc;
gameChromaAcc += roundChromaAcc; gameChromaAcc += roundChromaAcc;
@ -242,7 +247,7 @@ public void SignalGameEnd(List<Gameplay.RoundInfo> playedRounds)
showcaseTemplate.style.backgroundColor = templateColour; showcaseTemplate.style.backgroundColor = templateColour;
showcaseResponse.style.backgroundColor = responseColour; showcaseResponse.style.backgroundColor = responseColour;
showcaseInfo.text = showcaseInfo.text =
$"{roundLightnessAcc:N0}% {roundChromaAcc:N0}% {roundHueAcc:N0}% ({roundPerceivedAcc:N0}%)"; $"{roundLightnessAcc * (roundPerceivedAcc / 100d):N0}% {roundChromaAcc * (roundPerceivedAcc / 100d):N0}% {roundHueAcc * (roundPerceivedAcc / 100d):N0}% ({roundPerceivedAcc:N0}%)";
} }
else else
{ {
@ -257,25 +262,30 @@ public void SignalGameEnd(List<Gameplay.RoundInfo> playedRounds)
gameHueAcc /= Gameplay.RoundsPerGame; gameHueAcc /= Gameplay.RoundsPerGame;
gamePerceivedAcc /= Gameplay.RoundsPerGame; gamePerceivedAcc /= Gameplay.RoundsPerGame;
// NOTE: this is NOT equiv to user rating, this is just a per-game accuracy score var adjustedHistoricalLightnessAcc = historicalLightnessAcc * (historicalPerceivedAcc / 100d);
// all that math is done in LocalPlayerData.CalculateUserRating var adjustedHistoricalChromaAcc = historicalChromaAcc * (historicalPerceivedAcc / 100d);
var gameAccuracy = (gameLightnessAcc + gameChromaAcc + gameHueAcc + gamePerceivedAcc) / 4; var adjustedHistoricalHueAcc = historicalHueAcc * (historicalPerceivedAcc / 100d);
var adjustedGameLightnessAcc = gameLightnessAcc * (gamePerceivedAcc / 100d);
var adjustedGameChromaAcc = gameChromaAcc * (gamePerceivedAcc / 100d);
var adjustedGameHueAcc = gameHueAcc * (gamePerceivedAcc / 100d);
var gameAccuracy = (gameLightnessAcc + gameChromaAcc + gameHueAcc + gamePerceivedAcc) / 4d;
// make comparison texts // make comparison texts
var lAccDeltaText = (gameLightnessAcc > historicalLightnessAcc ? "+" : "-") + var lAccDeltaText = (adjustedGameLightnessAcc > adjustedHistoricalLightnessAcc ? "+" : "-") +
Math.Abs(gameLightnessAcc - historicalLightnessAcc).ToString("F2"); $"{Math.Abs(adjustedGameLightnessAcc - adjustedHistoricalLightnessAcc):F1}%";
var cAccDeltaText = (gameChromaAcc > historicalChromaAcc ? "+" : "-") + var cAccDeltaText = (adjustedGameChromaAcc > adjustedHistoricalChromaAcc ? "+" : "-") +
Math.Abs(gameChromaAcc - historicalChromaAcc).ToString("F2"); $"{Math.Abs(adjustedGameChromaAcc - adjustedHistoricalChromaAcc):F1}%";
var hAccDeltaText = (gameHueAcc > historicalHueAcc ? "+" : "-") + var hAccDeltaText = (adjustedGameHueAcc > adjustedHistoricalHueAcc ? "+" : "-") +
Math.Abs(gameHueAcc - historicalHueAcc).ToString("F2"); $"{Math.Abs(adjustedGameHueAcc - adjustedHistoricalHueAcc):F1}%";
var score = new LocalPlayerData.Score(DateTime.Now, var score = new LocalPlayerData.Score(DateTime.Now,
playedRounds.Count, playedRounds.Count,
(float)gameLightnessAcc, (float)adjustedGameLightnessAcc,
(float)gameChromaAcc, (float)adjustedGameChromaAcc,
(float)gameHueAcc, (float)adjustedGameHueAcc,
(float)gamePerceivedAcc); (float)gamePerceivedAcc);
// breakpoint here: why is gamePerceivedAcc always "100"?
var oldRating = _data.CalculateUserRating(); var oldRating = _data.CalculateUserRating();
_data.RegisterLocalScore(score); _data.RegisterLocalScore(score);
FireLocalPlayerDataChangeCallbacks(Instance.Data); FireLocalPlayerDataChangeCallbacks(Instance.Data);
@ -285,7 +295,7 @@ public void SignalGameEnd(List<Gameplay.RoundInfo> playedRounds)
Backend.SubmitScore(score, Backend.SubmitScore(score,
submitRes => submitRes =>
{ {
if (submitRes != Backend.DatabaseTransactionResult.Ok) if (submitRes != Backend.TransactionResult.Ok)
{ {
Debug.Log("couldn't submit score"); Debug.Log("couldn't submit score");
TransitionToResultsView(_data.CalculateUserRating()); TransitionToResultsView(_data.CalculateUserRating());
@ -294,17 +304,16 @@ public void SignalGameEnd(List<Gameplay.RoundInfo> playedRounds)
Backend.CalculateUserRating((urcRes, userRating) => Backend.CalculateUserRating((urcRes, userRating) =>
{ {
if (urcRes != Backend.DatabaseTransactionResult.Ok) if (urcRes != Backend.TransactionResult.Ok)
{ {
Debug.Log("couldn't calculate user rating"); Debug.Log("couldn't calculate user rating");
TransitionToResultsView(_data.CalculateUserRating()); TransitionToResultsView(_data.CalculateUserRating());
FireLocalPlayerDataChangeCallbacks(Instance.Data);
return; return;
} }
Backend.UpdateUserRating(updateRes => Backend.UpdateUserRating(updateRes =>
{ {
if (updateRes != Backend.DatabaseTransactionResult.Ok) if (updateRes != Backend.TransactionResult.Ok)
{ {
Debug.Log("calculated user rating but couldn't update it"); Debug.Log("calculated user rating but couldn't update it");
TransitionToResultsView(userRating); TransitionToResultsView(userRating);
@ -321,18 +330,20 @@ public void SignalGameEnd(List<Gameplay.RoundInfo> playedRounds)
void TransitionToResultsView(float rating) void TransitionToResultsView(float rating)
{ {
Debug.Log("signal GameManager-UIManager transition to results view"); Debug.Log("signal GameManager-UIManager transition to results view");
var ratingDifferenceDescriptor = oldRating > rating ? "decreased" : "increased"; var ratingDifferenceDescriptor = rating > oldRating ? "increased" : "decreased";
var ratingText = rating >= 0 var ratingText = rating >= 0
? $"\nYour rating has {ratingDifferenceDescriptor} by {Math.Abs(rating - oldRating):F2}." ? $"\nYour rating has {ratingDifferenceDescriptor} by {Math.Abs(rating - oldRating):F2}."
: "\nYour rating could not be calculated."; : "\nYour rating could not be calculated.";
// build the result text and show the results view // build the result text and show the results view
ui.UI.Q<Label>("ResultsText").text = string.Join(Environment.NewLine, $"Over {playedRounds.Count} rounds,", ui.UI.Q<Label>("ResultsText").text = string.Join(Environment.NewLine,
$"you were {gameAccuracy} accurate.", "", $"Over {playedRounds.Count:N0} rounds,",
$"Lightness was {gameLightnessAcc:F2}% accurate. ({lAccDeltaText} from your average)", $"you were {LocalPlayerData.UserRatingScalingF(gameAccuracy):F2}% accurate. (raw ΔEok={gameAccuracy:F2}%)",
$"Chroma was {gameChromaAcc:F2}% accurate. ({cAccDeltaText} from your average)", "",
$"Hue was {gameHueAcc:F2}% accurate. ({hAccDeltaText} from your average)") + ratingText; $"Lightness was {adjustedGameLightnessAcc:F2}% accurate. ({lAccDeltaText} from your average)",
$"Chroma was {adjustedGameChromaAcc:F2}% accurate. ({cAccDeltaText} from your average)",
$"Hue was {adjustedGameHueAcc:F2}% accurate. ({hAccDeltaText} from your average)") + ratingText;
ui.SetDisplayState(UIManager.DisplayState.ResultsView); ui.SetDisplayState(UIManager.DisplayState.ResultsView);
} }

View file

@ -18,7 +18,7 @@ public class Gameplay
/// seconds per round /// seconds per round
/// </summary> /// </summary>
// ReSharper disable once MemberCanBePrivate.Global // ReSharper disable once MemberCanBePrivate.Global
public const double SecondsPerRound = 15d; public const double SecondsPerRound = 12d;
/// <summary> /// <summary>
/// countdown text label for showing the countdown /// countdown text label for showing the countdown
@ -118,7 +118,8 @@ private void StoreRoundInfo()
TemplateColour = _templateColour.style.backgroundColor.value, TemplateColour = _templateColour.style.backgroundColor.value,
ResponseColour = _responseColour.style.backgroundColor.value ResponseColour = _responseColour.style.backgroundColor.value
}); });
Debug.Log("stored round info"); Debug.Log(
$"stored round info (Template is {_templateColour.style.backgroundColor.value}, Response is {_responseColour.style.backgroundColor.value})");
} }
/// <summary> /// <summary>
@ -127,13 +128,13 @@ private void StoreRoundInfo()
/// </summary> /// </summary>
private void GenerateNewTemplateColour() private void GenerateNewTemplateColour()
{ {
// - lightness: 40-80 // - lightness: 30-90
// - chroma: 0.05-0.20 // - chroma: 0.03-0.20
// - hue: all (0-360) // - hue: all (0-360)
var r = new Random(); var r = new Random();
var l = Math.Clamp(r.NextDouble() * 40d + 40d, 40d, 100d); var l = Math.Clamp(r.NextDouble() * 60d + 30d, 30d, 90d);
var c = Math.Clamp(r.NextDouble() * 0.15d + 0.05d, 0.05d, 0.20d); var c = Math.Clamp(r.NextDouble() * 0.17d + 0.03d, 0.03d, 0.20d);
var h = Math.Clamp(r.NextDouble() * 360d, 0d, 360d); var h = Math.Clamp(r.NextDouble() * 360d, 0d, 360d);
var colour = Colorimetry.RawLchToColor(l, c, h); var colour = Colorimetry.RawLchToColor(l, c, h);
Debug.Log($"generated new template colour LCh({l:F}, {c:F}, {h:F}) -> {colour}"); Debug.Log($"generated new template colour LCh({l:F}, {c:F}, {h:F}) -> {colour}");
@ -147,7 +148,7 @@ private void Render()
{ {
var remaining = (_countdownDatetime - DateTime.Now).TotalSeconds; var remaining = (_countdownDatetime - DateTime.Now).TotalSeconds;
_roundText.text = $"{Round}/{RoundsPerGame}"; _roundText.text = $"{Round}/{RoundsPerGame}";
_countdownText.text = $"{remaining:F}"; _countdownText.text = $"{remaining:F2}";
} }
/// <summary> /// <summary>

View file

@ -9,27 +9,23 @@ public class LocalPlayerData
/// <summary> /// <summary>
/// maximum number of the best online scores to keep track of /// maximum number of the best online scores to keep track of
/// </summary> /// </summary>
public const int MaxBestOnlineScores = 10; public const int MaxBestScores = 10;
/// <summary> /// <summary>
/// maximum number of recent local scores to keep track of /// maximum number of recent local scores to keep track of
/// </summary> /// </summary>
public const int MaxRecentLocalScores = 10; public const int MaxRecentScores = 10;
/// <summary> /// <summary>
/// the gamma value used in the exponential user rating calculation /// the gamma value used in the exponential user rating calculation
/// </summary> /// </summary>
private const float ExponentialUserRatingGamma = 1.75f; private const float ExponentialUserRatingGamma = 2f;
/// <summary> /// <summary>
/// last known email used /// queue of the best online scores,
/// used in user rating calculation and accuracy display stats
/// </summary> /// </summary>
public string LastKnownEmail = ""; public readonly Queue<Score> BestOnlineScores = new(20);
/// <summary>
/// last known username used
/// </summary>
public string LastKnownUsername = "Guest";
/// <summary> /// <summary>
/// queue of the 10 most recent local scores /// queue of the 10 most recent local scores
@ -43,10 +39,14 @@ public class LocalPlayerData
public readonly Queue<Score> RecentOnlineScores = new(10); public readonly Queue<Score> RecentOnlineScores = new(10);
/// <summary> /// <summary>
/// queue of the best online scores, /// last known email used
/// used in user rating calculation and accuracy display stats
/// </summary> /// </summary>
public readonly Queue<Score> BestOnlineScores = new(20); public string LastKnownEmail = "";
/// <summary>
/// last known username used
/// </summary>
public string LastKnownUsername = "Guest";
/// <summary> /// <summary>
/// loads player data from player prefs and database /// loads player data from player prefs and database
@ -149,10 +149,21 @@ public void SaveToTheWorld()
/// <param name="score">the score to register</param> /// <param name="score">the score to register</param>
public void RegisterLocalScore(Score score) public void RegisterLocalScore(Score score)
{ {
while (RecentLocalScores.Count >= MaxRecentLocalScores) RecentLocalScores.Dequeue(); while (RecentLocalScores.Count >= MaxRecentScores) RecentLocalScores.Dequeue();
RecentLocalScores.Enqueue(score); RecentLocalScores.Enqueue(score);
} }
/// <summary>
/// scaling function for user ratings
/// </summary>
/// <returns>the scaled user rating <c>double</c></returns>
public static double UserRatingScalingF(double rating)
{
var rawUserRating = Math.Clamp(rating, 0d, 100d);
var exponentialRating = 100d * Math.Pow(rawUserRating / 100d, ExponentialUserRatingGamma);
return Math.Clamp(exponentialRating, 0d, 100d);
}
/// <summary> /// <summary>
/// calculates the user rating based on whatever local data is available /// calculates the user rating based on whatever local data is available
/// </summary> /// </summary>
@ -164,9 +175,9 @@ public float CalculateUserRating()
// in this case 20 best scores, and 10 recent scores are used // in this case 20 best scores, and 10 recent scores are used
// ensure the scores don't exceed their arbitrary limits // ensure the scores don't exceed their arbitrary limits
while (RecentOnlineScores.Count > MaxRecentLocalScores) RecentOnlineScores.Dequeue(); while (RecentOnlineScores.Count > MaxRecentScores) RecentOnlineScores.Dequeue();
while (RecentLocalScores.Count > MaxRecentLocalScores) RecentLocalScores.Dequeue(); while (RecentLocalScores.Count > MaxRecentScores) RecentLocalScores.Dequeue();
while (BestOnlineScores.Count > MaxBestOnlineScores) BestOnlineScores.Dequeue(); while (BestOnlineScores.Count > MaxBestScores) BestOnlineScores.Dequeue();
// if online scores are available, use them // if online scores are available, use them
var recentScores = RecentOnlineScores.Count > 0 ? RecentOnlineScores : RecentLocalScores; var recentScores = RecentOnlineScores.Count > 0 ? RecentOnlineScores : RecentLocalScores;
@ -177,37 +188,22 @@ public float CalculateUserRating()
foreach (var score in recentScores.Take(10)) foreach (var score in recentScores.Take(10))
{ {
totalRating += (score.AvgLightnessAccuracy + score.AvgChromaAccuracy + score.AvgHueAccuracy +
score.AvgPerceivedAccuracy) / 4d;
scores++; scores++;
var dL = score.AvgLightnessAccuracy;
var dC = score.AvgChromaAccuracy;
var dH = score.AvgHueAccuracy;
var dE = Math.Sqrt(score.AvgLightnessAccuracy * score.AvgLightnessAccuracy
+ score.AvgChromaAccuracy * score.AvgChromaAccuracy
+ score.AvgHueAccuracy * score.AvgHueAccuracy);
totalRating += (dL + dC + dH + dE + dE) / 5d;
} }
foreach (var score in bestScores.Take(20)) foreach (var score in bestScores.Take(20))
{ {
totalRating += (score.AvgLightnessAccuracy + score.AvgChromaAccuracy + score.AvgHueAccuracy +
score.AvgPerceivedAccuracy) / 4d;
scores++; scores++;
var dL = score.AvgLightnessAccuracy;
var dC = score.AvgChromaAccuracy;
var dH = score.AvgHueAccuracy;
var dE = Math.Sqrt(score.AvgLightnessAccuracy * score.AvgLightnessAccuracy
+ score.AvgChromaAccuracy * score.AvgChromaAccuracy
+ score.AvgHueAccuracy * score.AvgHueAccuracy);
totalRating += (dL + dC + dH + dE + dE) / 5d;
} }
scores = Math.Max(1, scores); var rating = UserRatingScalingF(totalRating /= Math.Max(1, scores));
totalRating /= scores; Debug.Log($"locally calculated user rating: lin: {totalRating} -> exp: {rating}");
var rawUserRating = Math.Clamp(totalRating, 0d, 100d); return (float)rating;
var exponentialRating = 100d * Math.Pow(rawUserRating / 100d, ExponentialUserRatingGamma);
Debug.Log($"locally calculated user rating: lin: {rawUserRating} -> exp: {exponentialRating}");
return (float)exponentialRating;
} }
public struct Score public struct Score

View file

@ -106,12 +106,12 @@ private static void OnAccountButtonClicked()
private void RenderFromPlayerData(LocalPlayerData data) private void RenderFromPlayerData(LocalPlayerData data)
{ {
Debug.Log("updating SideView > AccountSection with new player data"); Debug.Log("updating SideView > AccountSection with new player data");
// calculate averages from both recent local scores and online scores // calculate averages from both recent local scores and online scores
var totalLightnessAcc = 0f; var totalLightnessAcc = 0f;
var totalChromaAcc = 0f; var totalChromaAcc = 0f;
var totalHueAcc = 0f; var totalHueAcc = 0f;
var totalRounds = 0; var totalGames = 0;
// average out all the scores we have to get a stable-ish average // average out all the scores we have to get a stable-ish average
@ -120,7 +120,7 @@ private void RenderFromPlayerData(LocalPlayerData data)
totalLightnessAcc += localScore.AvgLightnessAccuracy; totalLightnessAcc += localScore.AvgLightnessAccuracy;
totalChromaAcc += localScore.AvgChromaAccuracy; totalChromaAcc += localScore.AvgChromaAccuracy;
totalHueAcc += localScore.AvgHueAccuracy; totalHueAcc += localScore.AvgHueAccuracy;
totalRounds += localScore.NoOfRounds; totalGames++;
} }
foreach (var onlineScore in data.RecentOnlineScores) foreach (var onlineScore in data.RecentOnlineScores)
@ -128,7 +128,7 @@ private void RenderFromPlayerData(LocalPlayerData data)
totalLightnessAcc += onlineScore.AvgLightnessAccuracy; totalLightnessAcc += onlineScore.AvgLightnessAccuracy;
totalChromaAcc += onlineScore.AvgChromaAccuracy; totalChromaAcc += onlineScore.AvgChromaAccuracy;
totalHueAcc += onlineScore.AvgHueAccuracy; totalHueAcc += onlineScore.AvgHueAccuracy;
totalRounds += onlineScore.NoOfRounds; totalGames++;
} }
foreach (var onlineScore in data.BestOnlineScores) foreach (var onlineScore in data.BestOnlineScores)
@ -136,14 +136,14 @@ private void RenderFromPlayerData(LocalPlayerData data)
totalLightnessAcc += onlineScore.AvgLightnessAccuracy; totalLightnessAcc += onlineScore.AvgLightnessAccuracy;
totalChromaAcc += onlineScore.AvgChromaAccuracy; totalChromaAcc += onlineScore.AvgChromaAccuracy;
totalHueAcc += onlineScore.AvgHueAccuracy; totalHueAcc += onlineScore.AvgHueAccuracy;
totalRounds += onlineScore.NoOfRounds; totalGames++;
} }
Debug.Log($"tL={totalLightnessAcc} tC={totalChromaAcc} tH={totalHueAcc} tR={totalRounds}"); Debug.Log($"tL={totalLightnessAcc} tC={totalChromaAcc} tH={totalHueAcc} tG={totalGames}");
if (totalRounds == 0) totalRounds = 1; if (totalGames == 0) totalGames = 1;
var lightnessAcc = totalLightnessAcc / totalRounds; var lightnessAcc = totalLightnessAcc / totalGames;
var chromaAcc = totalChromaAcc / totalRounds; var chromaAcc = totalChromaAcc / totalGames;
var hueAcc = totalHueAcc / totalRounds; var hueAcc = totalHueAcc / totalGames;
var playerText = GameManager.Instance.Backend.IsSignedIn var playerText = GameManager.Instance.Backend.IsSignedIn
? data.LastKnownUsername ? data.LastKnownUsername
: $"{data.LastKnownUsername} (Not Signed In)"; : $"{data.LastKnownUsername} (Not Signed In)";
@ -151,9 +151,9 @@ private void RenderFromPlayerData(LocalPlayerData data)
// finally, set the labels // finally, set the labels
_playerText.text = playerText; _playerText.text = playerText;
_ratingText.text = $"{rating:F}"; _ratingText.text = $"{rating:F3}";
_lightnessAccuracyText.text = $"{lightnessAcc:F}"; _lightnessAccuracyText.text = $"{lightnessAcc:F2}%";
_chromaAccuracyText.text = $"{chromaAcc:F}"; _chromaAccuracyText.text = $"{chromaAcc:F2}%";
_hueAccuracyText.text = $"{hueAcc:F}"; _hueAccuracyText.text = $"{hueAcc:F2}%";
} }
} }

View file

@ -66,6 +66,13 @@ private void Start()
SetDisplayState(DisplayState.DefaultView); SetDisplayState(DisplayState.DefaultView);
} }
private void Update()
{
var gameplay = GameManager.Instance.Gameplay;
if (gameplay == null) return;
if (gameplay.Round >= 1) gameplay.Update();
}
/// <summary> /// <summary>
/// initialise variables and register callbacks /// initialise variables and register callbacks
/// </summary> /// </summary>
@ -74,13 +81,6 @@ private void OnEnable()
UI = GetComponent<UIDocument>().rootVisualElement; UI = GetComponent<UIDocument>().rootVisualElement;
} }
private void Update()
{
var gameplay = GameManager.Instance.Gameplay;
if (gameplay == null) return;
if (gameplay.Round >= 1) gameplay.Update();
}
/// <summary> /// <summary>
/// function to show a menu based on the enum passed, /// function to show a menu based on the enum passed,
/// and any other necessary actions /// and any other necessary actions
@ -141,7 +141,7 @@ public void SetDisplayState(DisplayState newDisplayState)
UI.Q<Button>("AccountButton").style.display = DisplayStyle.None; UI.Q<Button>("AccountButton").style.display = DisplayStyle.None;
UI.Q<VisualElement>("AccountSection").style.display = DisplayStyle.Flex; UI.Q<VisualElement>("AccountSection").style.display = DisplayStyle.Flex;
UI.Q<VisualElement>("ConnectionStatus").style.display = DisplayStyle.None; UI.Q<VisualElement>("ConnectionStatus").style.display = DisplayStyle.None;
// start the game // start the game
GameManager.Instance.Gameplay.StartGame(); GameManager.Instance.Gameplay.StartGame();
} }

View file

@ -1,245 +1,136 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" <Style src="project://database/Assets/UI/GameUI.uss?fileID=7433441132597879392&amp;guid=2c7ff79f21a3e8e408e76d75944d575b&amp;type=3#GameUI" />
noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> <ui:VisualElement name="Root" style="flex-grow: 1; background-color: rgb(208, 152, 194); justify-content: space-around; align-items: stretch; align-self: stretch; flex-direction: row;">
<Style src="project://database/Assets/UI/GameUI.uss?fileID=7433441132597879392&amp;guid=2c7ff79f21a3e8e408e76d75944d575b&amp;type=3#GameUI"/> <ui:VisualElement name="SideView" style="flex-grow: 0; background-color: rgb(15, 13, 27); flex-shrink: 0; width: 25%; justify-content: space-between;">
<ui:VisualElement name="Root" <ui:VisualElement name="Header" style="flex-grow: 0; margin-top: 10%; margin-right: 10%; margin-bottom: 0; margin-left: 10%; justify-content: space-between; align-items: flex-start; flex-direction: column;">
style="flex-grow: 1; background-color: rgb(208, 152, 194); justify-content: space-around; align-items: stretch; align-self: stretch; flex-direction: row;"> <ui:Label tabindex="-1" text="Colour Me OK" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" style="color: rgb(208, 152, 194); -unity-font-style: bold; font-size: 58px; white-space: normal;" />
<ui:VisualElement name="SideView" <ui:Label tabindex="-1" text="Color Me OK is a colour-matching game using the coordinates of the OKLCh colour model on the OKLab perceptually uniform colour space." parse-escape-sequences="true" display-tooltip-when-elided="true" name="Description" style="font-size: 16px; white-space: normal; text-overflow: clip; color: rgb(208, 152, 194);" />
style="flex-grow: 0; background-color: rgb(15, 13, 27); flex-shrink: 0; width: 25%; justify-content: space-between;">
<ui:VisualElement name="Header"
style="flex-grow: 0; margin-top: 10%; margin-right: 10%; margin-bottom: 0; margin-left: 10%; justify-content: space-between; align-items: flex-start; flex-direction: column;">
<ui:Label tabindex="-1" text="Colour Me OK" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="Name"
style="color: rgb(208, 152, 194); -unity-font-style: bold; font-size: 58px; white-space: normal;"/>
<ui:Label tabindex="-1"
text="Color Me OK is a colour-matching game using the coordinates of the OKLCh colour model on the OKLab perceptually uniform colour space."
parse-escape-sequences="true" display-tooltip-when-elided="true" name="Description"
style="font-size: 16px; white-space: normal; text-overflow: clip; color: rgb(208, 152, 194);"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="Content" <ui:VisualElement name="Content" style="flex-grow: 0; padding-right: 10%; padding-bottom: 10%; padding-left: 10%;">
style="flex-grow: 0; padding-right: 10%; padding-bottom: 10%; padding-left: 10%;"> <ui:Button text="Play ↗" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PlayButton" style="display: none;" />
<ui:Button text="Play ↗" parse-escape-sequences="true" display-tooltip-when-elided="true" <ui:Button text="Leaderboard ↗" parse-escape-sequences="true" display-tooltip-when-elided="true" name="LeaderboardButton" style="display: none;" />
name="PlayButton" style="display: none;"/> <ui:Button text="Account ↗" parse-escape-sequences="true" display-tooltip-when-elided="true" name="AccountButton" style="display: none;" />
<ui:Button text="Leaderboard ↗" parse-escape-sequences="true" display-tooltip-when-elided="true" <ui:VisualElement name="AccountSection" style="flex-grow: 0; border-top-color: rgb(208, 152, 194); margin-top: 0; border-top-width: 1px; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-color: rgb(208, 152, 194); padding-bottom: 12px; border-bottom-width: 1px; display: flex;">
name="LeaderboardButton" style="display: none;"/> <ui:VisualElement name="PlayerDetails" style="flex-grow: 1; flex-direction: row; align-items: stretch; justify-content: space-between; font-size: 10px; align-self: stretch;">
<ui:Button text="Account ↗" parse-escape-sequences="true" display-tooltip-when-elided="true"
name="AccountButton" style="display: none;"/>
<ui:VisualElement name="AccountSection"
style="flex-grow: 0; border-top-color: rgb(208, 152, 194); margin-top: 0; border-top-width: 1px; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-color: rgb(208, 152, 194); padding-bottom: 12px; border-bottom-width: 1px; display: flex;">
<ui:VisualElement name="PlayerDetails"
style="flex-grow: 1; flex-direction: row; align-items: stretch; justify-content: space-between; font-size: 10px; align-self: stretch;">
<ui:VisualElement name="PlayerNameDetail" style="flex-grow: 1;"> <ui:VisualElement name="PlayerNameDetail" style="flex-grow: 1;">
<ui:Label tabindex="-1" text="Player" parse-escape-sequences="true" <ui:Label tabindex="-1" text="Player" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PlayerHeader" style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-left;" />
display-tooltip-when-elided="true" name="PlayerHeader" <ui:Label tabindex="-1" text="Not Signed In" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PlayerText" style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; text-overflow: clip;" />
style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-left;"/>
<ui:Label tabindex="-1" text="Not Signed In" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="PlayerText"
style="-unity-font-style: normal; font-size: 18px; padding-top: 6px;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="PlayerRatingDetail" style="flex-grow: 0;"> <ui:VisualElement name="PlayerRatingDetail" style="flex-grow: 0;">
<ui:Label tabindex="-1" text="Rating" parse-escape-sequences="true" <ui:Label tabindex="-1" text="Rating" parse-escape-sequences="true" display-tooltip-when-elided="true" name="RatingHeader" style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-right;" />
display-tooltip-when-elided="true" name="RatingHeader" <ui:Label tabindex="-1" text="00.00%" parse-escape-sequences="true" display-tooltip-when-elided="true" name="RatingText" style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; -unity-text-align: upper-right; text-overflow: ellipsis;" />
style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-right;"/>
<ui:Label tabindex="-1" text="00.00%" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="RatingText"
style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; -unity-text-align: upper-right;"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="AccuracyDetails" <ui:VisualElement name="AccuracyDetails" style="flex-grow: 1; flex-direction: row; align-items: stretch; justify-content: space-between; font-size: 10px; align-self: stretch; padding-top: 4px;">
style="flex-grow: 1; flex-direction: row; align-items: stretch; justify-content: space-between; font-size: 10px; align-self: stretch; padding-top: 4px;">
<ui:VisualElement name="LightnessAccuracyDetail" style="flex-grow: 0;"> <ui:VisualElement name="LightnessAccuracyDetail" style="flex-grow: 0;">
<ui:Label tabindex="-1" text="Lightness&#10;Accuracy" parse-escape-sequences="true" <ui:Label tabindex="-1" text="Lightness&#10;Accuracy" parse-escape-sequences="true" display-tooltip-when-elided="true" name="LightnessAccuracyHeader" style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-left; padding-top: 0;" />
display-tooltip-when-elided="true" name="LightnessAccuracyHeader" <ui:Label tabindex="-1" text="00.0%" parse-escape-sequences="true" display-tooltip-when-elided="true" name="LightnessAccuracyText" style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; padding-bottom: 0;" />
style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-left; padding-top: 0;"/>
<ui:Label tabindex="-1" text="00.0%" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="LightnessAccuracyText"
style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; padding-bottom: 0;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ChromaAccuracyDetail" style="flex-grow: 0;"> <ui:VisualElement name="ChromaAccuracyDetail" style="flex-grow: 0;">
<ui:Label tabindex="-1" text="Chroma&#10;Accuracy" parse-escape-sequences="true" <ui:Label tabindex="-1" text="Chroma&#10;Accuracy" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ChromaAccuracyHeader" style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-center; padding-top: 0;" />
display-tooltip-when-elided="true" name="ChromaAccuracyHeader" <ui:Label tabindex="-1" text="00.0%" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ChromaAccuracyText" style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; -unity-text-align: upper-center; padding-bottom: 0;" />
style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-center; padding-top: 0;"/>
<ui:Label tabindex="-1" text="00.0%" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="ChromaAccuracyText"
style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; -unity-text-align: upper-center; padding-bottom: 0;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="HueAccuracyDetail" style="flex-grow: 0;"> <ui:VisualElement name="HueAccuracyDetail" style="flex-grow: 0;">
<ui:Label tabindex="-1" text="Hue&#10;Accuracy" parse-escape-sequences="true" <ui:Label tabindex="-1" text="Hue&#10;Accuracy" parse-escape-sequences="true" display-tooltip-when-elided="true" name="HueAccuracyHeader" style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-right; padding-top: 0;" />
display-tooltip-when-elided="true" name="HueAccuracyHeader" <ui:Label tabindex="-1" text="00.0%" parse-escape-sequences="true" display-tooltip-when-elided="true" name="HueAccuracyText" style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; -unity-text-align: upper-right; padding-bottom: 0;" />
style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-right; padding-top: 0;"/>
<ui:Label tabindex="-1" text="00.0%" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="HueAccuracyText"
style="-unity-font-style: normal; font-size: 18px; padding-top: 6px; -unity-text-align: upper-right; padding-bottom: 0;"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ConnectionStatus" <ui:VisualElement name="ConnectionStatus" style="flex-grow: 0; border-top-color: rgb(208, 152, 194); margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-color: rgb(208, 152, 194); padding-bottom: 12px; display: flex; border-bottom-width: 1px;">
style="flex-grow: 0; border-top-color: rgb(208, 152, 194); margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-color: rgb(208, 152, 194); padding-bottom: 12px; display: flex; border-bottom-width: 1px;"> <ui:Label tabindex="-1" text="Status: Unknown" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ConnectionStatusText" style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-left; display: flex;" />
<ui:Label tabindex="-1" text="Status: Unknown" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="ConnectionStatusText"
style="-unity-font-style: normal; font-size: 14px; padding-bottom: 0; -unity-text-align: lower-left; display: flex;"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="MainView" <ui:VisualElement name="MainView" style="flex-grow: 0; flex-shrink: 0; width: 75%; justify-content: space-between;">
style="flex-grow: 0; flex-shrink: 0; width: 75%; justify-content: space-between;"> <ui:VisualElement name="DefaultView" style="flex-grow: 0; justify-content: space-around; height: 100%; align-self: stretch; display: none;">
<ui:VisualElement name="DefaultView" <ui:VisualElement name="DemoResponseColour" style="flex-grow: 1; background-color: rgb(0, 0, 0); align-self: stretch; justify-content: center;">
style="flex-grow: 0; justify-content: space-around; height: 100%; align-self: stretch; display: none;"> <ui:VisualElement name="DemoResponseSliderContainer" style="flex-grow: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; padding-top: 2%; padding-right: 2%; padding-bottom: 2%; padding-left: 2%; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; background-color: rgb(208, 152, 194);">
<ui:VisualElement name="DemoResponseColour" <ui:Slider label="Lightness" high-value="100" name="DemoResponseLightnessSlider" class="lch-slider" />
style="flex-grow: 1; background-color: rgb(0, 0, 0); align-self: stretch; justify-content: center;"> <ui:Slider label="Chroma" high-value="0.5" name="DemoResponseChromaSlider" class="lch-slider" />
<ui:VisualElement name="DemoResponseSliderContainer" <ui:Slider label="Hue" high-value="360" name="DemoResponseHueSlider" class="lch-slider" />
style="flex-grow: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; padding-top: 2%; padding-right: 2%; padding-bottom: 2%; padding-left: 2%; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; background-color: rgb(208, 152, 194);">
<ui:Slider label="Lightness" high-value="100" name="DemoResponseLightnessSlider"
class="lch-slider"/>
<ui:Slider label="Chroma" high-value="0.5" name="DemoResponseChromaSlider" class="lch-slider"/>
<ui:Slider label="Hue" high-value="360" name="DemoResponseHueSlider" class="lch-slider"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="GameView" <ui:VisualElement name="GameView" style="flex-grow: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; justify-content: space-between; height: 100%; align-self: stretch; display: none;">
style="flex-grow: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; justify-content: space-between; height: 100%; align-self: stretch; display: none;"> <ui:VisualElement name="GameHeader" style="flex-grow: 0; flex-direction: row; justify-content: space-between; align-self: stretch;">
<ui:VisualElement name="GameHeader" <ui:Label tabindex="-1" text="1/5" parse-escape-sequences="true" display-tooltip-when-elided="true" name="RoundText" style="font-size: 58px; -unity-font-style: normal;" />
style="flex-grow: 0; flex-direction: row; justify-content: space-between; align-self: stretch;"> <ui:Label tabindex="-1" text="0.00s" parse-escape-sequences="true" display-tooltip-when-elided="true" name="TimeText" style="-unity-text-align: lower-right; font-size: 58px;" />
<ui:Label tabindex="-1" text="1/5" parse-escape-sequences="true" display-tooltip-when-elided="true"
name="RoundText" style="font-size: 58px; -unity-font-style: normal;"/>
<ui:Label tabindex="-1" text="0.00s" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="TimeText"
style="-unity-text-align: lower-right; font-size: 58px;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ColourPreview" <ui:VisualElement name="ColourPreview" style="flex-grow: 0; height: 50%; background-color: rgb(255, 255, 255); border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; flex-direction: row; padding-top: 2%; padding-right: 2%; padding-bottom: 2%; padding-left: 2%; justify-content: space-between;">
style="flex-grow: 0; height: 50%; background-color: rgb(255, 255, 255); border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; flex-direction: row; padding-top: 2%; padding-right: 2%; padding-bottom: 2%; padding-left: 2%; justify-content: space-between;"> <ui:VisualElement name="TemplatePreview" style="flex-grow: 0; flex-shrink: 0; height: 100%; width: 49%;">
<ui:VisualElement name="TemplatePreview" <ui:Label tabindex="-1" text="Template" parse-escape-sequences="true" display-tooltip-when-elided="true" name="TemplateText" style="margin-bottom: 12px; margin-top: 0; -unity-font-style: normal;" />
style="flex-grow: 0; flex-shrink: 0; height: 100%; width: 49%;"> <ui:VisualElement name="TemplateColour" style="flex-grow: 1; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; background-color: rgb(0, 0, 0);" />
<ui:Label tabindex="-1" text="Template" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="TemplateText"
style="margin-bottom: 12px; margin-top: 0; -unity-font-style: normal;"/>
<ui:VisualElement name="TemplateColour"
style="flex-grow: 1; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; background-color: rgb(0, 0, 0);"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ResponsePreview" <ui:VisualElement name="ResponsePreview" style="flex-grow: 0; flex-shrink: 0; height: 100%; width: 49%;">
style="flex-grow: 0; flex-shrink: 0; height: 100%; width: 49%;"> <ui:Label tabindex="-1" text="Response" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ResponseText" style="margin-bottom: 12px; margin-top: 0; -unity-font-style: normal; -unity-text-align: upper-right;" />
<ui:Label tabindex="-1" text="Response" parse-escape-sequences="true" <ui:VisualElement name="ResponseColour" style="flex-grow: 1; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; background-color: rgb(0, 0, 0);" />
display-tooltip-when-elided="true" name="ResponseText"
style="margin-bottom: 12px; margin-top: 0; -unity-font-style: normal; -unity-text-align: upper-right;"/>
<ui:VisualElement name="ResponseColour"
style="flex-grow: 1; border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; background-color: rgb(0, 0, 0);"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ResponseSliders" style="flex-grow: 0; display: flex;"> <ui:VisualElement name="ResponseSliders" style="flex-grow: 0; display: flex;">
<ui:Slider label="Lightness" high-value="100" name="ResponseLightnessSlider" class="lch-slider"/> <ui:Slider label="Lightness" high-value="100" name="ResponseLightnessSlider" class="lch-slider" />
<ui:Slider label="Chroma" high-value="0.5" name="ResponseChromaSlider" class="lch-slider"/> <ui:Slider label="Chroma" high-value="0.5" name="ResponseChromaSlider" class="lch-slider" />
<ui:Slider label="Hue" high-value="360" name="ResponseHueSlider" class="lch-slider"/> <ui:Slider label="Hue" high-value="360" name="ResponseHueSlider" class="lch-slider" />
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ResultsView" <ui:VisualElement name="ResultsView" style="flex-grow: 1; display: none; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; justify-content: space-between;">
style="flex-grow: 1; display: none; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; justify-content: space-between;"> <ui:VisualElement name="ColourShowcase" style="flex-grow: 1; background-color: rgb(255, 255, 255); border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; padding-top: 2%; padding-right: 2%; padding-bottom: 2%; padding-left: 2%; margin-bottom: 2%; margin-top: 0; margin-right: 0; margin-left: 0;">
<ui:VisualElement name="ColourShowcase" <ui:Label tabindex="-1" text="Templates" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ShowcaseTemplatesText" style="-unity-text-align: upper-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 2%; padding-left: 0;" />
style="flex-grow: 1; background-color: rgb(255, 255, 255); border-top-left-radius: 8px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-bottom-left-radius: 8px; padding-top: 2%; padding-right: 2%; padding-bottom: 2%; padding-left: 2%; margin-bottom: 2%; margin-top: 0; margin-right: 0; margin-left: 0;">
<ui:Label tabindex="-1" text="Templates" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="ShowcaseTemplatesText"
style="-unity-text-align: upper-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 2%; padding-left: 0;"/>
<ui:VisualElement name="Gallery" style="flex-grow: 1; flex-direction: row;"> <ui:VisualElement name="Gallery" style="flex-grow: 1; flex-direction: row;">
<ui:VisualElement name="ShowcasePair1" style="flex-grow: 1;"> <ui:VisualElement name="ShowcasePair1" style="flex-grow: 1;">
<ui:VisualElement name="ShowcasePair1TemplateColour" <ui:VisualElement name="ShowcasePair1TemplateColour" style="flex-grow: 1; background-color: rgb(15, 13, 27); border-top-left-radius: 8px; border-bottom-left-radius: 8px;" />
style="flex-grow: 1; background-color: rgb(15, 13, 27); border-top-left-radius: 8px; border-bottom-left-radius: 8px;"/> <ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ShowcasePair1Info" style="-unity-text-align: upper-center; font-size: 18px;" />
<ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" <ui:VisualElement name="ShowcasePair1ResponseColour" style="flex-grow: 1; border-bottom-left-radius: 8px; border-left-color: rgb(26, 22, 40); border-right-color: rgb(26, 22, 40); border-top-color: rgb(26, 22, 40); border-bottom-color: rgb(26, 22, 40); background-color: rgb(26, 22, 40); border-top-left-radius: 8px;" />
display-tooltip-when-elided="true" name="ShowcasePair1Info"
style="-unity-text-align: upper-center; font-size: 18px;"/>
<ui:VisualElement name="ShowcasePair1ResponseColour"
style="flex-grow: 1; border-bottom-left-radius: 8px; border-left-color: rgb(26, 22, 40); border-right-color: rgb(26, 22, 40); border-top-color: rgb(26, 22, 40); border-bottom-color: rgb(26, 22, 40); background-color: rgb(26, 22, 40); border-top-left-radius: 8px;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ShowcasePair2" style="flex-grow: 1;"> <ui:VisualElement name="ShowcasePair2" style="flex-grow: 1;">
<ui:VisualElement name="ShowcasePair2TemplateColour" <ui:VisualElement name="ShowcasePair2TemplateColour" style="flex-grow: 1; background-color: rgb(42, 33, 56);" />
style="flex-grow: 1; background-color: rgb(42, 33, 56);"/> <ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ShowcasePair2Info" style="-unity-text-align: upper-center; font-size: 18px;" />
<ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" <ui:VisualElement name="ShowcasePair2ResponseColour" style="flex-grow: 1; background-color: rgb(63, 48, 76);" />
display-tooltip-when-elided="true" name="ShowcasePair2Info"
style="-unity-text-align: upper-center; font-size: 18px;"/>
<ui:VisualElement name="ShowcasePair2ResponseColour"
style="flex-grow: 1; background-color: rgb(63, 48, 76);"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ShowcasePair3" style="flex-grow: 1;"> <ui:VisualElement name="ShowcasePair3" style="flex-grow: 1;">
<ui:VisualElement name="ShowcasePair3TemplateColour" <ui:VisualElement name="ShowcasePair3TemplateColour" style="flex-grow: 1; background-color: rgb(63, 48, 76);" />
style="flex-grow: 1; background-color: rgb(63, 48, 76);"/> <ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ShowcasePair3Info" style="-unity-text-align: upper-center; font-size: 18px;" />
<ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" <ui:VisualElement name="ShowcasePair3ResponseColour" style="flex-grow: 1; background-color: rgb(89, 67, 100);" />
display-tooltip-when-elided="true" name="ShowcasePair3Info"
style="-unity-text-align: upper-center; font-size: 18px;"/>
<ui:VisualElement name="ShowcasePair3ResponseColour"
style="flex-grow: 1; background-color: rgb(89, 67, 100);"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ShowcasePair4" style="flex-grow: 1;"> <ui:VisualElement name="ShowcasePair4" style="flex-grow: 1;">
<ui:VisualElement name="ShowcasePair4TemplateColour" <ui:VisualElement name="ShowcasePair4TemplateColour" style="flex-grow: 1; background-color: rgb(89, 67, 100);" />
style="flex-grow: 1; background-color: rgb(89, 67, 100);"/> <ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ShowcasePair4Info" style="-unity-text-align: upper-center; font-size: 18px;" />
<ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" <ui:VisualElement name="ShowcasePair4ResponseColour" style="flex-grow: 1; background-color: rgb(122, 90, 126);" />
display-tooltip-when-elided="true" name="ShowcasePair4Info"
style="-unity-text-align: upper-center; font-size: 18px;"/>
<ui:VisualElement name="ShowcasePair4ResponseColour"
style="flex-grow: 1; background-color: rgb(122, 90, 126);"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="ShowcasePair5" style="flex-grow: 1;"> <ui:VisualElement name="ShowcasePair5" style="flex-grow: 1;">
<ui:VisualElement name="ShowcasePair5TemplateColour" <ui:VisualElement name="ShowcasePair5TemplateColour" style="flex-grow: 1; background-color: rgb(162, 118, 158); border-top-right-radius: 8px; border-bottom-right-radius: 8px;" />
style="flex-grow: 1; background-color: rgb(162, 118, 158); border-top-right-radius: 8px; border-bottom-right-radius: 8px;"/> <ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ShowcasePair5Info" style="-unity-text-align: upper-center; font-size: 18px;" />
<ui:Label tabindex="-1" text="100% 100% 100% (100%)" parse-escape-sequences="true" <ui:VisualElement name="ShowcasePair5ResponseColour" style="flex-grow: 1; background-color: rgb(208, 152, 194); border-top-right-radius: 8px; border-bottom-right-radius: 8px;" />
display-tooltip-when-elided="true" name="ShowcasePair5Info"
style="-unity-text-align: upper-center; font-size: 18px;"/>
<ui:VisualElement name="ShowcasePair5ResponseColour"
style="flex-grow: 1; background-color: rgb(208, 152, 194); border-top-right-radius: 8px; border-bottom-right-radius: 8px;"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:Label tabindex="-1" text="Responses" parse-escape-sequences="true" <ui:Label tabindex="-1" text="Responses" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ShowcaseResponsesText" style="-unity-text-align: upper-center; padding-top: 1.5%; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0;" />
display-tooltip-when-elided="true" name="ShowcaseResponsesText"
style="-unity-text-align: upper-center; padding-top: 1.5%; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:Label tabindex="-1" <ui:Label tabindex="-1" text="Over n rounds,&#10;you were 100.00% accurate.&#10;&#10;Lightness was 100.00% accurate. (+100.00% from your average)&#10;Chroma was 100.00% accurate. (+100.00% from your average)&#10;Hue was 100.00% accurate. (+100.00% from your average)&#10;&#10;Your RATING has increased by 100.00%." parse-escape-sequences="true" display-tooltip-when-elided="true" name="ResultsText" style="flex-grow: 0; margin-top: 2%; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;" />
text="Over n rounds,&#10;you were 100.00% accurate.&#10;&#10;Lightness was 100.00% accurate. (+100.00% from your average)&#10;Chroma was 100.00% accurate. (+100.00% from your average)&#10;Hue was 100.00% accurate. (+100.00% from your average)&#10;&#10;Your RATING has increased by 100.00%."
parse-escape-sequences="true" display-tooltip-when-elided="true" name="ResultsText"
style="flex-grow: 0; margin-top: 2%; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="LeaderboardView" <ui:VisualElement name="LeaderboardView" style="flex-grow: 1; display: none; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; flex-direction: column; justify-content: space-between;">
style="flex-grow: 1; display: none; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; flex-direction: column; justify-content: space-between;"> <ui:Label tabindex="-1" text="Leaderboard" parse-escape-sequences="true" display-tooltip-when-elided="true" name="LeaderboardHeader" style="font-size: 58px; -unity-font-style: normal;" />
<ui:Label tabindex="-1" text="Leaderboard" parse-escape-sequences="true" <ui:ListView name="LeaderboardListView" />
display-tooltip-when-elided="true" name="LeaderboardHeader"
style="font-size: 58px; -unity-font-style: normal;"/>
<ui:ListView name="LeaderboardListView"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="AccountView" <ui:VisualElement name="AccountView" style="flex-grow: 1; display: flex; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; flex-direction: column; justify-content: space-between;">
style="flex-grow: 1; display: flex; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 3.25%; margin-right: 3.25%; margin-bottom: 3.25%; margin-left: 3.25%; flex-direction: column; justify-content: space-between;"> <ui:Label tabindex="-1" text="You are not signed in." parse-escape-sequences="true" display-tooltip-when-elided="true" name="AccountHeader" style="font-size: 58px; -unity-font-style: normal;" />
<ui:Label tabindex="-1" text="You are not signed in." parse-escape-sequences="true"
display-tooltip-when-elided="true" name="AccountHeader"
style="font-size: 58px; -unity-font-style: normal;"/>
<ui:VisualElement name="AccountFields" style="flex-grow: 0;"> <ui:VisualElement name="AccountFields" style="flex-grow: 0;">
<ui:VisualElement name="UsernameContainer" <ui:VisualElement name="UsernameContainer" style="flex-grow: 1; flex-direction: row; justify-content: space-between;">
style="flex-grow: 1; flex-direction: row; justify-content: space-between;"> <ui:TextField picking-mode="Ignore" label="Username" name="UsernameField" />
<ui:TextField picking-mode="Ignore" label="Username" name="UsernameField"/> <ui:Button text="Update" parse-escape-sequences="true" display-tooltip-when-elided="true" name="UsernameUpdateButton" />
<ui:Button text="Update" parse-escape-sequences="true" display-tooltip-when-elided="true"
name="UsernameUpdateButton"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="EmailContainer" <ui:VisualElement name="EmailContainer" style="flex-grow: 1; flex-direction: row; justify-content: space-between;">
style="flex-grow: 1; flex-direction: row; justify-content: space-between;"> <ui:TextField picking-mode="Ignore" label="Email" name="EmailField" keyboard-type="EmailAddress" />
<ui:TextField picking-mode="Ignore" label="Email" name="EmailField" <ui:Button text="Update" parse-escape-sequences="true" display-tooltip-when-elided="true" name="EmailUpdateButton" />
keyboard-type="EmailAddress"/>
<ui:Button text="Update" parse-escape-sequences="true" display-tooltip-when-elided="true"
name="EmailUpdateButton"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="PasswordContainer" <ui:VisualElement name="PasswordContainer" style="flex-grow: 1; flex-direction: row; justify-content: space-between;">
style="flex-grow: 1; flex-direction: row; justify-content: space-between;"> <ui:TextField picking-mode="Ignore" label="Password" name="PasswordField" password="true" />
<ui:TextField picking-mode="Ignore" label="Password" name="PasswordField" password="true"/> <ui:Button text="Update" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PasswordUpdateButton" />
<ui:Button text="Update" parse-escape-sequences="true" display-tooltip-when-elided="true"
name="PasswordUpdateButton"/>
</ui:VisualElement> </ui:VisualElement>
<ui:Label tabindex="-1" text="A verification email has been sent. Check your inbox." <ui:Label tabindex="-1" text="A verification email has been sent. Check your inbox." parse-escape-sequences="true" display-tooltip-when-elided="true" name="AccompanyingText" style="padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 1.5%; margin-right: 0; margin-bottom: 0.75%; margin-left: 0; -unity-text-align: upper-left; display: none;" />
parse-escape-sequences="true" display-tooltip-when-elided="true" name="AccompanyingText"
style="padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; margin-top: 1.5%; margin-right: 0; margin-bottom: 0.75%; margin-left: 0; -unity-text-align: upper-left; display: none;"/>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="AccountButtons" style="flex-grow: 0; align-items: flex-start;"> <ui:VisualElement name="AccountButtons" style="flex-grow: 0; align-items: flex-start;">
<ui:Button text="Primary Action Button →" parse-escape-sequences="true" <ui:Button text="Primary Action Button →" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PrimaryActionButton" style="-unity-text-align: middle-center; margin-bottom: 1%; margin-right: 1%; margin-top: 1%; -unity-font-style: bold;" />
display-tooltip-when-elided="true" name="PrimaryActionButton" <ui:Button text="Secondary Action Button →" parse-escape-sequences="true" display-tooltip-when-elided="true" name="SecondaryActionButton" style="-unity-text-align: middle-center; margin-bottom: 1%; margin-right: 1%; margin-top: 1%; -unity-font-style: bold;" />
style="-unity-text-align: middle-center; margin-bottom: 1%; margin-right: 1%; margin-top: 1%; -unity-font-style: bold;"/> <ui:Button text="Tertiary Action Button →" parse-escape-sequences="true" display-tooltip-when-elided="true" name="TertiaryActionButton" style="margin-top: 1%; margin-right: 1%; -unity-font-style: bold;" />
<ui:Button text="Secondary Action Button →" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="SecondaryActionButton"
style="-unity-text-align: middle-center; margin-bottom: 1%; margin-right: 1%; margin-top: 1%; -unity-font-style: bold;"/>
<ui:Button text="Tertiary Action Button →" parse-escape-sequences="true"
display-tooltip-when-elided="true" name="TertiaryActionButton"
style="margin-top: 1%; margin-right: 1%; -unity-font-style: bold;"/>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>

View file

@ -4,5 +4,8 @@
EditorBuildSettings: EditorBuildSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Scenes: [] m_Scenes:
- enabled: 1
path: Assets/Scenes/GameScene.unity
guid: 9fc0d4010bbf28b4594072e72b8655ab
m_configObjects: {} m_configObjects: {}

View file

@ -12,8 +12,8 @@ PlayerSettings:
targetDevice: 2 targetDevice: 2
useOnDemandResources: 0 useOnDemandResources: 0
accelerometerFrequency: 60 accelerometerFrequency: 60
companyName: DefaultCompany companyName: Mark Joshwel
productName: ColourMeOKLABGame productName: Colour Me OK
defaultCursor: {fileID: 0} defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0} cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
@ -42,8 +42,8 @@ PlayerSettings:
m_SplashScreenLogos: [] m_SplashScreenLogos: []
m_VirtualRealitySplashScreen: {fileID: 0} m_VirtualRealitySplashScreen: {fileID: 0}
m_HolographicTrackingLossScreen: {fileID: 0} m_HolographicTrackingLossScreen: {fileID: 0}
defaultScreenWidth: 1920 defaultScreenWidth: 1280
defaultScreenHeight: 1080 defaultScreenHeight: 720
defaultScreenWidthWeb: 960 defaultScreenWidthWeb: 960
defaultScreenHeightWeb: 600 defaultScreenHeightWeb: 600
m_StereoRenderingPath: 0 m_StereoRenderingPath: 0
@ -93,7 +93,7 @@ PlayerSettings:
bakeCollisionMeshes: 0 bakeCollisionMeshes: 0
forceSingleInstance: 0 forceSingleInstance: 0
useFlipModelSwapchain: 1 useFlipModelSwapchain: 1
resizableWindow: 0 resizableWindow: 1
useMacAppStoreValidation: 0 useMacAppStoreValidation: 0
macAppStoreCategory: public.app-category.games macAppStoreCategory: public.app-category.games
gpuSkinning: 1 gpuSkinning: 1
@ -104,7 +104,7 @@ PlayerSettings:
xboxEnableFitness: 0 xboxEnableFitness: 0
visibleInBackground: 1 visibleInBackground: 1
allowFullscreenSwitch: 1 allowFullscreenSwitch: 1
fullscreenMode: 1 fullscreenMode: 3
xboxSpeechDB: 0 xboxSpeechDB: 0
xboxEnableHeadOrientation: 0 xboxEnableHeadOrientation: 0
xboxEnableGuest: 0 xboxEnableGuest: 0
@ -140,7 +140,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0 loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0 visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0 tvOSBundleVersion: 1.0
bundleVersion: 0.1 bundleVersion: 1.0.0
preloadedAssets: [] preloadedAssets: []
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0
@ -161,13 +161,14 @@ PlayerSettings:
resetResolutionOnWindowResize: 0 resetResolutionOnWindowResize: 0
androidSupportedAspectRatio: 1 androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1 androidMaxAspectRatio: 2.1
applicationIdentifier: {} applicationIdentifier:
Standalone: co.joshwel.colourmeok
buildNumber: buildNumber:
Standalone: 0 Standalone: 0
VisionOS: 0 VisionOS: 0
iPhone: 0 iPhone: 0
tvOS: 0 tvOS: 0
overrideDefaultApplicationIdentifier: 0 overrideDefaultApplicationIdentifier: 1
AndroidBundleVersionCode: 1 AndroidBundleVersionCode: 1
AndroidMinSdkVersion: 22 AndroidMinSdkVersion: 22
AndroidTargetSdkVersion: 0 AndroidTargetSdkVersion: 0
@ -838,7 +839,8 @@ PlayerSettings:
scriptingDefineSymbols: {} scriptingDefineSymbols: {}
additionalCompilerArguments: {} additionalCompilerArguments: {}
platformArchitecture: {} platformArchitecture: {}
scriptingBackend: {} scriptingBackend:
Standalone: 0
il2cppCompilerConfiguration: {} il2cppCompilerConfiguration: {}
il2cppCodeGeneration: {} il2cppCodeGeneration: {}
managedStrippingLevel: managedStrippingLevel: