< Summary

Class:DCL.Tutorial.TutorialTeacher
Assembly:Onboarding
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialTeacher.cs
Covered lines:0
Uncovered lines:19
Coverable lines:19
Total lines:63
Line coverage:0% (0 of 19)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PlayAnimation(...)0%30500%
PlaySpeakSound()0%2100%
PlayHappySound(...)0%2100%
OnEnable()0%2100%
OnDisable()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Tutorial/Scripts/TutorialTeacher.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.Tutorial
 4{
 5    /// <summary>
 6    /// This class controls the behaviour of the teacher (a 3D model character) that will be guiding to the player along
 7    /// </summary>
 8    public class TutorialTeacher : MonoBehaviour
 9    {
 10        public enum TeacherAnimation
 11        {
 12            StepCompleted,
 13            QuickGoodbye,
 14            Reset
 15        }
 16
 17        [SerializeField] private Animator teacherAnimator;
 18        [SerializeField] private AudioEvent audioEventHappy, audioEventNormal;
 19
 20
 021        public bool IsHiddenByAnimation { get; private set; } = false;
 22
 23
 24        public void PlayAnimation(TeacherAnimation animation)
 25        {
 026            if (!isActiveAndEnabled)
 027                return;
 28
 29            switch (animation)
 30            {
 31                case TeacherAnimation.StepCompleted:
 032                    teacherAnimator.SetTrigger("StepCompleted");
 033                    PlayHappySound(0.3f);
 034                    break;
 35                case TeacherAnimation.QuickGoodbye:
 036                    teacherAnimator.SetTrigger("QuickGoodbye");
 037                    IsHiddenByAnimation = true;
 038                    break;
 39                case TeacherAnimation.Reset:
 040                    teacherAnimator.SetTrigger("Reset");
 041                    IsHiddenByAnimation = false;
 42                    break;
 43                default:
 44                    break;
 45            }
 046        }
 47
 048        public void PlaySpeakSound() { audioEventNormal.PlayScheduled(0.4f); }
 49
 050        public void PlayHappySound(float delay) { audioEventHappy.PlayScheduled(delay); }
 51
 52        private void OnEnable()
 53        {
 054            teacherAnimator.enabled = true;
 055        }
 56
 57        private void OnDisable()
 58        {
 059            teacherAnimator.StopPlayback();
 060            teacherAnimator.enabled = false;
 061        }
 62    }
 63}