From 7e59239e067910af9615c6e92ba5a6b7137e8181 Mon Sep 17 00:00:00 2001 From: Falampe <falampe@uni-potsdam.de> Date: Wed, 8 Jan 2025 15:30:19 +0100 Subject: [PATCH] =?UTF-8?q?added=20new=20tag=20words=20for=20randSt=C3=B6?= =?UTF-8?q?=20and=20randInt=20in=20ImpulseController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit introduced new global Resolving and Disturbance methodes to ClassController --- .../Runtime/Scripts/ImpulseController.cs | 28 +++++++++++++---- .../WholeClass/Scripts/ClassController.cs | 30 +++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/Packages/vr.teachr.structuretree/Runtime/Scripts/ImpulseController.cs b/Packages/vr.teachr.structuretree/Runtime/Scripts/ImpulseController.cs index a967117ca..3f8d3339e 100644 --- a/Packages/vr.teachr.structuretree/Runtime/Scripts/ImpulseController.cs +++ b/Packages/vr.teachr.structuretree/Runtime/Scripts/ImpulseController.cs @@ -330,22 +330,40 @@ namespace TeachR.StructureTree string keyword = StructureTreeHandler.stc[nextNode.nodeId].soundFileName.ToLower(); switch (keyword) { - case "stö": + case "stö": // a specific disturbance should be triggered - for all if global knowledge is true GoToNextNode(bcs); - ClassController.SetRandomDisturbance(bc.gameObject, _levelOfDistortion); + if (StructureTreeHandler.classHasGlobalKnowledge) + ClassController.SetGlobalRandomDisturbance(_levelOfDistortion); + else + ClassController.SetRandomDisturbance(bc.gameObject, _levelOfDistortion); _levelOfDistortion++; break; - case "stöex": + case "stöex": // a specific disturbance should be triggered, but more extreme! GoToNextNode(bcs); _levelOfDistortion++; + if (StructureTreeHandler.classHasGlobalKnowledge) + ClassController.SetGlobalRandomDisturbance(_levelOfDistortion); + else + ClassController.SetRandomDisturbance(bc.gameObject, _levelOfDistortion); + _levelOfDistortion++; + break; + case "randStö": // a random disturbance should be triggered + GoToNextNode(bcs); ClassController.SetRandomDisturbance(bc.gameObject, _levelOfDistortion); _levelOfDistortion++; break; - case "int": + case "int": // All disturbances should be stopped + GoToNextNode(bcs); + if (StructureTreeHandler.classHasGlobalKnowledge) + ClassController.SolveGlobalRandomDisturbance(); + else + ClassController.SolveRandomDisturbance(); + break; + case "randInt": // some random Disturbance should bes stopped GoToNextNode(bcs); ClassController.SolveRandomDisturbance(); break; - case "anim": + case "anim": // animation based on the structuretree is triggered GoToNextNode(bcs); float maximumDelay = !isInitiationInTree ? maxDelayInAction : maxInitialDelay; HandleAnimations(bcs, chanceToMisbehave, nextNode, maximumDelay); diff --git a/Packages/vr.teachr.students/Runtime/WholeClass/Scripts/ClassController.cs b/Packages/vr.teachr.students/Runtime/WholeClass/Scripts/ClassController.cs index fb632d846..fe4145416 100644 --- a/Packages/vr.teachr.students/Runtime/WholeClass/Scripts/ClassController.cs +++ b/Packages/vr.teachr.students/Runtime/WholeClass/Scripts/ClassController.cs @@ -95,6 +95,27 @@ namespace TeachR.Student { DisruptStudent(student.GetComponent<BehaviourController>(), behaviour); } + /// <summary> + /// Will trigger a Disruption random Disturbance from <class>SpecialBehaviours</class> for each Student in the Classroom. + /// </summary> + /// <param name="level">provides level of distortion, defaults to zero</param> + public static void SetGlobalRandomDisturbance(int level = 0) + { + List<string> possibleDistortions = level switch + { + 0 => SpecialBehaviours._level0Distortion.ToList(), + 1 => SpecialBehaviours._level1Distortion.ToList(), + 2 => SpecialBehaviours._level2Distortion.ToList(), + _ => SpecialBehaviours._level0Distortion.ToList() + .Concat(SpecialBehaviours._level1Distortion) + .Concat(SpecialBehaviours._level2Distortion).ToList() + }; + + AllStudentAttributes.StudentSlots + .ToList() + .ForEach(slot => DisruptStudent(slot, possibleDistortions[Random.Range(0, possibleDistortions.Count)])); + } + public static GameObject GetRandomStudent() { int randomStudentSlot = Random.Range(0, AllStudentAttributes.StudentSlots.Length); @@ -131,5 +152,14 @@ namespace TeachR.Student { int rndDisturbance = Random.Range(0, countOfActiveDisturbances - 1); DisruptStudent(Behaviours[rndDisturbance], Behaviours[rndDisturbance].LastGoodBehaviour); } + + /// <summary> + /// Will reset all Students to their last good behaviour. + /// </summary> + public static void SolveGlobalRandomDisturbance() + => AllStudentAttributes.BehaviourControllers + .Where(bc => bc.IsDistorting) + .ToList() + .ForEach(bc => DisruptStudent(bc, bc.LastGoodBehaviour)); } } \ No newline at end of file -- GitLab