New basic signs model
This commit is contained in:
committed by
Jelle De Geest
parent
06aa9206ac
commit
43887af670
@@ -586,18 +586,18 @@ public class HangmanController : AbstractMinigameController
|
||||
/// </summary>
|
||||
/// <param name="accuracy">The accuracy of the passed sign</param>
|
||||
/// <param name="predictedSign">The name of the passed sign</param>
|
||||
protected override void ProcessMostProbableSign(float accuracy, string predictedSign)
|
||||
protected override void ProcessMostProbableSign(float distance, string predictedSign)
|
||||
{
|
||||
// Grab the threshold for the most probable letter
|
||||
Learnable letter = fingerSpelling.learnables.Find((l) => l.name == predictedSign);
|
||||
float threshold = letter.thresholdPercentage;
|
||||
float threshold = letter.thresholdDistance;
|
||||
|
||||
// If there is a feedback-object, we wil change its appearance
|
||||
if (feedbackText != null && feedbackProgressImage != null)
|
||||
{
|
||||
float oldValue = feedbackProgress.value;
|
||||
// use an exponential scale
|
||||
float newValue = Mathf.Exp(4 * (Mathf.Clamp(accuracy / threshold, 0.0f, 1.0f) - 1.0f));
|
||||
float newValue = 1 - Mathf.Clamp(distance - threshold, 0.0f, 3.0f) / 3;
|
||||
feedbackProgress.gameObject.Tween("FeedbackUpdate", oldValue, newValue, 0.2f, TweenScaleFunctions.CubicEaseInOut, (t) =>
|
||||
{
|
||||
if (feedbackProgress != null)
|
||||
@@ -606,14 +606,14 @@ public class HangmanController : AbstractMinigameController
|
||||
}
|
||||
});
|
||||
|
||||
if (accuracy > threshold)
|
||||
if (distance < threshold)
|
||||
{
|
||||
feedbackText.text = $"Herkent '{predictedSign}'";
|
||||
Color green = new Color(139.0f / 255.0f, 212.0f / 255.0f, 94.0f / 255.0f);
|
||||
feedbackText.color = green;
|
||||
feedbackProgressImage.color = green;
|
||||
}
|
||||
else if (accuracy > threshold * 0.9)
|
||||
else if (distance < threshold * 1.5)
|
||||
{
|
||||
feedbackText.text = $"Lijkt op '{predictedSign}'";
|
||||
Color orange = new Color(242.0f / 255.0f, 127.0f / 255.0f, 12.0f / 255.0f);
|
||||
@@ -629,7 +629,7 @@ public class HangmanController : AbstractMinigameController
|
||||
}
|
||||
}
|
||||
// The logic for the internal workings of the game
|
||||
if (accuracy > threshold)
|
||||
if (distance < threshold)
|
||||
{
|
||||
// A different sign was predicted compared to the last call of this function
|
||||
if (previousSign != predictedSign)
|
||||
|
||||
@@ -265,27 +265,36 @@ public class HangmanPlaymodeTests
|
||||
{
|
||||
hangmanController.SinglePlayer();
|
||||
|
||||
hangmanController.ProcessSignForTests(1, "A");
|
||||
hangmanController.ProcessSignForTests(0.001f, "A");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
// The sign for A has been held for 0.2f seconds...
|
||||
Assert.IsTrue(hangmanController.getCurrentTime() >= 0.2f && hangmanController.getCurrentTime() <= 0.3f);
|
||||
|
||||
hangmanController.ProcessSignForTests(1, "B");
|
||||
hangmanController.ProcessSignForTests(0.001f, "B");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
// The sign changed so the time needs to be at 0.2f again
|
||||
Assert.IsTrue(hangmanController.getCurrentTime() >= 0.2f && hangmanController.getCurrentTime() <= 0.3f);
|
||||
|
||||
hangmanController.ProcessSignForTests(1 / 10, "B");
|
||||
hangmanController.ProcessSignForTests(1000, "B");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
// The sign changed is below the threshold, time is no longer tracked
|
||||
// The sign changed is way above the threshold, time is no longer tracked and is reset
|
||||
Assert.IsTrue(hangmanController.getCurrentTime() == 0.0);
|
||||
|
||||
for (float i = 0; i < 1; i += 0.02f)
|
||||
// Check that the time stays zero so long as the distance stays above the threshold
|
||||
Learnable C = hangmanController.fingerSpelling.learnables.Find((l) => l.name == "C");
|
||||
float threshold = C.thresholdDistance;
|
||||
for (float i = 2 * threshold; i > threshold; i -= threshold / 6)
|
||||
{
|
||||
hangmanController.ProcessSignForTests(i, "C");
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
Assert.IsTrue(hangmanController.getCurrentTime() == 0.0);
|
||||
}
|
||||
|
||||
// Check that the time rises above zero when you dip just below the threshold
|
||||
hangmanController.ProcessSignForTests(threshold - 0.01f, "C");
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
Assert.IsTrue(hangmanController.getCurrentTime() > 0.0);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
@@ -350,7 +359,8 @@ public class HangmanPlaymodeTests
|
||||
{
|
||||
while (hangmanController.getCurrentMode() != multiplayerConfirmInput)
|
||||
{
|
||||
hangmanController.ProcessSignForTests(1, letter);
|
||||
// Choose the letter by giving it a very small distance
|
||||
hangmanController.ProcessSignForTests(0.001f, letter);
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
@@ -366,7 +376,8 @@ public class HangmanPlaymodeTests
|
||||
{
|
||||
while (!hangmanController.getUsedLetters().Contains(letter))
|
||||
{
|
||||
hangmanController.ProcessSignForTests(1, letter);
|
||||
// Choose the letter by giving it a very small distance
|
||||
hangmanController.ProcessSignForTests(0.001f, letter);
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user