From 7df6ea1ecd3b90bf29c2489973693a2813b3ddff Mon Sep 17 00:00:00 2001 From: Jerome Coudron Date: Sun, 14 May 2023 12:37:36 +0000 Subject: [PATCH] Fixed preview and clothes bug --- .../ScriptableObjects/ClothesTheme.asset | 40 +++++++++---------- Assets/Common/Scripts/CourseActivityScreen.cs | 3 +- .../ScriptableObjects/ClothesCourse.asset | 2 +- Assets/Courses/Scripts/CoursesController.cs | 15 ++++--- .../Tests/PlayMode/CourseControllerTests.cs | 15 +++++++ 5 files changed, 47 insertions(+), 28 deletions(-) diff --git a/Assets/Common/ScriptableObjects/ClothesTheme.asset b/Assets/Common/ScriptableObjects/ClothesTheme.asset index 2cb2e56..3c13756 100644 --- a/Assets/Common/ScriptableObjects/ClothesTheme.asset +++ b/Assets/Common/ScriptableObjects/ClothesTheme.asset @@ -14,101 +14,101 @@ MonoBehaviour: m_EditorClassIdentifier: title: Kleren en Kleuren description: Van rok tot sok - themeIndex: 1 + themeIndex: 7 modelIndex: 0 learnables: - name: Blauw image: {fileID: 21300000, guid: 182fb89eba9c64041bef31ca35c4bcd8, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: ddbd51ba81efa0d4386063f0908dddbc, type: 3} - name: Bril image: {fileID: 21300000, guid: c671ae6bf5c5e90419add134a669aec1, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 50ab64534fbf206448eae89e7f849536, type: 3} - name: Geel image: {fileID: 21300000, guid: c7006b8cc5cff974b9ff307fe13fdd5e, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 7e14190a75067624abdb6a2872a4afac, type: 3} - name: Grijs image: {fileID: 21300000, guid: 7d4fdd972dcef1747bcbcc598b075504, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: f71578e140d29484580a9b9ab6ef1b50, type: 3} - name: Groen image: {fileID: 21300000, guid: d1f80913126d4c94285c1160f9e50c24, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: e275659c79beb764b882ed5293d70087, type: 3} - name: Hemd image: {fileID: 21300000, guid: 28d5b4df34fc2b049b2455f303461f45, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 732b94d1c76ad8a4bb3fee5c686c0d8e, type: 3} - name: Hoed image: {fileID: 21300000, guid: cede6c6f958f0ae4bbba6282528292cf, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 6a3028c09a55d4a418b56ea4a716777a, type: 3} - name: Jas image: {fileID: 21300000, guid: 4a61d44b0e2ccb242a97681b429b8343, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 558ee737100d298479641a10ae09852e, type: 3} - name: Kous image: {fileID: 21300000, guid: 83b7dc2f696a1c443acf92f310a61cc3, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: cf8a1b846823a074d90075f29753b679, type: 3} - name: Zwart image: {fileID: 21300000, guid: 5527d4c18ce148a4c8ce7de7b927cb5e, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 2895a22e7719def418818a5b532bfbf5, type: 3} - name: Wit image: {fileID: 21300000, guid: 5387f0486602abf479f049d9afa9d3cb, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 351aac8168f9ea34f95878dd90ef5f3b, type: 3} - name: Trui image: {fileID: 21300000, guid: 2413cb0f9b70cd84aae8a3aa1b83e7e8, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: c907e04793964864dad921a6a01af8a7, type: 3} - name: Handschoenen image: {fileID: 21300000, guid: 12d9777dbc9d4f543b822e38838e47d4, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: cf67ee32acd99eb4d935a4fedb7e1fb1, type: 3} - name: Muts image: {fileID: 21300000, guid: b620a409ad2371d43b418b851715df4d, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 125c5c87cf540e94098608da4a956b21, type: 3} - name: Oranje image: {fileID: 21300000, guid: 16f645dc2176fa248af566b5295b451a, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: d64c7a8ee9206e848b5b3e8ccce0db41, type: 3} - name: Paars image: {fileID: 21300000, guid: d574bf2c96bb5b74080b4cf8ca51312d, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: b19ed4b06b9556d4081c0683b495e71a, type: 3} - name: Rood image: {fileID: 21300000, guid: 47a49435e7b8c9a49b162fb4d6f9ceaa, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 552079dd964f93643a4ca82452c49f35, type: 3} - name: Roze image: {fileID: 21300000, guid: e3c4feacdb7710349b326280e2163a84, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 6d35ec9a9a78cf3429a1366279003e06, type: 3} - name: Schoen image: {fileID: 21300000, guid: 2b98a98c11c5bbf4782d9d41b1c9f213, type: 3} handGuide: {fileID: 0} - thresholdPrecentage: 0.9 + thresholdDistance: 2 clip: {fileID: 32900000, guid: 422c7afc0cb753b42bf72e281c743097, type: 3} diff --git a/Assets/Common/Scripts/CourseActivityScreen.cs b/Assets/Common/Scripts/CourseActivityScreen.cs index c4194d7..a6f679f 100644 --- a/Assets/Common/Scripts/CourseActivityScreen.cs +++ b/Assets/Common/Scripts/CourseActivityScreen.cs @@ -81,12 +81,13 @@ public class CourseActivityScreen : MonoBehaviour // Set progress PersistentDataController.GetInstance().Load(); progress = UserList.GetCurrentUser().GetCourseProgress(course.index); - if (progress != null && course.theme.modelIndex != ModelIndex.NONE) + if (progress != null) { progressBar.value = progress.progress; if (progress.progress == 1.0f) { playButton.SetActive(false); + previewButton.SetActive(false); progressObject.SetActive(false); completedObject.SetActive(true); } diff --git a/Assets/Courses/ScriptableObjects/ClothesCourse.asset b/Assets/Courses/ScriptableObjects/ClothesCourse.asset index b702ca8..1bbb464 100644 --- a/Assets/Courses/ScriptableObjects/ClothesCourse.asset +++ b/Assets/Courses/ScriptableObjects/ClothesCourse.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f6b23e64e6ffb12459ed4f37d7305852, type: 3} m_Name: ClothesCourse m_EditorClassIdentifier: - index: 1 + index: 7 title: Kleren en Kleuren description: // TBA thumbnail: {fileID: 21300000, guid: 4913be0505c981a49bdbee0bbe6c33fe, type: 3} diff --git a/Assets/Courses/Scripts/CoursesController.cs b/Assets/Courses/Scripts/CoursesController.cs index 395b5a9..bff3de6 100644 --- a/Assets/Courses/Scripts/CoursesController.cs +++ b/Assets/Courses/Scripts/CoursesController.cs @@ -253,12 +253,7 @@ public class CoursesController : AbstractFeedback { PersistentDataController.SavedLearnableProgress learnable = progress.GetRandomLearnable(); int panelChosen; - if (course.theme.modelIndex == ModelIndex.NONE) - { - // only multiple choice works in preview mode - panelChosen = 1; - } - else if (learnable.progress > 2.0f) + if (learnable.progress > 2.0f) { panelChosen = 2; } @@ -285,6 +280,14 @@ public class CoursesController : AbstractFeedback //if (isNextSignInTransit || maxWords < progress.completedLearnables) if (isNextSignInTransit) return; + // Code for preview-progress, skipping should give progress unless it is multipleChoice + if (course.theme.modelIndex == ModelIndex.NONE) + { + string currentName = course.theme.learnables[currentWordIndex].name; + // This works both to allow panel 0 to allow progress via skipping and also to allow panel 2 to be skipped. + if (progress.FindLearnable(currentName).progress <= 1f || progress.FindLearnable(currentName).progress >= 2f) progress.UpdateLearnable(currentName, 1.5f); + } + progress.progress = (float)progress.completedLearnables / (float)maxWords; progressBar.fillAmount = progress.progress; diff --git a/Assets/Courses/Tests/PlayMode/CourseControllerTests.cs b/Assets/Courses/Tests/PlayMode/CourseControllerTests.cs index 1b6eb0f..41b1a07 100644 --- a/Assets/Courses/Tests/PlayMode/CourseControllerTests.cs +++ b/Assets/Courses/Tests/PlayMode/CourseControllerTests.cs @@ -135,6 +135,21 @@ public class CoursesControllerTests var coursesController = GameObject.FindObjectOfType(); Assert.IsNotNull(coursesController); + Assert.AreEqual(coursesController.GetPanelId(), 0); + + // Check that you reach multiple-choice after 6 NextSigns + coursesController.NextSign(); + yield return new WaitForSeconds(1f); + coursesController.NextSign(); + yield return new WaitForSeconds(1f); + coursesController.NextSign(); + yield return new WaitForSeconds(1f); + coursesController.NextSign(); + yield return new WaitForSeconds(1f); + coursesController.NextSign(); + yield return new WaitForSeconds(1f); + coursesController.NextSign(); + yield return new WaitForSeconds(1f); Assert.AreEqual(coursesController.GetPanelId(), 1); }