| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DCL.Tutorial |
| | 4 | | { |
| | 5 | | /// <summary> |
| | 6 | | /// Class that represents the onboarding tutorial step related to show the social features available in the taskbar. |
| | 7 | | /// </summary> |
| | 8 | | public class TutorialStep_Tooltip_SocialFeatures : TutorialStep_Tooltip |
| | 9 | | { |
| | 10 | | private const int TEACHER_CANVAS_SORT_ORDER_START = 4; |
| | 11 | |
|
| | 12 | | [SerializeField] InputAction_Hold voiceChatAction; |
| | 13 | |
|
| | 14 | | private int defaultTeacherCanvasSortOrder; |
| | 15 | |
|
| | 16 | | public override void OnStepStart() |
| | 17 | | { |
| 3 | 18 | | base.OnStepStart(); |
| | 19 | |
|
| 3 | 20 | | if (tutorialController.configuration.teacherCanvas != null) |
| 3 | 21 | | defaultTeacherCanvasSortOrder = tutorialController.configuration.teacherCanvas.sortingOrder; |
| | 22 | |
|
| 3 | 23 | | tutorialController.SetTeacherCanvasSortingOrder(TEACHER_CANVAS_SORT_ORDER_START); |
| | 24 | |
|
| 3 | 25 | | if (tutorialController != null && |
| | 26 | | tutorialController.hudController != null) |
| | 27 | | { |
| 3 | 28 | | if (tutorialController.hudController.worldChatWindowHud != null) |
| | 29 | | { |
| 0 | 30 | | tutorialController.hudController.worldChatWindowHud.OnOpen += WorldChatWindowHud_OnOpen; |
| | 31 | | } |
| | 32 | |
|
| 3 | 33 | | if (tutorialController.hudController.friendsHud != null) |
| | 34 | | { |
| 0 | 35 | | tutorialController.hudController.friendsHud.OnFriendsOpened += FriendsHud_OnFriendsOpened; |
| 0 | 36 | | tutorialController.hudController.friendsHud.OnFriendsClosed += FriendsHud_OnFriendsClosed; |
| | 37 | | } |
| | 38 | |
|
| 3 | 39 | | if (voiceChatAction != null) |
| | 40 | | { |
| 3 | 41 | | voiceChatAction.OnStarted += VoiceChatAction_OnStarted; |
| 3 | 42 | | voiceChatAction.OnFinished += VoiceChatAction_OnFinished; |
| | 43 | | } |
| | 44 | | } |
| 3 | 45 | | } |
| | 46 | |
|
| | 47 | | public override void OnStepFinished() |
| | 48 | | { |
| 3 | 49 | | base.OnStepFinished(); |
| | 50 | |
|
| 3 | 51 | | tutorialController.SetTeacherCanvasSortingOrder(defaultTeacherCanvasSortOrder); |
| | 52 | |
|
| 3 | 53 | | if (tutorialController != null && |
| | 54 | | tutorialController.hudController != null) |
| | 55 | | { |
| 3 | 56 | | if (tutorialController.hudController.worldChatWindowHud != null) |
| | 57 | | { |
| 0 | 58 | | tutorialController.hudController.worldChatWindowHud.OnOpen -= WorldChatWindowHud_OnOpen; |
| | 59 | | } |
| | 60 | |
|
| 3 | 61 | | if (tutorialController.hudController.friendsHud != null) |
| | 62 | | { |
| 0 | 63 | | tutorialController.hudController.friendsHud.OnFriendsOpened -= FriendsHud_OnFriendsOpened; |
| 0 | 64 | | tutorialController.hudController.friendsHud.OnFriendsClosed -= FriendsHud_OnFriendsClosed; |
| | 65 | | } |
| | 66 | |
|
| 3 | 67 | | if (voiceChatAction != null) |
| | 68 | | { |
| 3 | 69 | | voiceChatAction.OnStarted -= VoiceChatAction_OnStarted; |
| 3 | 70 | | voiceChatAction.OnFinished -= VoiceChatAction_OnFinished; |
| | 71 | | } |
| | 72 | | } |
| 3 | 73 | | } |
| | 74 | |
|
| | 75 | | protected override void SetTooltipPosition() |
| | 76 | | { |
| 3 | 77 | | base.SetTooltipPosition(); |
| | 78 | |
|
| 3 | 79 | | if (tutorialController != null && |
| | 80 | | tutorialController.hudController != null && |
| | 81 | | tutorialController.hudController.taskbarHud != null) |
| | 82 | | { |
| 0 | 83 | | if (tutorialController.hudController.taskbarHud.socialTooltipReference) |
| | 84 | | { |
| 0 | 85 | | tooltipTransform.position = |
| | 86 | | tutorialController.hudController.taskbarHud.socialTooltipReference.position; |
| | 87 | | } |
| | 88 | | } |
| 3 | 89 | | } |
| | 90 | |
|
| 0 | 91 | | internal void WorldChatWindowHud_OnOpen() { stepIsFinished = true; } |
| | 92 | |
|
| 2 | 93 | | internal void FriendsHud_OnFriendsOpened() { SocialFeatureIsOpen(true); } |
| | 94 | |
|
| 2 | 95 | | internal void FriendsHud_OnFriendsClosed() { SocialFeatureIsOpen(false); } |
| | 96 | |
|
| 2 | 97 | | internal void VoiceChatAction_OnStarted(DCLAction_Hold action) { SocialFeatureIsOpen(true); } |
| | 98 | |
|
| 2 | 99 | | internal void VoiceChatAction_OnFinished(DCLAction_Hold action) { SocialFeatureIsOpen(false); } |
| | 100 | |
|
| | 101 | | private void SocialFeatureIsOpen(bool isOpen) |
| | 102 | | { |
| 4 | 103 | | if (isOpen) |
| | 104 | | { |
| 2 | 105 | | isRelatedFeatureActived = true; |
| 2 | 106 | | stepIsFinished = true; |
| 2 | 107 | | tutorialController.PlayTeacherAnimation(TutorialTeacher.TeacherAnimation.QuickGoodbye); |
| 2 | 108 | | } |
| 2 | 109 | | else if (isRelatedFeatureActived) |
| | 110 | | { |
| 2 | 111 | | isRelatedFeatureActived = false; |
| | 112 | | } |
| 2 | 113 | | } |
| | 114 | | } |
| | 115 | | } |