| | 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; |
| | 13 | | [SerializeField] bool setMaxTimeToHide = false; |
| 16 | 14 | | [SerializeField] float maxTimeToHide = 5f; |
| | 15 | |
|
| | 16 | | private bool tooltipStarted = false; |
| | 17 | | private float timeSinceWasOpened = 0f; |
| | 18 | | internal bool stepIsFinished = false; |
| | 19 | | internal bool isRelatedFeatureActived = false; |
| | 20 | |
|
| | 21 | | protected virtual void Update() |
| | 22 | | { |
| 54 | 23 | | if (!setMaxTimeToHide || !tooltipStarted) |
| 48 | 24 | | return; |
| | 25 | |
|
| 6 | 26 | | timeSinceWasOpened += Time.deltaTime; |
| | 27 | |
|
| 6 | 28 | | if (timeSinceWasOpened >= maxTimeToHide) |
| 0 | 29 | | stepIsFinished = true; |
| 6 | 30 | | } |
| | 31 | |
|
| 0 | 32 | | public virtual void OnPointerDown(PointerEventData eventData) { stepIsFinished = true; } |
| | 33 | |
|
| | 34 | | public override void OnStepStart() |
| | 35 | | { |
| 9 | 36 | | base.OnStepStart(); |
| | 37 | |
|
| 9 | 38 | | SetTooltipPosition(); |
| | 39 | |
|
| 9 | 40 | | if (tutorialController != null) |
| 9 | 41 | | tutorialController.SetTeacherPosition(teacherPositionRef.position); |
| | 42 | |
|
| 9 | 43 | | tooltipStarted = true; |
| 9 | 44 | | } |
| | 45 | |
|
| 45 | 46 | | public override IEnumerator OnStepExecute() { yield return new WaitUntil(() => stepIsFinished); } |
| | 47 | |
|
| | 48 | | public override IEnumerator OnStepPlayHideAnimation() |
| | 49 | | { |
| 9 | 50 | | yield return base.OnStepPlayHideAnimation(); |
| 18 | 51 | | yield return new WaitUntil(() => !isRelatedFeatureActived); |
| 9 | 52 | | } |
| | 53 | |
|
| 0 | 54 | | protected virtual void SetTooltipPosition() { } |
| | 55 | |
|
| 0 | 56 | | public void OverrideSetMaxTimeToHide(bool setMaxTimeToHide) { this.setMaxTimeToHide = setMaxTimeToHide; } |
| | 57 | | } |
| | 58 | | } |