| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace 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] internal Animator teacherAnimator; |
| | 18 | |
|
| | 19 | | [SerializeField] |
| | 20 | | AudioEvent audioEventHappy, audioEventNormal; |
| | 21 | |
|
| | 22 | | [HideInInspector] public bool isHiddenByAnAnimation = false; |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Play an animation. |
| | 26 | | /// </summary> |
| | 27 | | /// <param name="animation">Animation to play.</param> |
| | 28 | | public void PlayAnimation(TeacherAnimation animation) |
| | 29 | | { |
| 27 | 30 | | if (!isActiveAndEnabled) |
| 0 | 31 | | return; |
| | 32 | |
|
| | 33 | | switch (animation) |
| | 34 | | { |
| | 35 | | case TeacherAnimation.StepCompleted: |
| 20 | 36 | | teacherAnimator.SetTrigger("StepCompleted"); |
| 20 | 37 | | PlayHappySound(0.3f); |
| 20 | 38 | | break; |
| | 39 | | case TeacherAnimation.QuickGoodbye: |
| 5 | 40 | | teacherAnimator.SetTrigger("QuickGoodbye"); |
| 5 | 41 | | isHiddenByAnAnimation = true; |
| 5 | 42 | | break; |
| | 43 | | case TeacherAnimation.Reset: |
| 2 | 44 | | teacherAnimator.SetTrigger("Reset"); |
| 2 | 45 | | isHiddenByAnAnimation = false; |
| | 46 | | break; |
| | 47 | | default: |
| | 48 | | break; |
| | 49 | | } |
| 2 | 50 | | } |
| | 51 | |
|
| 0 | 52 | | public void PlaySpeakSound() { audioEventNormal.PlayScheduled(0.4f); } |
| | 53 | |
|
| 40 | 54 | | public void PlayHappySound(float delay) { audioEventHappy.PlayScheduled(delay); } |
| | 55 | | } |
| | 56 | | } |