Resolve WES-132-Common-Abstract-Minigame

This commit is contained in:
Jerome Coudron
2023-04-23 21:20:12 +00:00
committed by Jelle De Geest
parent 4fdb8f95cb
commit 966475455a
30 changed files with 1046 additions and 1078 deletions

View File

@@ -1,6 +1,7 @@
using DigitalRuby.Tween;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
@@ -170,10 +171,26 @@ public class CoursesController : AbstractFeedback
void Start()
{
StartCourseController();
signPredictor.SetSignsList(GetSignsList());
signPredictor.SetModel(course.theme.modelIndex);
AddSelfAsListener();
}
/// <summary>
/// Fetches all the strings of the signs of the course
/// </summary>
/// <returns>The signsList that needs to be passed to the signPredictor</returns>
private List<string> GetSignsList()
{
List<string> signsList = new List<string>();
foreach (Learnable learnable in course.theme.learnables)
{
signsList.Add(learnable.name);
}
return signsList;
}
/// <summary>
/// Holds the course-specific logic to start the controller, it is seperated to allow the course to be reset (if that would become needed)
/// </summary>
@@ -410,6 +427,7 @@ public class CoursesController : AbstractFeedback
float accPredictSign = signPredictor.learnableProbabilities[predictedSign];
Learnable predSign = course.theme.learnables.Find(l => l.name.ToUpper().Replace(" ", "-") == predictedSign);
// If there is a feedback-object, we wil change its appearance
if (feedbackText != null && feedbackProgressImage != null)
{
Color col;
@@ -439,6 +457,7 @@ public class CoursesController : AbstractFeedback
feedbackText.color = col;
feedbackProgressImage.color = col;
// Tween the feedback-bar
float oldValue = feedbackProgress.value;
// use an exponential scale
float newValue = Mathf.Exp(4 * (Mathf.Clamp(accCurrentSign / sign.thresholdPercentage, 0.0f, 1.0f) - 1.0f));
@@ -451,6 +470,7 @@ public class CoursesController : AbstractFeedback
});
}
// The internal logic for the courses
if (accPredictSign > sign.thresholdPercentage)
{
// Correct sign