| | 1 | | using System.Collections; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.EventSystems; |
| | 4 | |
|
| | 5 | | namespace DCL.Tutorial |
| | 6 | | { |
| | 7 | | /// <summary> |
| | 8 | | /// Class that represents one of the tooltip steps included in the onboarding tutorial. |
| | 9 | | /// </summary> |
| | 10 | | public class TutorialStep_Tooltip : TutorialStep, IPointerDownHandler |
| | 11 | | { |
| | 12 | | [SerializeField] protected RectTransform tooltipTransform; |
| 15 | 13 | | [SerializeField] bool clickOnTooltipToFinish = true; |
| | 14 | | [SerializeField] bool setMaxTimeToHide = false; |
| 15 | 15 | | [SerializeField] float maxTimeToHide = 5f; |
| | 16 | |
|
| | 17 | | private bool tooltipStarted = false; |
| | 18 | | private float timeSinceWasOpened = 0f; |
| | 19 | | internal bool stepIsFinished = false; |
| | 20 | | internal bool isRelatedFeatureActived = false; |
| | 21 | |
|
| | 22 | | protected virtual void Update() |
| | 23 | | { |
| 30 | 24 | | if (!setMaxTimeToHide || !tooltipStarted) |
| 30 | 25 | | return; |
| | 26 | |
|
| 0 | 27 | | timeSinceWasOpened += Time.deltaTime; |
| | 28 | |
|
| 0 | 29 | | if (timeSinceWasOpened >= maxTimeToHide) |
| 0 | 30 | | stepIsFinished = true; |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | public virtual void OnPointerDown(PointerEventData eventData) |
| | 34 | | { |
| 0 | 35 | | if (!clickOnTooltipToFinish) |
| 0 | 36 | | return; |
| | 37 | |
|
| 0 | 38 | | stepIsFinished = true; |
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | public override void OnStepStart() |
| | 42 | | { |
| 5 | 43 | | base.OnStepStart(); |
| | 44 | |
|
| 5 | 45 | | SetTooltipPosition(); |
| | 46 | |
|
| 5 | 47 | | if (tutorialController != null) |
| 5 | 48 | | tutorialController.SetTeacherPosition(teacherPositionRef.position); |
| | 49 | |
|
| 5 | 50 | | tooltipStarted = true; |
| 5 | 51 | | } |
| | 52 | |
|
| 25 | 53 | | public override IEnumerator OnStepExecute() { yield return new WaitUntil(() => stepIsFinished); } |
| | 54 | |
|
| | 55 | | public override IEnumerator OnStepPlayHideAnimation() |
| | 56 | | { |
| 5 | 57 | | yield return base.OnStepPlayHideAnimation(); |
| 10 | 58 | | yield return new WaitUntil(() => !isRelatedFeatureActived); |
| 5 | 59 | | } |
| | 60 | |
|
| 0 | 61 | | protected virtual void SetTooltipPosition() { } |
| | 62 | |
|
| 0 | 63 | | public void OverrideSetMaxTimeToHide(bool setMaxTimeToHide) { this.setMaxTimeToHide = setMaxTimeToHide; } |
| | 64 | | } |
| | 65 | | } |