| | 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] private Animator teacherAnimator; |
| | 18 | | [SerializeField] private AudioEvent audioEventHappy, audioEventNormal; |
| | 19 | |
|
| | 20 | |
|
| 0 | 21 | | public bool IsHiddenByAnimation { get; private set; } = false; |
| | 22 | |
|
| | 23 | |
|
| | 24 | | public void PlayAnimation(TeacherAnimation animation) |
| | 25 | | { |
| 0 | 26 | | if (!isActiveAndEnabled) |
| 0 | 27 | | return; |
| | 28 | |
|
| | 29 | | switch (animation) |
| | 30 | | { |
| | 31 | | case TeacherAnimation.StepCompleted: |
| 0 | 32 | | teacherAnimator.SetTrigger("StepCompleted"); |
| 0 | 33 | | PlayHappySound(0.3f); |
| 0 | 34 | | break; |
| | 35 | | case TeacherAnimation.QuickGoodbye: |
| 0 | 36 | | teacherAnimator.SetTrigger("QuickGoodbye"); |
| 0 | 37 | | IsHiddenByAnimation = true; |
| 0 | 38 | | break; |
| | 39 | | case TeacherAnimation.Reset: |
| 0 | 40 | | teacherAnimator.SetTrigger("Reset"); |
| 0 | 41 | | IsHiddenByAnimation = false; |
| | 42 | | break; |
| | 43 | | default: |
| | 44 | | break; |
| | 45 | | } |
| 0 | 46 | | } |
| | 47 | |
|
| 0 | 48 | | public void PlaySpeakSound() { audioEventNormal.PlayScheduled(0.4f); } |
| | 49 | |
|
| 0 | 50 | | public void PlayHappySound(float delay) { audioEventHappy.PlayScheduled(delay); } |
| | 51 | |
|
| | 52 | | private void OnEnable() |
| | 53 | | { |
| 0 | 54 | | teacherAnimator.enabled = true; |
| 0 | 55 | | } |
| | 56 | |
|
| | 57 | | private void OnDisable() |
| | 58 | | { |
| 0 | 59 | | teacherAnimator.StopPlayback(); |
| 0 | 60 | | teacherAnimator.enabled = false; |
| 0 | 61 | | } |
| | 62 | | } |
| | 63 | | } |