| | 1 | | using DCL.Interface; |
| | 2 | | using System.Collections; |
| | 3 | | using TMPro; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | namespace DCL.Tutorial |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Class that represents the onboarding tutorial step related to the greetings showed in Genesis Plaza. |
| | 11 | | /// </summary> |
| | 12 | | public class TutorialStep_GenesisGreetings : TutorialStep |
| | 13 | | { |
| | 14 | | private const int TEACHER_CANVAS_SORT_ORDER_START = 4; |
| | 15 | | private const int GENESIS_PLAZA_TUTORIAL_LOCATION = 3; |
| | 16 | |
|
| | 17 | | [SerializeField] |
| | 18 | | Button okButton; |
| | 19 | |
|
| | 20 | | [SerializeField] |
| | 21 | | TMP_Text titleText; |
| | 22 | |
|
| | 23 | | private bool stepIsFinished = false; |
| | 24 | | private int defaultTeacherCanvasSortOrder; |
| | 25 | |
|
| | 26 | | public override void OnStepStart() |
| | 27 | | { |
| 0 | 28 | | base.OnStepStart(); |
| | 29 | |
|
| 0 | 30 | | OnChangePlayerCoords(new Vector2Int(0, 0), CommonScriptableObjects.playerCoords.Get()); |
| 0 | 31 | | CommonScriptableObjects.playerCoords.OnChange += OnChangePlayerCoords; |
| | 32 | |
|
| 0 | 33 | | CommonScriptableObjects.userMovementKeysBlocked.Set(true); |
| 0 | 34 | | CommonScriptableObjects.featureKeyTriggersBlocked.Set(true); |
| | 35 | |
|
| 0 | 36 | | titleText.text = titleText.text.Replace("{userName}", UserProfile.GetOwnUserProfile().userName); |
| | 37 | |
|
| 0 | 38 | | okButton.onClick.AddListener(OnOkButtonClick); |
| | 39 | |
|
| 0 | 40 | | if (tutorialController != null) |
| | 41 | | { |
| 0 | 42 | | tutorialController.SetEagleEyeCameraActive(true); |
| | 43 | |
|
| 0 | 44 | | if (tutorialController.configuration.teacherCanvas != null) |
| 0 | 45 | | defaultTeacherCanvasSortOrder = tutorialController.configuration.teacherCanvas.sortingOrder; |
| | 46 | |
|
| 0 | 47 | | tutorialController.SetTeacherCanvasSortingOrder(TEACHER_CANVAS_SORT_ORDER_START); |
| | 48 | |
|
| 0 | 49 | | tutorialController.hudController?.taskbarHud?.SetVisibility(false); |
| | 50 | |
|
| 0 | 51 | | if (Environment.i != null && Environment.i.world != null) |
| | 52 | | { |
| 0 | 53 | | WebInterface.SendSceneExternalActionEvent(Environment.i.world.state.GetCurrentSceneId(), "tutorial", |
| | 54 | | } |
| | 55 | | } |
| 0 | 56 | | } |
| | 57 | |
|
| 0 | 58 | | public override IEnumerator OnStepExecute() { yield return new WaitUntil(() => stepIsFinished); } |
| | 59 | |
|
| | 60 | | public override IEnumerator OnStepPlayHideAnimation() |
| | 61 | | { |
| 0 | 62 | | tutorialController?.SetEagleEyeCameraActive(false); |
| 0 | 63 | | yield return base.OnStepPlayHideAnimation(); |
| 0 | 64 | | } |
| | 65 | |
|
| | 66 | | public override void OnStepFinished() |
| | 67 | | { |
| 0 | 68 | | base.OnStepFinished(); |
| 0 | 69 | | tutorialController.SetTeacherCanvasSortingOrder(defaultTeacherCanvasSortOrder); |
| | 70 | |
|
| 0 | 71 | | CommonScriptableObjects.userMovementKeysBlocked.Set(false); |
| | 72 | |
|
| 0 | 73 | | CommonScriptableObjects.playerCoords.OnChange -= OnChangePlayerCoords; |
| 0 | 74 | | } |
| | 75 | |
|
| 0 | 76 | | internal void OnOkButtonClick() { stepIsFinished = true; } |
| | 77 | |
|
| | 78 | | private void OnChangePlayerCoords(Vector2Int prevCoords, Vector2Int coords) |
| | 79 | | { |
| 0 | 80 | | if (stepIsFinished) |
| 0 | 81 | | return; |
| | 82 | |
|
| 0 | 83 | | if (Mathf.Abs(coords.x) > GENESIS_PLAZA_TUTORIAL_LOCATION || |
| | 84 | | Mathf.Abs(coords.y) > GENESIS_PLAZA_TUTORIAL_LOCATION) |
| | 85 | | { |
| 0 | 86 | | stepIsFinished = true; |
| 0 | 87 | | return; |
| | 88 | | } |
| 0 | 89 | | } |
| | 90 | | } |
| | 91 | | } |